refactor all memory phrase#239
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Phrase Memory to move away from preset-based splitting toward a workspace-scoped LLM “memory extractor” (provider/model/prompt), adds confidence metadata to saved matches, and updates pipeline/search configuration to explicit search controls.
Changes:
- Replace Phrase Memory presets/splitters with a workspace “memory extractor” (plus new
memoryprompt-template context). - Add
confidenceto phrase-memory DB entries/matches and propagate it through TS + Rust layers. - Simplify pipeline phrase-memory config to
autoSearchPhraseMemory,phraseMemorySimilarityThreshold, andphraseMemoryMaxResults, plus manual refresh from the Memory tab.
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/memoryPreLaunchCheck.test.ts | Update test fixtures to include confidence on matches. |
| src/types.ts | Introduce PromptTemplateContext; refactor pipeline + workspace + match types; add confidence. |
| src/stores/workspaceStore.ts | Allow updating workspace memory-extractor fields. |
| src/stores/promptTemplateStore.ts | Use PromptTemplateContext type for template saving. |
| src/stores/projectStore.test.ts | Update workspace mock with extractor fields. |
| src/stores/pipelineStore.ts | Set new default phrase-memory config fields. |
| src/stores/phraseMemoryStore.ts | Add confidence to in-memory match model + mapping. |
| src/stores/tests/phraseMemoryStore.test.ts | Update match fixtures for confidence. |
| src/services/workspaceService.ts | Persist/load workspace extractor fields (DB columns + defaults). |
| src/services/workspaceService.test.ts | Update delete expectations (presets table removed). |
| src/services/promptTemplateService.ts | Accept/parse memory template context. |
| src/services/pipelineService.ts | Persist/load new phrase-memory search settings (no presets/overrides). |
| src/services/pipelineService.test.ts | Update expectations for new phrase-memory config fields. |
| src/services/phraseMemoryService.ts | Replace splitter/embedding job with LLM extractor + confidence; convert similarity→distance threshold for vector search. |
| src/services/phraseMemoryPresetService.ts | Remove preset service (deleted). |
| src/services/phraseMemoryPresetService.test.ts | Remove preset tests (deleted). |
| src/services/phraseMemoryInjection.test.ts | Update match fixtures to include confidence. |
| src/services/llmService.ts | Type refinePrompt context via PromptTemplateContext. |
| src/services/dbService.ts | Bump schema; add pipeline/workspace/phrase_memory columns; remove preset seeding; backfill extractor defaults. |
| src/services/dbService.test.ts | Update schema-version expectations; adjust migration assertions. |
| src/services/backupService.ts | Remove presets table from backup; include new workspace/pipeline/phrase_memory columns. |
| src/services/tests/phraseMemoryService.test.ts | Update phrase-memory service tests for extractor flow + confidence. |
| src/i18n/it.json | Update workspace/memory/template strings; add refresh label; remove preset copy. |
| src/i18n/en.json | Update workspace/memory/template strings; add refresh label; remove preset copy. |
| src/hooks/useSaveToMemory.ts | Use workspace extractor settings when saving phrase pairs. |
| src/hooks/useSaveToMemory.test.ts | Update hook test to assert extractor params. |
| src/hooks/usePipeline.test.ts | Update phrase-match fixtures to include confidence. |
| src/hooks/usePhraseMemoryMatches.test.ts | Update match fixtures to include confidence. |
| src/hooks/usePhraseMemoryAutoSearch.ts | Add pipeline-controlled auto-search; add per-chunk manual search function. |
| src/hooks/usePhraseMemoryAutoSearch.test.ts | Add coverage for auto-search off + manual refresh path; update fixtures. |
| src/constants.ts | Add defaults for extractor provider/model/prompt. |
| src/components/workspace/WorkspaceSettingsModal.tsx | Add Memory tab UI for extractor settings; persist extractor fields with workspace updates. |
| src/components/workspace/MemoryExtractorSettings.tsx | New component for extractor provider/model/prompt + template integration + refine/reset actions. |
| src/components/settings/PresetForm.tsx | Remove preset form UI (deleted). |
| src/components/settings/PresetForm.test.tsx | Remove preset form tests (deleted). |
| src/components/settings/PhraseMemoryPresetManager.tsx | Remove preset manager UI (deleted). |
| src/components/settings/PhraseMemoryPresetManager.test.tsx | Remove preset manager tests (deleted). |
| src/components/settings/index.ts | Stop exporting removed preset components. |
| src/components/pipeline/SettingsTabPanel.tsx | Wire new phrase-memory config props (no presets/overrides). |
| src/components/pipeline/PipelineConfig.tsx | Persist updated phrase-memory config fields in pipeline config UI. |
| src/components/pipeline/PhraseMemoryConfig.tsx | Replace preset/override UI with auto-search + threshold + max-results controls. |
| src/components/pipeline/PhraseMemoryConfig.test.tsx | Update tests for new phrase-memory config UI behavior. |
| src/components/library/PromptTemplatesTab.tsx | Add memory template context and filtering UI. |
| src/components/document/MemoryTab.tsx | Add manual refresh; update actions/labels; switch apply → copy translation behavior. |
| src-tauri/src/vector/embedding.rs | Add confidence to phrase_memory schema, search results, and save payload. |
| src-tauri/src/llm/pipeline.rs | Add extract_phrase_memory_pairs Tauri command (LLM JSON mode extractor). |
| src-tauri/src/lib.rs | Register new extractor command; remove old splitter/upsert commands. |
| docs/ARCHITECTURE.md | Update architecture docs for extractor-based Phrase Memory + new schema fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 does this PR do?
Type of change
Checklist
npm run lintpassescargo checkpasses (if Rust changes)