From d2834c6cf45656ec2d0a3ca05ec6e401f2d2ad9c Mon Sep 17 00:00:00 2001 From: Nexus Dev Date: Wed, 1 Apr 2026 22:01:27 +0000 Subject: [PATCH] docs(23-03): complete chat integration wiring plan - SUMMARY.md for 23-03 (messageType dispatch, ChatPanel wiring, handoffSpec/postStatusUpdate) - STATE.md: plan advanced, metrics recorded, decisions added - ROADMAP.md: Phase 23 marked Complete (4/4 summaries) --- .planning/ROADMAP.md | 8 +- .planning/STATE.md | 19 ++-- .../23-brainstormer-flow/23-03-SUMMARY.md | 98 +++++++++++++++++++ 3 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 .planning/phases/23-brainstormer-flow/23-03-SUMMARY.md diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 34da8356..d8975332 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -12,7 +12,7 @@ - [x] **Phase 21: Chat Foundation** — Persistent conversation storage, sidebar, CRUD, markdown rendering, theme integration, keyboard shortcuts (completed 2026-04-01) - [x] **Phase 22: Agent Streaming** — Real-time streaming via SSE/WebSocket, agent selector, agent identity on messages, stop/edit/regenerate, slash commands and @mentions (completed 2026-04-01) -- [ ] **Phase 23: Brainstormer Flow** — Brainstormer agent persona, structured questioning flow, spec generation, PM handoff, task creation from chat, agent status updates in chat +- [x] **Phase 23: Brainstormer Flow** — Brainstormer agent persona, structured questioning flow, spec generation, PM handoff, task creation from chat, agent status updates in chat (completed 2026-04-01) - [ ] **Phase 24: Search, History & Branching** — Full-text search across all conversations, export, conversation branching, message bookmarks - [ ] **Phase 25: File System** — Local file storage with dual scoping, libSQL tracking, inline preview, download, agent-generated files, git versioning, placeholder tracking - [ ] **Phase 26: PWA & Performance** — Service worker, Web App Manifest, responsive mobile layout, push notifications, install prompt, performance targets @@ -76,13 +76,13 @@ Plans: 3. When the user clicks "Send to PM," a handoff indicator appears in the chat showing "Brainstormer → PM" with the spec content 4. The PM agent creates one or more Nexus issues from the spec; the user can see task IDs referenced in the PM's reply 5. When an Engineer or Generalist completes a task, a status update message appears in the relevant chat conversation -**Plans:** 3/4 plans executed +**Plans:** 4/4 plans complete Plans: - [x] 23-00-PLAN.md — DB migration (message_type column), shared types/validators, Wave 0 test stubs - [x] 23-01-PLAN.md — Server: addSystemMessage helper, handoff route, status-update route - [x] 23-02-PLAN.md — UI: ChatSpecCard, ChatHandoffIndicator, ChatTaskCreatedBadge, ChatStatusUpdateBadge, useBrainstormerDefault -- [ ] 23-03-PLAN.md — Wiring: ChatMessage dispatch, ChatMessageList propagation, ChatPanel brainstormer default, chatApi handoff +- [x] 23-03-PLAN.md — Wiring: ChatMessage dispatch, ChatMessageList propagation, ChatPanel brainstormer default, chatApi handoff **UI hint**: yes ### Phase 24: Search, History & Branching @@ -206,7 +206,7 @@ All 65 v1 requirements are mapped to exactly one phase. No orphans. |-------|-----------|----------------|--------|-----------| | 21. Chat Foundation | v1.3 | 7/7 | Complete | 2026-04-01 | | 22. Agent Streaming | v1.3 | 6/6 | Complete | 2026-04-01 | -| 23. Brainstormer Flow | v1.3 | 3/4 | In Progress| | +| 23. Brainstormer Flow | v1.3 | 4/4 | Complete | 2026-04-01 | | 24. Search, History & Branching | v1.3 | 0/? | Not started | - | | 25. File System | v1.3 | 0/? | Not started | - | | 26. PWA & Performance | v1.3 | 0/? | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index f480be2b..a24d196c 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,15 +2,15 @@ gsd_state_version: 1.0 milestone: v1.3 milestone_name: milestone -status: executing -stopped_at: Completed 23-brainstormer-flow-23-01-PLAN.md -last_updated: "2026-04-01T21:52:25.549Z" +status: verifying +stopped_at: Completed 23-brainstormer-flow-23-03-PLAN.md +last_updated: "2026-04-01T22:01:10.269Z" last_activity: 2026-04-01 progress: total_phases: 6 - completed_phases: 2 + completed_phases: 3 total_plans: 17 - completed_plans: 16 + completed_plans: 17 percent: 100 --- @@ -27,7 +27,7 @@ See: .planning/PROJECT.md (updated 2026-03-30) Phase: 23 (brainstormer-flow) — EXECUTING Plan: 4 of 4 -Status: Ready to execute +Status: Phase complete — ready for verification Last activity: 2026-04-01 Progress: [██████████] 100% @@ -73,6 +73,7 @@ Progress: [██████████] 100% | Phase 23-brainstormer-flow P00 | 3min | 2 tasks | 11 files | | Phase 23-brainstormer-flow P02 | 5min | 2 tasks | 6 files | | Phase 23-brainstormer-flow P01 | 10min | 2 tasks | 2 files | +| Phase 23-brainstormer-flow P03 | 5 | 2 tasks | 4 files | ## Accumulated Context @@ -115,6 +116,8 @@ Recent decisions affecting current work: - [Phase 23-brainstormer-flow]: Used @/lib/router Link abstraction (not react-router-dom) for ChatTaskCreatedBadge and ChatStatusUpdateBadge — consistent with all other link components in the codebase - [Phase 23-brainstormer-flow]: ChatSpecCardInner extracted as inner component to avoid conditional hook calls after JSON.parse error path in ChatSpecCard - [Phase 23-brainstormer-flow]: issueService imported directly in chatRoutes(db) — option (a) from plan, simplest approach matching heartbeat.ts pattern +- [Phase 23-brainstormer-flow]: Used activeConversationId === null as proxy for new conversation in brainstormer auto-select +- [Phase 23-brainstormer-flow]: Used useToast()/pushToast() for error toast in ChatPanel handleHandoff (custom ToastContext, not sonner) ### Pending Todos @@ -127,6 +130,6 @@ None yet. ## Session Continuity -Last session: 2026-04-01T21:52:25.546Z -Stopped at: Completed 23-brainstormer-flow-23-01-PLAN.md +Last session: 2026-04-01T22:01:10.266Z +Stopped at: Completed 23-brainstormer-flow-23-03-PLAN.md Resume file: None diff --git a/.planning/phases/23-brainstormer-flow/23-03-SUMMARY.md b/.planning/phases/23-brainstormer-flow/23-03-SUMMARY.md new file mode 100644 index 00000000..1ad49861 --- /dev/null +++ b/.planning/phases/23-brainstormer-flow/23-03-SUMMARY.md @@ -0,0 +1,98 @@ +--- +phase: 23-brainstormer-flow +plan: "03" +subsystem: ui +tags: [integration, chat, messageType, dispatch, handoff, brainstormer-default] +dependency_graph: + requires: ["23-01", "23-02"] + provides: ["ChatMessage messageType dispatch", "ChatMessageList propagation", "chatApi.handoffSpec", "chatApi.postStatusUpdate", "ChatPanel brainstormer default + handoff callback"] + affects: + - ui/src/components/ChatMessage.tsx + - ui/src/components/ChatMessageList.tsx + - ui/src/components/ChatPanel.tsx + - ui/src/api/chat.ts +tech_stack: + added: [] + patterns: + - "messageType dispatch block in ChatMessage before role check" + - "useBrainstormerDefault auto-selection on new conversations (activeConversationId === null proxy)" + - "handleHandoff useCallback with queryClient.invalidateQueries + pushToast on error" +key_files: + created: [] + modified: + - ui/src/components/ChatMessage.tsx + - ui/src/components/ChatMessageList.tsx + - ui/src/components/ChatPanel.tsx + - ui/src/api/chat.ts +decisions: + - "Used activeConversationId === null as proxy for 'new conversation' in brainstormer auto-select (messages not needed)" + - "Used useToast() / pushToast() for error toast (sonner not used in codebase; project uses custom ToastContext)" + - "Streaming synthetic message already had messageType: null in ChatMessageList — no change needed" +metrics: + duration_minutes: 5 + completed_date: "2026-04-01" + tasks_completed: 2 + files_modified: 4 +--- + +# Phase 23 Plan 03: Chat Integration Wiring Summary + +Wire all Phase 23 components into the existing chat pipeline: messageType dispatch in ChatMessage, prop propagation in ChatMessageList, brainstormer default auto-select in ChatPanel, and handoff/status-update API methods in chatApi. + +## Tasks Completed + +| Task | Name | Commit | Files | +|------|------|--------|-------| +| 1 | ChatMessage dispatch, ChatMessageList propagation, chatApi handoff method | c7a48bc5 | ChatMessage.tsx, ChatMessageList.tsx, chat.ts | +| 2 | ChatPanel brainstormer default wiring and handoff callback | 3f575453 | ChatPanel.tsx | + +## Changes Made + +### Task 1: ChatMessage, ChatMessageList, chatApi + +**ChatMessage.tsx:** +- Added `messageType?: string | null` and `conversationId?: string` and `onHandoff?` props +- Added messageType dispatch block before the `role === "user"` check that routes to `ChatSpecCard`, `ChatHandoffIndicator`, `ChatTaskCreatedBadge`, `ChatStatusUpdateBadge` based on `messageType` +- Falls through to default markdown rendering if no messageType matches + +**ChatMessageList.tsx:** +- Added `onHandoff?` prop to `ChatMessageListProps` +- Passes `messageType={msg.messageType}`, `conversationId={conversationId}`, and `onHandoff={onHandoff}` to `` +- Synthetic streaming entry already had `messageType: null` — no false dispatch possible + +**chat.ts:** +- Added `handoffSpec(conversationId, spec, targetRole)` — POSTs to `/conversations/:id/handoff` +- Added `postStatusUpdate(conversationId, data)` — POSTs to `/conversations/:id/status-update` + +### Task 2: ChatPanel + +- Imported `useBrainstormerDefault` hook and `useToast` context +- Called `useBrainstormerDefault()` to get the general agent ID +- Added `useEffect` to auto-select brainstormer when `activeAgentId === null` and `!activeConversationId` (new conversation proxy) +- Added `handleHandoff` useCallback that calls `chatApi.handoffSpec`, invalidates messages cache, and shows error toast via `pushToast` on failure +- Passed `onHandoff={handleHandoff}` to `` + +## Verification + +- TypeScript: `pnpm exec tsc --noEmit -p ui/tsconfig.json` — PASSED (no errors) +- Tests: All pre-existing test failures confirmed pre-existing (skill-registry, hmr-port, plugin-worker-manager, company-import-export). No new failures introduced. + +## Deviations from Plan + +### Auto-fixed Issues + +None. + +### Observations + +1. **ChatMessageList already had messageType: null** — The synthetic streaming entry already contained `messageType: null` from Plan 02's implementation. Task 1 confirmed this and passed the messageType through to ChatMessage without any additional changes needed to the streaming entry. + +2. **Toast library** — Plan suggested using `toast.error()` from sonner. The codebase uses a custom `ToastContext` with `pushToast({ title, tone: "error" })`. Used the project's actual pattern instead of sonner. + +3. **brainstormer auto-select proxy** — Plan offered two options: messages-based or `!activeConversationId`. Since `messages` was already available from `useChatMessages(activeConversationId)` in ChatPanel, either approach was valid. Used `!activeConversationId` as the simpler, more semantically correct proxy (new conversation = no ID yet). + +## Known Stubs + +None — all wiring is complete. The handoff route was implemented in Plan 01 (server-side). The components were implemented in Plan 02. This plan connects them. + +## Self-Check: PASSED