|
| 1 | +--- |
| 2 | +phase: 08-port-library-notes-ide-features-to-project-notes-sidebar-width-pinned-notes-tabs-wikilinks-graph-view-ai-copilot-with-experiment-results |
| 3 | +plan: 01 |
| 4 | +subsystem: ai, api, ui |
| 5 | +tags: [fastapi, react, openai, copilot, experiment-context, notes] |
| 6 | + |
| 7 | +# Dependency graph |
| 8 | +requires: |
| 9 | + - phase: 03-experiment-tree |
| 10 | + provides: experiments table + note service experiment_id support |
| 11 | + - phase: 08-port-library-notes-ide-features |
| 12 | + provides: NotesCopilotPanel + NoteGraphView shared components |
| 13 | +provides: |
| 14 | + - POST /api/projects/{id}/notes-copilot endpoint with experiment context building |
| 15 | + - project_id column on chat_messages (migration 020) |
| 16 | + - NoteGraphView: customSourceColors, customSourceLabels, storagePrefix props |
| 17 | + - NotesCopilotPanel: sendFn, scopeId, experiments props + experiments in @ mention dropdown |
| 18 | + - projectNotesCopilotApi exported from api.js |
| 19 | +affects: [08-02-project-notes-ide] |
| 20 | + |
| 21 | +# Tech tracking |
| 22 | +tech-stack: |
| 23 | + added: [] |
| 24 | + patterns: |
| 25 | + - "sendFn/scopeId prop injection to NotesCopilotPanel for project-scoped sends without forking component" |
| 26 | + - "storagePrefix prop on NoteGraphView to prevent localStorage key collisions between library/project graphs" |
| 27 | + - "Experiment context block: config KVs + metrics KVs + children summaries serialized into system message" |
| 28 | + - "ITEM_STYLE lookup table extended with experiment type (indigo/science icon)" |
| 29 | + - "EXPERIMENT_STATUS_COLOR map for colored status dots in @ mention dropdown" |
| 30 | + |
| 31 | +key-files: |
| 32 | + created: |
| 33 | + - backend/migrations/020_project_notes_copilot.sql |
| 34 | + - backend/services/project_notes_copilot_service.py |
| 35 | + - backend/routers/project_notes_copilot.py |
| 36 | + modified: |
| 37 | + - backend/models/chat.py |
| 38 | + - backend/app.py |
| 39 | + - frontend/src/components/NoteGraphView.jsx |
| 40 | + - frontend/src/components/NotesCopilotPanel.jsx |
| 41 | + - frontend/src/services/api.js |
| 42 | + |
| 43 | +key-decisions: |
| 44 | + - "project_notes_copilot_service.py copies architecture from notes_copilot_service.py but scopes to project_id — avoids overloading one service with branching logic" |
| 45 | + - "suggest_note_create target_type enum extended to include 'project' and 'experiment' so AI can propose notes under either entity" |
| 46 | + - "storagePrefix prop on NoteGraphView replaces hardcoded 'researchos.graph.' prefix — project graph settings stored at 'researchos.project.graph.' to avoid collision" |
| 47 | + - "experiments prop passed to NotesCopilotPanel with children pre-filtered client-side — avoids extra server round-trip at mention selection time" |
| 48 | + - "Show type checkboxes in NoteGraphView now iterate Object.keys(mergedColors) instead of hardcoded list — allows custom types added via customSourceColors to appear" |
| 49 | + |
| 50 | +patterns-established: |
| 51 | + - "Backend copilot pattern: service handles persistence+LLM, router is a thin wrapper — same as library notes copilot" |
| 52 | + - "Context item metadata pattern: arbitrary dict field allows experiment config/metrics/children without schema changes" |
| 53 | + |
| 54 | +requirements-completed: [IDE-05, IDE-04] |
| 55 | + |
| 56 | +# Metrics |
| 57 | +duration: 20min |
| 58 | +completed: 2026-03-18 |
| 59 | +--- |
| 60 | + |
| 61 | +# Phase 08 Plan 01: Project Notes Copilot Backend + Component Prop Extensions Summary |
| 62 | + |
| 63 | +**Project-scoped AI copilot backend (POST /api/projects/{id}/notes-copilot) with experiment context building + NoteGraphView/NotesCopilotPanel prop extensions for reuse in ProjectNotesIDE** |
| 64 | + |
| 65 | +## Performance |
| 66 | + |
| 67 | +- **Duration:** ~20 min |
| 68 | +- **Started:** 2026-03-18T16:00:00Z |
| 69 | +- **Completed:** 2026-03-18T16:20:00Z |
| 70 | +- **Tasks:** 2 |
| 71 | +- **Files modified:** 8 |
| 72 | + |
| 73 | +## Accomplishments |
| 74 | +- Created full backend copilot stack: migration adding project_id to chat_messages, service with experiment context building (_build_context_block handles status/config/metrics/children for experiment items), and router with GET/POST/DELETE endpoints under /api/projects/{id}/notes-copilot |
| 75 | +- Extended NoteGraphView with customSourceColors, customSourceLabels, and storagePrefix props; all SOURCE_COLOR/SOURCE_LABEL references replaced with merged counterparts; Show checkboxes now dynamic over merged keys |
| 76 | +- Extended NotesCopilotPanel with sendFn/scopeId override and experiments prop; @ mention dropdown shows experiments with status dot + metrics preview; projectNotesCopilotApi exported from api.js |
| 77 | + |
| 78 | +## Task Commits |
| 79 | + |
| 80 | +Each task was committed atomically: |
| 81 | + |
| 82 | +1. **Task 1: Backend migration, service, router for project notes copilot** - `4338bbd` (feat) |
| 83 | +2. **Task 2: Extend NoteGraphView, NotesCopilotPanel props + frontend API client** - `61de0a7` (feat) |
| 84 | + |
| 85 | +## Files Created/Modified |
| 86 | +- `backend/migrations/020_project_notes_copilot.sql` - Adds project_id column + index to chat_messages |
| 87 | +- `backend/models/chat.py` - Added project_id to ChatMessage; extended NotesCopilotContextItem docstring; added ProjectNotesCopilotMessageCreate model |
| 88 | +- `backend/services/project_notes_copilot_service.py` - Project-scoped copilot service with experiment context block building |
| 89 | +- `backend/routers/project_notes_copilot.py` - GET/POST/DELETE /api/projects/{id}/notes-copilot router |
| 90 | +- `backend/app.py` - Wire project_notes_copilot router |
| 91 | +- `frontend/src/components/NoteGraphView.jsx` - Added customSourceColors, customSourceLabels, storagePrefix props; replaced hardcoded SOURCE_COLOR/SOURCE_LABEL with merged versions |
| 92 | +- `frontend/src/components/NotesCopilotPanel.jsx` - Added sendFn, scopeId, experiments props; experiment @ mention with status dot + metrics preview; ITEM_STYLE + EXPERIMENT_STATUS_COLOR extended |
| 93 | +- `frontend/src/services/api.js` - Added projectNotesCopilotApi export |
| 94 | + |
| 95 | +## Decisions Made |
| 96 | +- project_notes_copilot_service.py is a separate service (not merged with notes_copilot_service.py) to avoid branching complexity — same architecture, different scope key |
| 97 | +- suggest_note_create target_type enum includes 'project' and 'experiment' so the AI can propose notes at either scope |
| 98 | +- storagePrefix prop replaces hardcoded 'researchos.graph.' so library and project graph views don't share localStorage keys |
| 99 | +- Children for experiment context items are pre-filtered client-side by parentId at @ mention selection time — no extra round-trip |
| 100 | + |
| 101 | +## Deviations from Plan |
| 102 | + |
| 103 | +None - plan executed exactly as written. |
| 104 | + |
| 105 | +## Issues Encountered |
| 106 | +None. |
| 107 | + |
| 108 | +## User Setup Required |
| 109 | +Run `backend/migrations/020_project_notes_copilot.sql` in the Supabase SQL editor to add the project_id column to chat_messages before using the project notes copilot. |
| 110 | + |
| 111 | +## Next Phase Readiness |
| 112 | +- Plan 02 (ProjectNotesIDE) can now import NoteGraphView with storagePrefix='researchos.project.graph.' and NotesCopilotPanel with sendFn=projectNotesCopilotApi.send + experiments prop without modifying shared components |
| 113 | +- projectNotesCopilotApi is ready for wiring in ProjectNotesIDE |
| 114 | + |
| 115 | +--- |
| 116 | +*Phase: 08-port-library-notes-ide-features-to-project-notes* |
| 117 | +*Completed: 2026-03-18* |
0 commit comments