|
| 1 | +--- |
| 2 | +mode: plan |
| 3 | +task: UI+Autosave+Streaming fixes v2 |
| 4 | +created_at: "2026-02-10T23:07:08+08:00" |
| 5 | +complexity: complex |
| 6 | +--- |
| 7 | + |
| 8 | +# Plan: UI + Autosave + Streaming fixes v2 |
| 9 | + |
| 10 | +## Goal |
| 11 | +- Fix streaming completion so it never overwrites existing document text and caret stays stable; output renders in-order like typing. |
| 12 | +- Ensure blank/scratch editing is auto-saved and restored reliably (including on app close) so content isn鈥檛 lost. |
| 13 | +- Clean up bottom status bar visual clutter (no stacked separators/overlaps) and keep key info readable. |
| 14 | +- Confirm max_tokens UI supports large values (>= 1,000,000) and config persists correctly. |
| 15 | +- Verify provider streaming request/response formats for OpenAI/Anthropic/Gemini against latest docs and keep code + tests aligned. |
| 16 | + |
| 17 | +## Scope |
| 18 | +- In: |
| 19 | + - Ghost text/inline completion rendering (`src/gui/editor/*ghost*`, `src/gui/editor/smart_completion_manager.py`) |
| 20 | + - Streaming request/parse plumbing (`src/core/ai_client.py`, `src/core/ai_providers/*`, `src/core/ai_qt_client.py`, `src/gui/ai/enhanced_ai_manager.py`) |
| 21 | + - Autosave/session restore for scratch + project docs (`src/gui/editor/editor_panel.py`, `src/gui/editor/text_editor.py`, `src/main.py`, `src/core/config*.py`) |
| 22 | + - Status bar UI (`src/gui/status/status_bar.py` + related tests) |
| 23 | + - AI config center UI token/stream toggles (`src/gui/ai/unified_ai_config_dialog.py`) |
| 24 | +- Out: |
| 25 | + - Changing project DB schema |
| 26 | + - Adding new providers beyond existing list (only ensure existing auto-adaptation is correct) |
| 27 | + |
| 28 | +## Assumptions / Dependencies |
| 29 | +- Use venv python: `.tmp\\ane0305-venv-311\\Scripts\\python.exe` |
| 30 | +- PyQt6 + pytest-qt available for tests. |
| 31 | +- Provider streaming docs may change; rely on official docs as of 2026-02-10. |
| 32 | + |
| 33 | +## Phases |
| 34 | +1. Create plan + Issue CSV contract; validate CSV. |
| 35 | +2. Streaming render safety: move ghost preview to non-destructive overlay; add tests guarding no overwrite/cursor chaos. |
| 36 | +3. Autosave reliability: flush on close; persist/restore scratch doc; add tests + manual checklist. |
| 37 | +4. Status bar cleanup: remove redundant separators and fix sizing; update layout test. |
| 38 | +5. Provider streaming verification: web research + adjust provider strategies/SSE parsing as needed; add/refresh fixtures. |
| 39 | +6. Regression: run `python -m compileall -q src` and targeted pytest suite; mark Regression DONE via meta commit. |
| 40 | + |
| 41 | +## Tests & Verification |
| 42 | +- Streaming safety -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q tests/test_streaming_ghost_no_overwrite.py` |
| 43 | +- Scratch autosave -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q tests/test_scratch_autosave_restore.py` |
| 44 | +- Status bar -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q tests/test_status_bar_layout.py` |
| 45 | +- Config UI -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q tests/test_ai_config_max_tokens_range.py` |
| 46 | +- Provider streaming -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q tests/test_provider_streaming_openai_claude.py` |
| 47 | +- Regression -> `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m compileall -q src` + `.tmp\\ane0305-venv-311\\Scripts\\python.exe -m pytest -q` |
| 48 | + |
| 49 | +## Issue CSV |
| 50 | +- Path: issues/2026-02-10_23-01-37-ui-autosave-streaming-v2.csv |
| 51 | +- Must share the same timestamp/slug as this plan. |
| 52 | + |
| 53 | +## Tools / MCP |
| 54 | +- `manual` for UI verification. |
| 55 | +- `none` for code work; web search (non-MCP) for provider docs. |
| 56 | + |
| 57 | +## Acceptance Checklist |
| 58 | +- [ ] Streaming completion never modifies document text until user accepts. |
| 59 | +- [ ] Streaming output appears in-order like typing; cancel stops updates; stale chunks ignored. |
| 60 | +- [ ] Closing the app does not lose recently typed content (project docs and scratch). |
| 61 | +- [ ] New/empty project starts with empty content (no ghost/saved garbage). |
| 62 | +- [ ] Bottom status bar has clean separators, no stacked lines or clipping. |
| 63 | +- [ ] Max tokens UI supports >= 1,000,000 and persists. |
| 64 | +- [ ] All issues Dev/Review1/Regression are DONE with tests evidence in Notes. |
| 65 | + |
| 66 | +## Risks / Blockers |
| 67 | +- PyQt paint overlay differences across platforms/themes; needs manual QA. |
| 68 | +- Streaming SSE formats may evolve; fixtures might need updates. |
| 69 | + |
| 70 | +## Rollback / Recovery |
| 71 | +- Keep old Optimal ghost system code; allow toggling default back if deep overlay causes regressions. |
| 72 | +- For autosave: keep scratch autosave file separate and non-destructive. |
| 73 | + |
| 74 | +## Checkpoints |
| 75 | +- Commit + push per issue. |
| 76 | +- Meta commit for Regression_Status after batch passes. |
| 77 | + |
| 78 | +## References |
| 79 | +- src/gui/editor/text_editor.py |
| 80 | +- src/gui/editor/optimal_ghost_text.py |
| 81 | +- src/gui/editor/deep_integrated_ghost_text.py |
| 82 | +- src/gui/editor/smart_completion_manager.py |
| 83 | +- src/core/ai_client.py |
| 84 | +- src/gui/status/status_bar.py |
0 commit comments