refactor(data): migrate QuickPhrase to Prompt with version management#13430
Open
zhangjiadi225 wants to merge 3 commits intoCherryHQ:v2from
Open
refactor(data): migrate QuickPhrase to Prompt with version management#13430zhangjiadi225 wants to merge 3 commits intoCherryHQ:v2from
zhangjiadi225 wants to merge 3 commits intoCherryHQ:v2from
Conversation
- Replace QuickPhrase with Prompt entity backed by SQLite via Drizzle ORM - Add prompt and prompt_version tables with automatic versioning - Implement PromptService with CRUD, version history, and rollback - Add API handlers and schemas for /prompts endpoints - Create PromptMigrator for Dexie quick_phrases → SQLite migration - Refactor QuickPhrasesButton with version sub-menu selection - Replace QuickPhraseSettings with PromptSettings page - Remove unused template variables system and templateEngine utility - Update routing from /settings/quickphrase to /settings/prompts Signed-off-by: zhangjiadi225 <625013594@qq.com>
Collaborator
|
Note This comment was translated by Claude. Add unit tests for the key migrator Original Content关键的migrator加一下单元测试 |
- Test prepare phase: table existence, valid/invalid filtering, empty table, error handling - Test execute phase: insertion, title defaults, progress reporting, transaction errors - Test validate phase: count matching, mismatch detection, db failure handling, skip tracking Signed-off-by: zhangjiadi225 <625013594@qq.com>
Collaborator
|
Nice work on the migration and version management! A few things before detailed review: Question: Variable designThe old QuickPhrase had a Have you considered the variable substitution story? How should Want to make sure the data model accounts for this before we merge. Initial code observations
|
Author
|
[!NOTE]
This comment was translated by Claude.
Thanks for the detailed reply!
**Variable substitution**: Agreed — variable management should be designed as an independent global module, not tied to Prompts. The current `` syntax is just a simple design for this stage. Going forward, the variable system should serve as shared infrastructure across the entire application — Prompts, Agent system prompts, MCP configs, and other areas could all reference the same global variables with type constraints and usage history.
**Code fixes**: Great catches. Will fix all three issues and push shortly.
— Di Ge
…---
<details>
<summary>Original Content</summary>
Thanks for the detailed reply!
**Variable substitution**: Agreed — variable management should be designed as
an independent global module, not tied to Prompts. The current `` syntax
is just a simple design for this stage. Going forward, the variable system
should serve as shared infrastructure across the entire application — Prompts,
Agent system prompts, MCP configs, and other areas could all reference the
same global variables with type constraints and usage history.
**Code fixes**: Great catches. Will fix all three issues and push shortly.
...迪哥
***@***.***
</details>
|
…aints - Wrap create/update/rollback/reorder in db.transaction() - Move reads inside transactions to prevent race conditions - Add notNull constraints to currentVersion and sortOrder - Change prompt_version composite index to uniqueIndex - Remove redundant null fallbacks in rowToPrompt Signed-off-by: zhangjiadi225 <625013594@qq.com>
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 this PR does
Before this PR:
After this PR:
${var}syntax in contentWhy we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Breaking changes
Data migration from Dexie
quick_phrasesto SQLiteprompttable runs automatically via PromptMigrator.Checklist
Release note