diff options
| author | Adam Malczewski <[email protected]> | 2026-06-02 14:50:30 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-02 14:50:30 +0900 |
| commit | d022877e3a4c954adafce3894f70c176dee76433 (patch) | |
| tree | 4dc5e033c88ee123c82adc964e50cc788f16d7ed /packages/core/src | |
| parent | 58b985b9c82c7c1acb98ac8799b8409d5c403642 (diff) | |
| parent | 2e71dbfbfb883c8fa31f40969fdb249043a37ec0 (diff) | |
| download | dispatch-d022877e3a4c954adafce3894f70c176dee76433.tar.gz dispatch-d022877e3a4c954adafce3894f70c176dee76433.zip | |
Merge branch 'dev' into cr/claude-reset-fix
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/db/tabs.ts | 14 | ||||
| -rw-r--r-- | packages/core/src/index.ts | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/packages/core/src/db/tabs.ts b/packages/core/src/db/tabs.ts index 8b290d2..f719a01 100644 --- a/packages/core/src/db/tabs.ts +++ b/packages/core/src/db/tabs.ts @@ -115,6 +115,20 @@ export function updateTabStatus(id: string, status: string): void { }); } +export function updateTabPositions(idsInOrder: string[]): void { + const db = getDatabase(); + const now = Date.now(); + const update = db.query("UPDATE tabs SET position = $position, updated_at = $now WHERE id = $id"); + // One transaction so a reorder is atomic: either every tab lands at its new + // slot or none does, never a half-applied ordering. + const applyAll = db.transaction(() => { + idsInOrder.forEach((id, index) => { + update.run({ $id: id, $position: index, $now: now }); + }); + }); + applyAll(); +} + export function archiveTab(id: string): void { const db = getDatabase(); db.query("UPDATE tabs SET is_open = 0, updated_at = $now WHERE id = $id").run({ diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 7818024..f67ad53 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -56,6 +56,7 @@ export { shortestUniquePrefix, type TabRow, updateTabModel, + updateTabPositions, updateTabStatus, updateTabTitle, } from "./db/tabs.js"; |
