diff options
| author | Adam Malczewski <[email protected]> | 2026-05-22 15:24:13 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-22 15:24:13 +0900 |
| commit | 9ecaabd87c0e51b8a7408dabb0133a9344586859 (patch) | |
| tree | 4b5809ab23948a5e3f558f3aa34c52d5038f4e19 /packages/core/src/db | |
| parent | 8f1dd855f0c4c877bff8d3a4ba193432b268b1c2 (diff) | |
| download | dispatch-9ecaabd87c0e51b8a7408dabb0133a9344586859.tar.gz dispatch-9ecaabd87c0e51b8a7408dabb0133a9344586859.zip | |
feat: agent builder, CWD support, auto-save, UI polish, unavailable tool handling
- Agent Builder: full CRUD with card grid, drag-and-drop model reorder, edit/delete
- Auto-save on edit with 600ms debounce, AbortController for concurrency, fieldset disabled until name entered
- Agent definitions stored as TOML with cwd field, loaded from global/project dirs
- Working directory: per-tab CWD override in Chat Settings, agent default CWD, auto-create on first message
- CWD validation: check-dir endpoint with ~ expansion, real-time validity indicator
- Subagent CWD validated against parent's effective CWD using path.relative
- Unavailable tool calls: caught gracefully, shown as tool call with error badge, model retries
- UI: tab bar border radius, sidebar border removed, chat input ghost style, scroll-to-bottom rectangle
- Skills dir collapse uses CSS rotation, Model Choice renamed to Chat Settings, System Prompt view removed
- Reusable SkillsBrowser/ToolPermissions with external mode for Agent Builder
- ModelSelector: Agent/Manual toggle, agent list, Agent Settings link
- Page router, skills recursive scanning, bin/up gopass removed, docker volume mounts
Diffstat (limited to 'packages/core/src/db')
| -rw-r--r-- | packages/core/src/db/messages.ts | 26 | ||||
| -rw-r--r-- | packages/core/src/db/settings.ts | 4 |
2 files changed, 25 insertions, 5 deletions
diff --git a/packages/core/src/db/messages.ts b/packages/core/src/db/messages.ts index 5a8758f..80a1f22 100644 --- a/packages/core/src/db/messages.ts +++ b/packages/core/src/db/messages.ts @@ -10,14 +10,30 @@ export interface MessageRow { createdAt: number; } -export function appendMessage(tabId: string, id: string, role: string, contentJson: string, thinking?: string): void { +export function appendMessage( + tabId: string, + id: string, + role: string, + contentJson: string, + thinking?: string, +): void { const db = getDatabase(); - const maxSeq = db.query("SELECT COALESCE(MAX(seq), -1) as max_seq FROM messages WHERE tab_id = $tabId").get({ $tabId: tabId }) as { max_seq: number }; + const maxSeq = db + .query("SELECT COALESCE(MAX(seq), -1) as max_seq FROM messages WHERE tab_id = $tabId") + .get({ $tabId: tabId }) as { max_seq: number }; const seq = (maxSeq?.max_seq ?? -1) + 1; db.query( `INSERT INTO messages (id, tab_id, seq, role, content_json, thinking, created_at) VALUES ($id, $tabId, $seq, $role, $contentJson, $thinking, $now)`, - ).run({ $id: id, $tabId: tabId, $seq: seq, $role: role, $contentJson: contentJson, $thinking: thinking ?? null, $now: Date.now() }); + ).run({ + $id: id, + $tabId: tabId, + $seq: seq, + $role: role, + $contentJson: contentJson, + $thinking: thinking ?? null, + $now: Date.now(), + }); } export function updateMessage(id: string, contentJson: string, thinking?: string): void { @@ -29,7 +45,9 @@ export function updateMessage(id: string, contentJson: string, thinking?: string export function getMessagesForTab(tabId: string): MessageRow[] { const db = getDatabase(); - const rows = db.query("SELECT * FROM messages WHERE tab_id = $tabId ORDER BY seq ASC").all({ $tabId: tabId }) as Array<Record<string, unknown>>; + const rows = db + .query("SELECT * FROM messages WHERE tab_id = $tabId ORDER BY seq ASC") + .all({ $tabId: tabId }) as Array<Record<string, unknown>>; return rows.map((row) => ({ id: row.id as string, tabId: row.tab_id as string, diff --git a/packages/core/src/db/settings.ts b/packages/core/src/db/settings.ts index 51d6ea2..f9d152e 100644 --- a/packages/core/src/db/settings.ts +++ b/packages/core/src/db/settings.ts @@ -2,7 +2,9 @@ import { getDatabase } from "./index.js"; export function getSetting(key: string): string | null { const db = getDatabase(); - const row = db.query("SELECT value FROM settings WHERE key = $key").get({ $key: key }) as { value: string } | null; + const row = db.query("SELECT value FROM settings WHERE key = $key").get({ $key: key }) as { + value: string; + } | null; return row?.value ?? null; } |
