Skip to content

Commit 2eac045

Browse files
Merge branch 'ftr/phase-9-chat' into test-deployment
2 parents c0b8562 + 415041c commit 2eac045

File tree

24 files changed

+4172
-384
lines changed

24 files changed

+4172
-384
lines changed

.planning/REQUIREMENTS.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,21 +1731,25 @@ This document defines formal requirements for Holmes v1. Requirements are derive
17311731

17321732
### REQ-CHAT: Contextual Chat
17331733

1734-
#### REQ-CHAT-001: Chat Interface — 🟡 FRONTEND_COMPLETE
1734+
#### REQ-CHAT-001: Chat Interface — ✅ COMPLETE
17351735

17361736
| Sub-Criterion | Status | Notes |
17371737
|---------------|--------|-------|
17381738
| Message input with send button || Full input with keyboard support |
1739-
| Message history display || Scrollable history |
1740-
| Streaming response with typing indicator || Animated typing dots |
1741-
| Markdown rendering || Implemented |
1742-
| Code block formatting || Implemented |
1739+
| Message history display || Scrollable history with SSE streaming |
1740+
| Streaming response with typing indicator || Real-time SSE token streaming via fetchEventSource |
1741+
| Markdown rendering || ReactMarkdown + remark-gfm with styled components |
1742+
| Code block formatting || Custom pre/code styling in dark theme |
17431743
| Mobile-responsive || Responsive design |
1744+
| Inline citation chips || [[file_id\|locator\|label]] parsed to clickable chips |
1745+
| Tool activity indicators || Expandable "Agent is working..." section |
1746+
| Stop/Clear buttons || AbortController cancellation, session reset |
1747+
| Disabled state (no analysis) || Overlay message when analysis not run |
1748+
| Error bubbles with retry || Red-tinted inline error messages |
17441749

1745-
**Backend APIs Needed:**
1746-
- `POST /api/chat` — Send message, receive response
1750+
**Backend API:** `POST /api/cases/:caseId/chat` (SSE streaming) — DONE
17471751

1748-
**Files:** `frontend/src/components/app/chatbot.tsx`, `frontend/src/hooks/useChatbot.ts`, `frontend/src/types/chatbot.ts`
1752+
**Files:** `frontend/src/components/app/chatbot.tsx`, `frontend/src/hooks/useChatbot.ts`, `frontend/src/types/chatbot.ts`, `backend/app/api/chat.py`, `backend/app/services/chat_service.py`, `backend/app/agents/chat_tools.py`, `backend/app/agents/prompts/chat.py`
17491753

17501754
---
17511755

.planning/ROADMAP.md

Lines changed: 118 additions & 66 deletions
Large diffs are not rendered by default.

.planning/STATE.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Holmes Project State
22

33
**Last Updated:** 2026-02-09
4-
**Current Phase:** 10 of 12 (Source Panel & Entity Resolution) — COMPLETE (3/3 plans)
4+
**Current Phase:** 9 of 12 (Chat Interface) — COMPLETE (2/2 plans)
55
**Next Phase:** 11 (Corrections & Refinement)
66
**Current Milestone:** M1 - Holmes v1.0
77

@@ -23,7 +23,7 @@
2323
| 7.3 | KG Frontend (vis-network) | DEFERRED | - | - | Optional; only if D3.js proves insufficient |
2424
| 8 | Synthesis Agent & Intelligence Layer | COMPLETE | 2026-02-08 | 2026-02-09 | 7 plans (16 commits) + 3 bugfix commits: DB models + schemas, agent runner/prompt/factory, pipeline Stage 8, SSE events, 8 API endpoints, frontend types/api/hooks, 7 Verdict components, 3 detail panels, CC tab toggle + SSE synthesis readiness, timeline API wiring, verdict badges. Post-fix: Gemini schema compat, pipeline crash fixes, gap entity resolution with names/types, KG event routing |
2525
| 8.1 | Geospatial Agent & Map View | COMPLETE | 2026-02-09 | 2026-02-09 | 5 plans (5 commits): GeocodingService, GeospatialAgentRunner + pipeline Stage 9, 6 REST API endpoints, frontend API client + hook + trigger UI, enhanced detail panel with 4 sections |
26-
| 9 | Chat Interface & Research | FRONTEND_DONE | - | - | Backend API needed |
26+
| 9 | Chat Interface & Research | COMPLETE | 2026-02-09 | 2026-02-09 | 2 plans (4 commits): backend (4 tools, SSE endpoint, chat service) + frontend (SSE hook, markdown, citations, tool activity, stop/clear) |
2727
| 10 | Source Panel & Entity Resolution | COMPLETE | 2026-02-09 | 2026-02-09 | 3 plans (9 commits), 9/9 verified: shared citation utils + hooks, KG + Geospatial source wiring + entity resolution, Verdict + Timeline citation navigation |
2828
| 11 | Corrections & Refinement | NOT_STARTED | - | - | |
2929
| 12 | Demo Preparation | NOT_STARTED | - | - | |
@@ -35,6 +35,11 @@
3535
## Current Context
3636

3737
**What was just completed:**
38+
- **Phase 9 COMPLETE** (2026-02-09): Chat Interface -- 2 plans, 4 commits
39+
- Plan 01 (Backend): 4 closure-based tool factories, chat_service.py, SSE POST endpoint with 5 event types, system prompt with full synthesis context
40+
- Plan 02 (Frontend): @microsoft/fetch-event-source SSE hook, markdown rendering (react-markdown + remark-gfm), inline citation chips opening SourceViewerModal, tool activity expandable section, stop/clear buttons, disabled state, error bubbles with retry
41+
- Full user flow: type message -> SSE stream tokens -> markdown + citations -> click citation -> SourceViewerModal
42+
3843
- **Phase 10 COMPLETE** (2026-02-09): Source Panel & Entity Resolution -- 3 plans, 9 commits, 9/9 verified
3944
- Plan 01: Shared foundation (citation-utils, useSourceNavigation, useEntityResolver, CitationLink, EntityBadge)
4045
- Plan 02: KG entity panel source docs clickable, EntityTimelineEntry "View source evidence", Geospatial entity resolution + citation-to-source
@@ -187,11 +192,14 @@
187192
- Full user flow: Generate button → 3-second polling → location extraction + geocoding → map display → click marker → detailed evidence context
188193
- Known limitations: Paths not rendered (v1), no SSE streaming (polling-based), entity names not resolved (UUIDs only)
189194

195+
**Phase 9 COMPLETE** (2026-02-09): Chat Interface & Research -- 2 plans, 6 commits, 20/20 verified
196+
- Plan 01: Backend -- 4 closure-based tool factories (query_knowledge_graph, get_findings with detail/list modes, get_synthesis, search_findings), build_chat_system_prompt with full context injection, chat_service (load_chat_context + create_chat_agent_and_runner with ADK session_service), SSE POST endpoint with 5 event types, router registered
197+
- Plan 02: Frontend -- @microsoft/fetch-event-source SSE streaming, useChatbot hook rewrite with AbortController + session persistence, ReactMarkdown + remark-gfm rendering, [[file_id|locator|label]] citation chips with SourceViewerModal, tool activity expandable section, stop/clear buttons, disabled state, error bubbles with retry
198+
- Full flow: User types message → POST SSE → Flash agent queries DB tools → tokens stream → citations parsed → markdown rendered → SourceViewerModal on click
199+
190200
**What's next:**
191201
- Phase 11 (Corrections & Refinement) -- polish, bug fixes, integration testing
192202
- Phase 12 (Demo Preparation) -- demo scenarios, sample data, walkthrough
193-
- Phase 9 (Chat Interface) -- backend API + tool integration still needed
194-
- Chat message citations deferred to Phase 9+ (backend does not yet produce structured citations)
195203

196204
---
197205

@@ -309,15 +317,20 @@
309317

310318
---
311319

312-
### REQ-CHAT-001: Chat Interface — FRONTEND_DONE
320+
### REQ-CHAT-001: Chat Interface — COMPLETE
313321

314322
| Component | File Path |
315323
|-----------|-----------|
316324
| Chatbot UI | `frontend/src/components/app/chatbot.tsx` |
317325
| Chat hook | `frontend/src/hooks/useChatbot.ts` |
318326
| Types | `frontend/src/types/chatbot.ts` |
327+
| **Backend: Chat tools** | `backend/app/agents/chat_tools.py` |
328+
| **Backend: Chat prompt** | `backend/app/agents/prompts/chat.py` |
329+
| **Backend: Chat service** | `backend/app/services/chat_service.py` |
330+
| **Backend: Chat API** | `backend/app/api/chat.py` |
319331

320-
**Backend API Needed:** `POST /api/chat`
332+
**Backend API:** `POST /api/cases/:caseId/chat` (SSE streaming) -- DONE
333+
**Frontend wiring:** useChatbot.ts SSE streaming, chatbot.tsx markdown + citations + tool activity -- DONE
321334

322335
---
323336

@@ -356,7 +369,7 @@ All frontend features need these backend endpoints:
356369
| File Ingestion | `/api/cases/:caseId/files` | GET, POST, DELETE | HIGH | DONE |
357370
| File Download | `/api/cases/:caseId/files/:fileId/download` | GET | HIGH | DONE |
358371
| File SSE | `/sse/cases/:caseId/files` | SSE | HIGH | DONE |
359-
| Chat | `/api/chat` | POST | HIGH | TODO |
372+
| Chat | `/api/cases/:caseId/chat` | POST (SSE) | HIGH | DONE |
360373
| Knowledge Graph | `/api/cases/:caseId/graph` | GET | HIGH | DONE |
361374
| KG Entities | `/api/cases/:caseId/entities` | GET, POST, PATCH, DELETE | MEDIUM | DONE |
362375
| KG Relationships | `/api/cases/:caseId/relationships` | GET, POST | MEDIUM | DONE |
@@ -604,6 +617,11 @@ All frontend features need these backend endpoints:
604617
| Verdict source navigation wiring | Direct hook in panels vs Callback threading | Callback threading via sidebar descriptors | Detail panels render inside DetailSidebar without caseId access; callback threaded from page through VerdictView -> descriptor props |
605618
| Timeline citation source | event.sourceIds vs event.metadata.citations | event.metadata.citations | sourceIds contains entity UUIDs (misnamed); metadata.citations has actual file refs (file_id, locator, excerpt) |
606619
| Timeline citation UX | Modal with all citations vs Expandable list | Expandable list in card | Progressive disclosure; click count to expand, click individual citation to open SourceViewerModal |
620+
| Chat SSE library | Native EventSource vs fetchEventSource | @microsoft/fetch-event-source | EventSource only supports GET; chat endpoint is POST with body; fetchEventSource supports POST + headers + AbortController |
621+
| Chat auth token | api-client.ts wrapper vs getToken direct | getToken from auth-client.ts | fetchEventSource needs explicit headers; getToken provides raw JWT without api-client wrapper |
622+
| Chat session persistence | Frontend session tracking vs Server-side ADK | Server-side ADK with session_id ref | ADK manages conversation history; frontend only stores session_id to reconnect |
623+
| Citation regex mutation | Module-level global regex vs Local creation | Local new RegExp() inside useMemo | React Compiler immutability rule prevents lastIndex mutation on module-level regex |
624+
| Chat disabled derivation | caseStatus only vs latest_workflow_id + status | latest_workflow_id !== null && status !== PROCESSING | Chat requires completed analysis; in-progress analysis data is incomplete |
607625

608626
---
609627

@@ -623,7 +641,7 @@ None currently.
623641
## Session Continuity
624642

625643
Last session: 2026-02-09
626-
Stopped at: Phase 10 COMPLETE (3/3 plans, 9 commits, 9/9 verified). Source panel & entity resolution across all views.
644+
Stopped at: Phase 9 COMPLETE (2/2 plans, 4 commits). Chat backend + frontend fully wired.
627645
Resume file: None
628646
Next action: Phase 11 (Corrections & Refinement)
629647

0 commit comments

Comments
 (0)