diff options
| author | Adam Malczewski <[email protected]> | 2026-06-03 15:29:45 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-03 15:30:38 +0900 |
| commit | 5af9bd021c206b9e4330ab6a549dc8d013d91537 (patch) | |
| tree | 667dca977d6eb78e09006c5553523230daa2b73f /packages/core/src/db | |
| parent | bcc449a5cba183c7358ab48ed4f2140bb1a3238c (diff) | |
| parent | bc3ecbe7b72f6da6ed36d0cea5a66de1c440269a (diff) | |
| download | dispatch-5af9bd021c206b9e4330ab6a549dc8d013d91537.tar.gz dispatch-5af9bd021c206b9e4330ab6a549dc8d013d91537.zip | |
Merge branch 'dev' into warm/prompt-cache-warming
# Conflicts:
# packages/api/src/agent-manager.ts
# packages/api/tests/agent-manager.test.ts
# packages/frontend/src/lib/tabs.svelte.ts
Diffstat (limited to 'packages/core/src/db')
| -rw-r--r-- | packages/core/src/db/chunks.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/core/src/db/chunks.ts b/packages/core/src/db/chunks.ts index e0aadf3..b434a47 100644 --- a/packages/core/src/db/chunks.ts +++ b/packages/core/src/db/chunks.ts @@ -225,3 +225,22 @@ export function clearChunksForTab(tabId: string): void { const db = getDatabase(); db.query("DELETE FROM chunks WHERE tab_id = $tabId").run({ $tabId: tabId }); } + +/** + * Relocate every chunk row from one tab to another (compaction backup path). + * + * Used by conversation compaction to move the FULL pre-compaction history off + * the canonical tab id (`fromTabId`) onto a freshly-created backup tab id + * (`toTabId`), leaving the canonical id free to be re-seeded with the summary + + * preserved tail. `seq` values are preserved (they remain per-tab monotonic for + * the destination since it starts empty), as are turn ids, so the relocated + * history groups identically under its new tab. Returns the number of rows + * moved. + */ +export function rekeyChunks(fromTabId: string, toTabId: string): number { + const db = getDatabase(); + const result = db + .query("UPDATE chunks SET tab_id = $to WHERE tab_id = $from") + .run({ $from: fromTabId, $to: toTabId }); + return Number(result.changes ?? 0); +} |
