fix: surface memory logs in the chunk console#240
Open
nikazzio wants to merge 5 commits into
Open
Conversation
…ntion help - Replace per-model token breakdown with per-operation scope breakdown (Translation/Refine/Format stages + Audit/Coherence), each showing its model and cache hit rate — removes invoke double-counting - Move similarity threshold slider from pipeline config to MemoryTab header, below the match buttons, so users can adjust and re-search without leaving the chunk panel - Separate phrase count row from save button with a divider — two distinct functions now visually distinct - Add cache retention section to help: explains gpt-5.4 extended (24h) vs mini/nano in-memory (5-10 min) TTL and why Refine shows 0% cache Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the structured operation log system to better surface Phrase Memory activity in the UI console and adds richer usage summaries (global + per-chunk) based on operation logs, including a new Chunk “Summary” tab and a dedicated “Memory” scope.
Changes:
- Add
memoryas a first-class operation-log scope and emit detailed logs for phrase-memory extract/search/save flows. - Introduce operation-log–based usage summarization (global + per-chunk) and new UI surfaces (Chunk Summary tab, scope breakdown cards).
- UI/UX adjustments: memory tab controls (threshold slider, rerun confirm), tooltip behavior for disabled icon buttons, and export dialog portaling.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/pipelineLogging.ts | Adds stageName into stage-end log metadata to support later summarization. |
| src/utils/operationLogStats.ts | Adds global/chunk usage summary builders and supporting types/helpers. |
| src/utils/operationLogStats.test.ts | Adds tests covering new global/chunk summary behavior. |
| src/stores/uiStore.ts | Adds new chunk drawer tab (summary) and changes default chunk tab. |
| src/stores/operationLogStore.ts | Adds memory to OperationLogScope. |
| src/services/phraseMemoryService.ts | Adds operation logging across memory extraction/search/save flows. |
| src/hooks/useSaveToMemory.ts | Adds chunk-scoped reasons when “Save to memory” skips chunks / completes/fails. |
| src/hooks/usePhraseMemoryAutoSearch.ts | Merges exact (chunk-id) memory matches with vector matches; adds logging. |
| src/hooks/usePhraseMemoryAutoSearch.test.ts | Updates tests for exact-match merge behavior. |
| src/components/ui/IconButton.tsx | Wraps button to allow tooltips to work even when disabled. |
| src/components/pipeline/SettingsTabPanel.tsx | Removes threshold config wiring from settings panel. |
| src/components/pipeline/PipelineConfig.tsx | Removes threshold prop plumbing to settings panel. |
| src/components/pipeline/PhraseMemoryConfig.tsx | Removes threshold slider UI from config panel. |
| src/components/pipeline/PhraseMemoryConfig.test.tsx | Updates tests to match removed threshold UI. |
| src/components/help/HelpGuide.tsx | Adds cache retention help section. |
| src/components/document/OperationsTab.tsx | Adds Memory scope icon/filter/group labeling. |
| src/components/document/MemoryTab.tsx | Adds threshold slider, memory count display, rerun confirm, UI refresh behavior. |
| src/components/document/InsightsDrawer.tsx | Adds Chunk Summary tab and replaces stats computation with log-based summaries. |
| src/components/document/ExportDialog.tsx | Switches to createPortal and raises z-index for overlay. |
| src/i18n/en.json | Adds strings for summary tab, chunk summary, memory UX, and Memory scope. |
| src/i18n/it.json | Adds strings for summary tab, chunk summary, memory UX, and Memory scope. |
| src-tauri/src/vector/embedding.rs | Adds “replace existing chunk memory” delete step before insert. |
| src-tauri/.gitignore | Ignores *.glossa-backup. |
| .gitignore | Ignores *.glossa-backup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+748
to
752
| {usageSummary.scopeBreakdown.length > 0 && ( | ||
| <div className="mt-3 space-y-1"> | ||
| {Array.from(modelNames).map((name) => ( | ||
| <div key={name} className="text-[10px] text-editorial-muted/70 font-mono truncate">{name}</div> | ||
| {usageSummary.scopeBreakdown.map((entry) => ( | ||
| <ScopeBreakdownCard key={entry.scope} entry={entry} /> | ||
| ))} |
Comment on lines
88
to
95
| if (savedCount === 0) { | ||
| if (previousCount && previousCount > 0) { | ||
| toast.message(t('memory.nothingToSave')); | ||
| return; | ||
| } | ||
| toast.message(t('memory.nothingToSave')); | ||
| return; | ||
| } |
Comment on lines
787
to
790
| "insightsTabAudit": "Audit", | ||
| "insightsTabSummary": "Riepilogo", | ||
| "insightsTabStats": "Riepilogo", | ||
| "insightsTabCoherence": "Coerenza", |
Comment on lines
+814
to
+818
| if (!currentChunk || !chunkSummary) { | ||
| return ( | ||
| <div id={panelId} role="tabpanel" aria-labelledby={labelledBy} className="px-6 py-8 text-sm text-editorial-muted"> | ||
| {t('document.insightsAuditEmpty')} | ||
| </div> |
Comment on lines
+446
to
+450
| let replaced_rows = conn | ||
| .execute( | ||
| "DELETE FROM phrase_memory WHERE chunk_id = ?1 AND project_id = ?2", | ||
| rusqlite::params![&chunk_id, &project_id], | ||
| ) |
| }); | ||
|
|
||
| const texts = chunks.map((c) => c.text); | ||
| const embeddings = await fetchEmbeddings(texts, embeddingModel); |
Comment on lines
318
to
324
| const raw = await invoke<RawPhraseMatch[]>('vec_search_phrase_memory', { | ||
| workspaceId, | ||
| queryEmbedding: embedding, | ||
| threshold: similarityToDistanceThreshold(threshold), | ||
| maxResults, | ||
| }); | ||
| result.set(chunks[i].id, raw.map(toPhraseMatch)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Verification