document-level notes

This commit is contained in:
2026-03-20 11:11:30 +10:00
parent ce2917505b
commit be8b47f8fb
9 changed files with 312 additions and 44 deletions

View File

@@ -44,6 +44,7 @@ interface EditorState {
clearArchivedAnnotations: () => void
removeArchivedAnnotation: (id: string) => void
setAnnotationAnalysis: (id: string, result: { text: string; suggestion: string | null }) => void
addDocumentNote: (note: string) => void
// Analysis mode
analysisMode: AnalysisMode
@@ -529,6 +530,36 @@ export const useEditorStore = create<EditorState>((set, get) => ({
})
},
addDocumentNote: (note) => {
const ann: import('../types/editor').TextAnnotation = {
id: `doc-note-${Date.now()}`,
type: 'document_note',
message: note,
comment: note,
}
set((s) => {
const annotations = [...s.annotations, ann]
const existingAll = s.activeFilePath
? (s.annotationsByFile[s.activeFilePath]?.annotations ?? [])
: []
const merged = [...existingAll, ann]
const annotationsByFile = s.activeFilePath
? { ...s.annotationsByFile, [s.activeFilePath]: { mode: s.analysisMode, annotations: merged } }
: s.annotationsByFile
return { annotations, annotationsByFile }
})
scheduleSave(() => {
const st = get()
return {
activeFilePath: st.activeFilePath,
scrollPositions: st.scrollPositions,
chatSessionsByFile: st.chatSessionsByFile,
activeSessionIdByFile: st.activeSessionIdByFile,
annotationsByFile: st.annotationsByFile
}
})
},
analysisMode: 'none',
setAnalysisMode: (analysisMode) => {
set((s) => {