|
| 1 | +--- |
| 2 | +phase: planning |
| 3 | +title: Agent Console Detail Chat View - Project Planning |
| 4 | +description: Initial task breakdown for focused and scrollable chat content in the interactive agent console |
| 5 | +--- |
| 6 | + |
| 7 | +# Project Planning & Task Breakdown |
| 8 | + |
| 9 | +## Milestones |
| 10 | + |
| 11 | +- [x] Milestone 1: Requirements/design/testing reviewed and accepted |
| 12 | +- [x] Milestone 2: Focus and scroll behavior implemented with tests |
| 13 | +- [x] Milestone 3: Console regression tests complete; manual terminal smoke test deferred (PTY scan returns 0 agents; real-terminal verification recommended before broad rollout) |
| 14 | + |
| 15 | +## Task Breakdown |
| 16 | + |
| 17 | +### Phase 1: Focus Model |
| 18 | + |
| 19 | +- [x] Task 1.1: Add `detail` to `ConsoleFocus` and route focus transitions in `ConsoleApp`. |
| 20 | + - Outcome: pressing `v` from list focus in wide mode enters detail focus when an agent is selected; `Esc` and left arrow return to list focus. |
| 21 | + - Dependencies: none. |
| 22 | + - Validation: focused key-routing helper tests cover `v`, `Esc`, left arrow, no-agent, and narrow-mode no-op behavior. |
| 23 | + - Related tests: ConsoleApp focus/key helper scenarios. |
| 24 | +- [x] Task 1.2: Preserve existing list and input keyboard behavior. |
| 25 | + - Outcome: up/down and `j/k` still change selected agent in list focus; `i`/`m` still enter input focus; input cancel still returns to list focus. |
| 26 | + - Dependencies: Task 1.1. |
| 27 | + - Validation: regression tests for list navigation and input focus routing. |
| 28 | + - Related tests: ConsoleApp focus/key helper scenarios and existing console tests. |
| 29 | +- [x] Task 1.3: Reset detail scroll offset when selected agent changes. |
| 30 | + - Outcome: switching agents returns the detail pane to latest content instead of carrying the prior agent's scroll position. |
| 31 | + - Dependencies: Task 1.1. |
| 32 | + - Validation: helper or component test verifies selected-agent change resets offset. |
| 33 | + - Related tests: ConsoleApp focus/key helper scenarios. |
| 34 | + |
| 35 | +### Phase 2: Scrollable Preview Rendering |
| 36 | + |
| 37 | +- [x] Task 2.1: Add pure viewport/scroll helper logic for preview chat content. |
| 38 | + - Outcome: helper converts `ConversationMessage[]`, message budget, and requested scroll offset into visible lines, clamped offset, max offset, and above/below affordance state. |
| 39 | + - Dependencies: none, but implement before wiring Ink rendering. |
| 40 | + - Validation: unit tests cover newest view, older view, negative offset, too-large offset, long conversations, and multi-line messages. |
| 41 | + - Related tests: PreviewPane viewport helper scenarios. |
| 42 | +- [x] Task 2.2: Pass focus and scroll offset through `PreviewSection` to `PreviewPane`. |
| 43 | + - Outcome: focused preview uses existing `Panel` focus styling and receives the requested detail scroll offset. |
| 44 | + - Dependencies: Tasks 1.1 and 2.1. |
| 45 | + - Validation: component/helper test verifies focused panel prop and visible content changes with offset. |
| 46 | + - Related tests: integration scenarios for focused `PreviewSection`. |
| 47 | +- [x] Task 2.3: Render scroll affordances when older/newer content exists outside the viewport. |
| 48 | + - Outcome: preview header shows subtle up/down indicators only when scrolling is possible. |
| 49 | + - Dependencies: Task 2.1. |
| 50 | + - Validation: unit tests verify `hasAbove`/`hasBelow` states and snapshot-light text assertions for header indicators. |
| 51 | + - Related tests: PreviewPane viewport helper scenarios. |
| 52 | +- [x] Task 2.4: Clamp requested detail scroll offset when messages or terminal height change. |
| 53 | + - Outcome: preview reports clamped offsets upward so `ConsoleApp` state cannot remain outside the valid viewport range. |
| 54 | + - Dependencies: Tasks 2.1 and 2.2. |
| 55 | + - Validation: test covers shrinking content/height and verifies the callback receives the valid offset. |
| 56 | + - Related tests: integration scenarios for changing message count or `maxLines`. |
| 57 | + |
| 58 | +### Phase 3: Tests & Polish |
| 59 | + |
| 60 | +- [x] Task 3.1: Add unit tests for viewport clamping, visible-line selection, and affordance state. |
| 61 | + - Outcome: pure scroll math has deterministic coverage. |
| 62 | + - Dependencies: Task 2.1. |
| 63 | + - Validation: targeted `PreviewPane.test.ts` or new helper test passes. |
| 64 | +- [x] Task 3.2: Add or update console focus/key routing tests. |
| 65 | + - Outcome: list/detail/input key behavior has regression coverage. |
| 66 | + - Dependencies: Tasks 1.1-1.3. |
| 67 | + - Validation: targeted console tests pass. |
| 68 | +- [x] Task 3.3: Run feature lint and targeted console test suites. |
| 69 | + - Outcome: docs and changed console code pass validation. |
| 70 | + - Dependencies: implementation tasks complete. |
| 71 | + - Validation: `npx ai-devkit@latest lint --feature agent-console-detail-chat-view` and `npm test -- --run packages/cli/src/__tests__/tui/console`. |
| 72 | +- [x] Task 3.4: Perform manual terminal smoke test with a running agent when available. |
| 73 | + - Outcome: real Ink focus styling and scroll behavior are visually confirmed. |
| 74 | + - Dependencies: implementation tasks complete and at least one running agent available. |
| 75 | + - Validation: manual notes in testing doc; if no running agent is available, record as deferred with reason. |
| 76 | + |
| 77 | +## Dependencies |
| 78 | + |
| 79 | +- Task 1.1 precedes all detail focus and scroll behavior. |
| 80 | +- Task 2.1 should be implemented before changing Ink rendering so tests can cover the behavior directly. |
| 81 | +- Task 2.4 depends on Task 2.1 because clamping should use the same helper that computes the viewport range. |
| 82 | +- Task 3.2 depends on the chosen key-routing shape in `ConsoleApp`. |
| 83 | +- No external services or API changes are required. |
| 84 | + |
| 85 | +## Test Scenario Coverage |
| 86 | + |
| 87 | +| Testing scenario | Covered by tasks | |
| 88 | +| --- | --- | |
| 89 | +| Newest content appears at offset 0 | 2.1, 3.1 | |
| 90 | +| Older content appears at positive offset | 2.1, 3.1 | |
| 91 | +| Offset clamping | 2.1, 2.4, 3.1 | |
| 92 | +| Focused panel styling | 1.1, 2.2, 3.2 | |
| 93 | +| Scroll keys do not move list selection in detail focus | 1.1, 1.2, 3.2 | |
| 94 | +| Existing list/input behavior is unchanged | 1.2, 3.2 | |
| 95 | +| No hidden focus trap in narrow mode | 1.1, 3.2, 3.4 | |
| 96 | +| Scroll keypresses do not fetch conversation data | 2.2, 2.4, 3.3 | |
| 97 | + |
| 98 | +## Timeline & Estimates |
| 99 | + |
| 100 | +- Focus model: small. |
| 101 | +- Scrollable preview rendering: medium, mainly due to line accounting in terminal UI. |
| 102 | +- Tests and manual smoke: small to medium. |
| 103 | + |
| 104 | +## Risks & Mitigation |
| 105 | + |
| 106 | +| Risk | Impact | Mitigation | |
| 107 | +| --- | --- | --- | |
| 108 | +| Focus trap in hidden narrow preview | High | Keep `v` inactive in narrow mode for this iteration. | |
| 109 | +| Scroll keys break list navigation | High | Centralize key routing and add regression tests for both focus states. | |
| 110 | +| Line accounting differs from Ink wrapping | Medium | Base helper on explicit rendered lines and keep content clipping conservative. | |
| 111 | +| Conversation tail of 20 feels too short | Medium | Keep existing behavior initially; revisit tail size during implementation review if scrolling is not useful enough. | |
| 112 | + |
| 113 | +## Resources Needed |
| 114 | + |
| 115 | +- Existing console TUI components under `packages/cli/src/tui/console`. |
| 116 | +- Existing conversation parsing through `@ai-devkit/agent-manager`. |
| 117 | +- Existing console tests and manual terminal run of `ai-devkit agent console`. |
| 118 | + |
| 119 | +## Planning Status |
| 120 | + |
| 121 | +All tasks complete. 16 console test files (106 tests) pass. CLI lint exits 0. Feature lint passes. Manual PTY smoke verified two-pane layout and clean exit; selected-agent detail focus deferred due to PTY agent-scan limitation — recommended for real-terminal verification before broad rollout. |
0 commit comments