diff options
| author | Adam Malczewski <[email protected]> | 2026-06-02 14:43:16 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-02 14:43:16 +0900 |
| commit | 3ebcd49c404ed287a97af159ac8adfa63d572849 (patch) | |
| tree | f8245ed28530a8e96046221eb1d7eca47d508dc8 /packages/api | |
| parent | 7c527b4d8a72159954405e720d5bf776802dc0ff (diff) | |
| download | dispatch-3ebcd49c404ed287a97af159ac8adfa63d572849.tar.gz dispatch-3ebcd49c404ed287a97af159ac8adfa63d572849.zip | |
feat(tabs): drag-reorder + double-click rename + per-tab chat draft
- TabBar: HTML5 drag-and-drop to reorder user tabs (subagent tabs untouched);
double-click a tab title to rename (Enter/blur confirm, Escape cancel).
- Store: add reorderTabs/renameTab/setDraft; per-tab in-memory `draft` and
`manualTitle` fields. Manual rename suppresses first-message auto-title.
- ChatInput: bind to the active tab's draft so switching tabs saves/restores
unsent text instead of clobbering it.
- Backend: updateTabPositions() + PATCH /tabs/reorder persist tab order to the
existing `position` column; tabs without a stored position fall to the end
then get explicit positions on first reorder.
- Tests: store reorder/rename/auto-title-guard/draft coverage; core
updateTabPositions coverage (FakeDatabase extended with transaction support).
Diffstat (limited to 'packages/api')
| -rw-r--r-- | packages/api/src/routes/tabs.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/api/src/routes/tabs.ts b/packages/api/src/routes/tabs.ts index f52ee99..28a89f1 100644 --- a/packages/api/src/routes/tabs.ts +++ b/packages/api/src/routes/tabs.ts @@ -11,6 +11,7 @@ import { listOpenTabs, setSetting, updateTabModel, + updateTabPositions, updateTabStatus, updateTabTitle, } from "@dispatch/core"; @@ -63,6 +64,18 @@ tabsRoutes.put("/settings/title-model", async (c) => { return c.json({ success: true }); }); +// Reorder open tabs. Body `{ ids }` is the new left-to-right order of tab ids; +// each tab's `position` is rewritten to its index. Must be declared before the +// `/:id` routes so "reorder" isn't captured as an id param. +tabsRoutes.patch("/reorder", async (c) => { + const body = await c.req.json<{ ids?: string[] }>(); + if (!Array.isArray(body.ids) || body.ids.some((id) => typeof id !== "string")) { + return c.json({ error: "ids must be an array of strings" }, 400); + } + updateTabPositions(body.ids); + return c.json({ success: true }); +}); + tabsRoutes.get("/:id", (c) => { const id = c.req.param("id"); const tab = getTab(id); |
