@kabmo-labs/kabmo 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +319 -319
- package/dist/client/static/js/index-bnrrw242.css +1 -0
- package/dist/client/static/js/{index-vzb1qz51.js → index-w6jx0h0p.js} +780 -780
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
- package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
- package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
- package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
- package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
- package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
- package/package.json +2 -2
- package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
- package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
- package/src/client/components/common/code-surface/extensions.ts +7 -1
- package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
- package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
- package/src/client/components/common/session-row/index.tsx +215 -0
- package/src/client/components/common/session-row/session-row.test.tsx +154 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
- package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
- package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
- package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +193 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
- package/src/client/components/mobile/SessionSidebar.tsx +137 -146
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
- package/src/client/components/settings/Modal.tsx +5 -27
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +102 -0
- package/src/client/components/settings/apply-side-effects.ts +90 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
- package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
- package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
- package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +15 -5
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
- package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +117 -75
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
- package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
- package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
- package/src/client/components/workspace/diff-panel/folding.ts +6 -1
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
- package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
- package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
- package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
- package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
- package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
- package/src/client/data/settings/omp-schema.json +151 -6
- package/src/client/hooks/chat/composer/style.ts +66 -0
- package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
- package/src/client/hooks/chat/timeline/row-window.ts +59 -133
- package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
- package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
- package/src/client/hooks/settings/providers/login.ts +11 -2
- package/src/client/hooks/ui/window-event.ts +20 -4
- package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
- package/src/client/hooks/workspace/batch-archive.ts +78 -0
- package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
- package/src/client/hooks/workspace/sidebar-style.ts +66 -0
- package/src/client/tailwind.css +111 -0
- package/src/server/index.ts +10 -134
- package/src/server/lib/lifecycle/after-listen.ts +178 -0
- package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
- package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
- package/src/server/lib/lifecycle/tls.test.ts +7 -7
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
- package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
- package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
- package/src/server/lib/plugins/background.server.ts +17 -1
- package/src/server/lib/plugins/background.test.ts +33 -0
- package/src/server/routes/sessions/batch-archive.test.ts +113 -0
- package/src/server/routes/sessions/batch-archive.ts +80 -0
- package/src/server/routes/sessions/index.ts +4 -0
- package/src/shared/lib/chat/composer/style.test.ts +126 -0
- package/src/shared/lib/chat/composer/style.ts +171 -0
- package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
- package/src/shared/lib/chat/composer/tui-only.ts +5 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
- package/src/shared/lib/chat/timeline/trace-groups.test.ts +132 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +95 -0
- package/src/shared/lib/settings/defaults.ts +6 -0
- package/src/shared/lib/workspace/session-focus.test.ts +93 -0
- package/src/shared/lib/workspace/session-focus.ts +71 -0
- package/src/shared/lib/workspace/session-state/store.ts +5 -0
- package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
- package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
- package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
- package/src/shared/lib/workspace/sidebar-style.ts +86 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/settings/state.ts +31 -0
- package/dist/client/static/js/index-68w8h33q.css +0 -1
- package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The batch archive route's contract.
|
|
8
|
+
*
|
|
9
|
+
* These are request-shape and verdict checks: a malformed body must be refused
|
|
10
|
+
* before anything is written, a valid id must actually land in
|
|
11
|
+
* `archived_sessions`, and the two "not a real session" cases (a pending
|
|
12
|
+
* `new-…` chat and a traversal id) must be per-id refusals while the rest of
|
|
13
|
+
* the batch still runs.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { batchArchiveSessions } from '@/server/routes/sessions/batch-archive';
|
|
18
|
+
import { getDb } from '@/server/db.server';
|
|
19
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
20
|
+
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
// This suite reaches the database: `batchArchiveSessions` resolves `getDb()`.
|
|
23
|
+
await isolateDb();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterAll(async () => {
|
|
27
|
+
await releaseDb();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function post(body: unknown, url = 'http://localhost/api/sessions/batch-archive'): Promise<Response> {
|
|
31
|
+
return batchArchiveSessions({
|
|
32
|
+
request: new Request(url, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: { 'content-type': 'application/json' },
|
|
35
|
+
body: JSON.stringify(body),
|
|
36
|
+
}),
|
|
37
|
+
params: {},
|
|
38
|
+
} as never) as Promise<Response>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function isArchived(id: string): Promise<boolean> {
|
|
42
|
+
const db = await getDb();
|
|
43
|
+
return Boolean(await db.get('SELECT session_id FROM archived_sessions WHERE session_id = ?', [id]));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('batchArchiveSessions request shape', () => {
|
|
47
|
+
test('a wrong verb is a 405', async () => {
|
|
48
|
+
const res = (await batchArchiveSessions({
|
|
49
|
+
request: new Request('http://localhost/api/sessions/batch-archive', { method: 'DELETE' }),
|
|
50
|
+
params: {},
|
|
51
|
+
} as never)) as Response;
|
|
52
|
+
expect(res.status).toBe(405);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('a non-array ids field is a 400', async () => {
|
|
56
|
+
const res = await post({ ids: 'a' });
|
|
57
|
+
expect(res.status).toBe(400);
|
|
58
|
+
expect(await res.json()).toMatchObject({ error: 'ids must be an array of session ids' });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('an empty selection is a 400 rather than a no-op success', async () => {
|
|
62
|
+
const res = await post({ ids: [] });
|
|
63
|
+
expect(res.status).toBe(400);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('an over-long selection is refused', async () => {
|
|
67
|
+
const ids = Array.from({ length: 501 }, (_, index) => `s-${index}`);
|
|
68
|
+
const res = await post({ ids });
|
|
69
|
+
expect(res.status).toBe(400);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('batchArchiveSessions verdicts', () => {
|
|
74
|
+
test('a valid id is archived and the row exists', async () => {
|
|
75
|
+
const res = await post({ ids: ['session-a'] });
|
|
76
|
+
expect(res.status).toBe(200);
|
|
77
|
+
const body = await res.json() as { success: boolean; archived: string[]; refused: unknown[] };
|
|
78
|
+
expect(body.success).toBe(true);
|
|
79
|
+
expect(body.archived).toEqual(['session-a']);
|
|
80
|
+
expect(body.refused).toEqual([]);
|
|
81
|
+
expect(await isArchived('session-a')).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('archiving is idempotent — the same id twice is one row', async () => {
|
|
85
|
+
await post({ ids: ['session-b', 'session-b'] });
|
|
86
|
+
const db = await getDb();
|
|
87
|
+
const rows = await db.all('SELECT session_id FROM archived_sessions WHERE session_id = ?', ['session-b']);
|
|
88
|
+
expect(rows).toHaveLength(1);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a pending chat is refused per id while the rest still archives', async () => {
|
|
92
|
+
const res = await post({ ids: ['new-1758800000000', 'session-c'] });
|
|
93
|
+
expect(res.status).toBe(200);
|
|
94
|
+
const body = await res.json() as {
|
|
95
|
+
success: boolean;
|
|
96
|
+
archived: string[];
|
|
97
|
+
refused: { id: string; code?: string }[];
|
|
98
|
+
};
|
|
99
|
+
expect(body.success).toBe(false);
|
|
100
|
+
expect(body.archived).toEqual(['session-c']);
|
|
101
|
+
expect(body.refused.map((entry) => entry.id)).toEqual(['new-1758800000000']);
|
|
102
|
+
expect(body.refused[0].code).toBe('session_pending');
|
|
103
|
+
expect(await isArchived('new-1758800000000')).toBe(false);
|
|
104
|
+
expect(await isArchived('session-c')).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('a traversal id is refused without touching the tree', async () => {
|
|
108
|
+
const res = await post({ ids: ['..'] });
|
|
109
|
+
const body = await res.json() as { archived: string[]; refused: { code?: string }[] };
|
|
110
|
+
expect(body.archived).toEqual([]);
|
|
111
|
+
expect(body.refused[0].code).toBe('invalid_id');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* POST /api/sessions/batch-archive — archive several sessions in one request.
|
|
8
|
+
*
|
|
9
|
+
* The sidebar's session batch mode is one user action over N rows, so it is one
|
|
10
|
+
* request: a client loop would pay N round trips and republish the sidebar N
|
|
11
|
+
* times for a single click.
|
|
12
|
+
*
|
|
13
|
+
* Archiving is the reversible sibling of delete — the row moves between the
|
|
14
|
+
* sidebar's archive view and its normal list, and the transcript is untouched
|
|
15
|
+
* (see `archiveSession`). It therefore needs no busy-child check and no
|
|
16
|
+
* destructive confirmation; the only refusals are the two "this id names
|
|
17
|
+
* something other than a real session" cases the single verbs already share:
|
|
18
|
+
* a pending `new-…` chat (there is no transcript to archive yet) and an id that
|
|
19
|
+
* is not one path segment.
|
|
20
|
+
*
|
|
21
|
+
* A refusal is a verdict, never an abort: a batch holding one pending chat
|
|
22
|
+
* still archives the rest, and the caller is told which ids survived and why.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { json } from '@/server/lib/remix-compat';
|
|
26
|
+
import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
27
|
+
import { methodNotAllowed, parseJsonBody } from '@/server/lib/route-adapter';
|
|
28
|
+
import { getDb } from '@/server/db.server';
|
|
29
|
+
import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
|
|
30
|
+
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
31
|
+
|
|
32
|
+
/** One request cannot carry an unbounded selection. */
|
|
33
|
+
const MAX_BATCH = 500;
|
|
34
|
+
|
|
35
|
+
export async function batchArchiveSessions({ request }: ActionFunctionArgs) {
|
|
36
|
+
if (request.method !== 'POST') {
|
|
37
|
+
return methodNotAllowed({ request, params: {} });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const parsed = await parseJsonBody<{ ids?: unknown }>(request);
|
|
41
|
+
if (!parsed.ok) return json({ error: 'Invalid JSON body' }, { status: 400 });
|
|
42
|
+
|
|
43
|
+
const raw = parsed.body.ids;
|
|
44
|
+
if (!Array.isArray(raw) || raw.some((id) => typeof id !== 'string' || id.length === 0)) {
|
|
45
|
+
return json({ error: 'ids must be an array of session ids' }, { status: 400 });
|
|
46
|
+
}
|
|
47
|
+
const ids = [...new Set(raw as string[])];
|
|
48
|
+
if (ids.length === 0) return json({ error: 'No sessions selected' }, { status: 400 });
|
|
49
|
+
if (ids.length > MAX_BATCH) {
|
|
50
|
+
return json({ error: `At most ${MAX_BATCH} sessions can be archived at once.` }, { status: 400 });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const db = await getDb();
|
|
54
|
+
const archived: string[] = [];
|
|
55
|
+
const refused: { id: string; error: string; code?: string }[] = [];
|
|
56
|
+
|
|
57
|
+
for (const id of ids) {
|
|
58
|
+
// The same two "names something other than the session it appears to"
|
|
59
|
+
// refusals the single verbs use: a pending chat has no transcript, and an
|
|
60
|
+
// id that is not one path segment cannot name a session.
|
|
61
|
+
if (id.startsWith('new-')) {
|
|
62
|
+
refused.push({ id, error: 'This chat has not been created yet.', code: 'session_pending' });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (!isSinglePathSegment(id)) {
|
|
66
|
+
refused.push({ id, error: 'Invalid session id', code: 'invalid_id' });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Idempotent: `session_id` is the primary key, so a session already
|
|
70
|
+
// archived stays archived and the row is not duplicated.
|
|
71
|
+
await db.run('INSERT OR IGNORE INTO archived_sessions (session_id) VALUES (?)', [id]);
|
|
72
|
+
archived.push(id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Archiving moves sessions between the sidebar's archive view and its normal
|
|
76
|
+
// list, so the structure changed — one republish covers the whole batch.
|
|
77
|
+
if (archived.length > 0) emitRealtimeSignal('sidebar-structure');
|
|
78
|
+
|
|
79
|
+
return json({ success: refused.length === 0, archived, refused });
|
|
80
|
+
}
|
|
@@ -15,6 +15,7 @@ import { listSubagents, readSubagentTranscript } from '@/server/routes/sessions/
|
|
|
15
15
|
import { cancelSubagent, steerSubagent } from '@/server/routes/sessions/subagent-control';
|
|
16
16
|
import { deleteSession } from '@/server/routes/sessions/delete';
|
|
17
17
|
import { batchDeleteSessions } from '@/server/routes/sessions/batch-delete';
|
|
18
|
+
import { batchArchiveSessions } from '@/server/routes/sessions/batch-archive';
|
|
18
19
|
|
|
19
20
|
export const sessionsBindings: HandlerBinding[] = [
|
|
20
21
|
...bindingsFor(sessionsList, '/api/sessions/list'),
|
|
@@ -22,6 +23,9 @@ export const sessionsBindings: HandlerBinding[] = [
|
|
|
22
23
|
// batch route is POST while `:sessionId` answers DELETE, so an id route
|
|
23
24
|
// winning the match would turn every batch into a 405.
|
|
24
25
|
{ method: 'POST', path: '/api/sessions/batch-delete', handler: batchDeleteSessions },
|
|
26
|
+
// The archive batch is static too, and must be registered before the
|
|
27
|
+
// `:sessionId` routes for the same reason as batch-delete.
|
|
28
|
+
{ method: 'POST', path: '/api/sessions/batch-archive', handler: batchArchiveSessions },
|
|
25
29
|
...bindingsFor(sessionsFolder, '/api/sessions/:sessionId'),
|
|
26
30
|
// DELETE-only on the same path the folder loader answers GET on: mounting it
|
|
27
31
|
// through `actionBindings` would register a 405 GET fallback that Elysia
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import {
|
|
8
|
+
COMPOSER_STYLES,
|
|
9
|
+
COMPOSER_STYLE_COPY,
|
|
10
|
+
DEFAULT_COMPOSER_STYLE,
|
|
11
|
+
composerStyleLayout,
|
|
12
|
+
isComposerStyle,
|
|
13
|
+
resolveComposerStyle,
|
|
14
|
+
type ComposerRow,
|
|
15
|
+
} from '@/shared/lib/chat/composer/style';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Every row the composer renders. The list is EXHAUSTIVE BY CONTRACT: a style
|
|
19
|
+
* that omits one is a style that drops a control the user cannot get back —
|
|
20
|
+
* the worst case being the access-mode selector, which decides whether a turn
|
|
21
|
+
* may write to disk.
|
|
22
|
+
*/
|
|
23
|
+
const EVERY_ROW: readonly ComposerRow[] = ['attachments', 'notice', 'draft', 'voice', 'toolbar'];
|
|
24
|
+
|
|
25
|
+
describe('composer style table', () => {
|
|
26
|
+
test('every style renders every row exactly once', () => {
|
|
27
|
+
for (const style of COMPOSER_STYLES) {
|
|
28
|
+
for (const hero of [false, true]) {
|
|
29
|
+
const { rows } = composerStyleLayout({ style, hero });
|
|
30
|
+
expect(new Set(rows)).toEqual(new Set(EVERY_ROW));
|
|
31
|
+
expect(rows.length).toBe(EVERY_ROW.length);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('every style has copy in the settings control', () => {
|
|
37
|
+
for (const style of COMPOSER_STYLES) {
|
|
38
|
+
expect(COMPOSER_STYLE_COPY[style].label.length).toBeGreaterThan(0);
|
|
39
|
+
expect(COMPOSER_STYLE_COPY[style].description.length).toBeGreaterThan(20);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('the wireframe lists only rows the renderer draws', () => {
|
|
44
|
+
for (const style of COMPOSER_STYLES) {
|
|
45
|
+
const { wire } = composerStyleLayout({ style, hero: false });
|
|
46
|
+
expect(wire.length).toBeGreaterThan(0);
|
|
47
|
+
for (const row of wire) expect(['chip', 'draft', 'controls']).toContain(row);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('the draft is above the toolbar in every style', () => {
|
|
52
|
+
// The one ordering invariant that is not cosmetic: the box a user types
|
|
53
|
+
// into must not sit under the row of controls it belongs to.
|
|
54
|
+
for (const style of COMPOSER_STYLES) {
|
|
55
|
+
const { rows } = composerStyleLayout({ style, hero: false });
|
|
56
|
+
expect(rows.indexOf('draft')).toBeLessThan(rows.indexOf('toolbar'));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('the notice stays attached to the draft it refuses', () => {
|
|
61
|
+
// A refusal rendered above the attachment row would read as a complaint
|
|
62
|
+
// about the file rather than about the send.
|
|
63
|
+
for (const style of COMPOSER_STYLES) {
|
|
64
|
+
const { rows } = composerStyleLayout({ style, hero: false });
|
|
65
|
+
expect(Math.abs(rows.indexOf('notice') - rows.indexOf('draft'))).toBe(1);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('only the console style draws a mono rail and a prompt glyph', () => {
|
|
70
|
+
for (const style of COMPOSER_STYLES) {
|
|
71
|
+
const layout = composerStyleLayout({ style, hero: false });
|
|
72
|
+
const console = style === 'console';
|
|
73
|
+
expect(layout.toolbarTone).toBe(console ? 'rail' : 'plain');
|
|
74
|
+
expect(layout.promptGlyph).toBe(console);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('stage alone reacts to an empty chat, and only through the hero attribute', () => {
|
|
79
|
+
const docked = composerStyleLayout({ style: 'stage', hero: false });
|
|
80
|
+
const hero = composerStyleLayout({ style: 'stage', hero: true });
|
|
81
|
+
// Same rows: the hero state may never add or drop a control.
|
|
82
|
+
expect(hero.rows).toEqual(docked.rows);
|
|
83
|
+
// The pixel difference is CSS's, keyed by this attribute — see the
|
|
84
|
+
// `[data-composer-hero]` rules in `tailwind.css`.
|
|
85
|
+
expect(hero.hero).toBe(true);
|
|
86
|
+
expect(docked.hero).toBe(false);
|
|
87
|
+
|
|
88
|
+
for (const style of COMPOSER_STYLES.filter((s) => s !== 'stage')) {
|
|
89
|
+
expect(composerStyleLayout({ style, hero: true }).hero).toBe(false);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('glass keeps the classic row order — it changes the surface, not the order', () => {
|
|
94
|
+
expect(composerStyleLayout({ style: 'glass', hero: false }).rows).toEqual(
|
|
95
|
+
composerStyleLayout({ style: 'classic', hero: false }).rows,
|
|
96
|
+
);
|
|
97
|
+
expect(composerStyleLayout({ style: 'glass', hero: false }).toolbarTone).toBe('plain');
|
|
98
|
+
expect(composerStyleLayout({ style: 'glass', hero: false }).promptGlyph).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('calm and console move the draft above the attachment chips', () => {
|
|
102
|
+
for (const style of ['calm', 'console'] as const) {
|
|
103
|
+
const { rows } = composerStyleLayout({ style, hero: false });
|
|
104
|
+
expect(rows.indexOf('draft')).toBeLessThan(rows.indexOf('attachments'));
|
|
105
|
+
}
|
|
106
|
+
expect(composerStyleLayout({ style: 'classic', hero: false }).rows.indexOf('attachments')).toBe(0);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('composer style resolution', () => {
|
|
111
|
+
test('the shipped default is classic, so an upgrade rearranges nothing', () => {
|
|
112
|
+
expect(DEFAULT_COMPOSER_STYLE).toBe('classic');
|
|
113
|
+
expect(resolveComposerStyle(undefined)).toBe('classic');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('a stored style this build draws is returned unchanged', () => {
|
|
117
|
+
for (const style of COMPOSER_STYLES) expect(resolveComposerStyle(style)).toBe(style);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('a value from another build falls back rather than rendering nothing', () => {
|
|
121
|
+
expect(resolveComposerStyle('neon')).toBe('classic');
|
|
122
|
+
expect(resolveComposerStyle(null)).toBe('classic');
|
|
123
|
+
expect(resolveComposerStyle(7)).toBe('classic');
|
|
124
|
+
expect(isComposerStyle('neon')).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the chat composer LOOKS like, as one of four styles.
|
|
8
|
+
*
|
|
9
|
+
* This is a PRESENTATION choice over one composer, not four composers: every
|
|
10
|
+
* style renders the same controls — the paperclip, the attachment chips, the
|
|
11
|
+
* compact "Type here" target, the stretch control, plan/goal, the notice
|
|
12
|
+
* strip, the draft with its `@`/`/` picker, the dictation notice, the model,
|
|
13
|
+
* thinking and access selectors, plugin actions, voice, stop and send. What
|
|
14
|
+
* changes is the ORDER of the rows and the frame around them.
|
|
15
|
+
*
|
|
16
|
+
* That constraint is the module's reason to exist. A style that could omit a
|
|
17
|
+
* control would be a style that can silently drop the access mode — the one
|
|
18
|
+
* setting that decides whether a turn may write to disk. So the table below
|
|
19
|
+
* names ROWS, never controls: there is no field here that can remove one.
|
|
20
|
+
*
|
|
21
|
+
* - `classic` — chrome above the draft, controls below it. The shipped card.
|
|
22
|
+
* - `calm` — the draft leads; chips and controls sit under it in one
|
|
23
|
+
* quieter rail.
|
|
24
|
+
* - `console` — a mono status rail under the box, with an `omp ›` prompt
|
|
25
|
+
* glyph. The workbench reading of the same controls.
|
|
26
|
+
* - `stage` — `classic` inside a chat, a wider hero card while the session
|
|
27
|
+
* is still empty (see `hero`).
|
|
28
|
+
*
|
|
29
|
+
* Copy lives here with the names; the pixels live with the components that
|
|
30
|
+
* draw them (`chat-input/expansion.ts`, `chat-input/index.tsx`), so neither
|
|
31
|
+
* file restates the other's fact.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export type ComposerStyle = 'classic' | 'calm' | 'console' | 'stage' | 'glass';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Every style, in the order the settings control lists them: the cards that
|
|
38
|
+
* keep today's reading order first, then the two that move it, then the one
|
|
39
|
+
* that changes the SURFACE rather than the order.
|
|
40
|
+
*/
|
|
41
|
+
export const COMPOSER_STYLES = ['classic', 'calm', 'console', 'stage', 'glass'] as const;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The style a document with no stored preference renders at. It is the shape
|
|
45
|
+
* Kabmo has always drawn, so an upgrade rearranges nothing.
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_COMPOSER_STYLE: ComposerStyle = 'classic';
|
|
48
|
+
|
|
49
|
+
export function isComposerStyle(value: unknown): value is ComposerStyle {
|
|
50
|
+
return value === 'classic' || value === 'calm' || value === 'console' || value === 'stage' || value === 'glass';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The style to APPLY for a stored value. Anything this build cannot draw — a
|
|
55
|
+
* value from a newer build, a corrupted blob, `undefined` on a fresh install —
|
|
56
|
+
* falls back to the default rather than to a style no component knows.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveComposerStyle(value: unknown): ComposerStyle {
|
|
59
|
+
return isComposerStyle(value) ? value : DEFAULT_COMPOSER_STYLE;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ComposerStyleCopy {
|
|
63
|
+
label: string;
|
|
64
|
+
/** One line under the label: the TRADEOFF, not the aesthetic. */
|
|
65
|
+
description: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const COMPOSER_STYLE_COPY: Record<ComposerStyle, ComposerStyleCopy> = {
|
|
69
|
+
classic: {
|
|
70
|
+
label: 'Classic',
|
|
71
|
+
description: 'Chrome above the draft, controls below it. Every control visible at once — the densest and the most predictable.',
|
|
72
|
+
},
|
|
73
|
+
calm: {
|
|
74
|
+
label: 'Calm',
|
|
75
|
+
description: 'The draft leads, chips and controls sit under it in one quieter rail. Same controls, less chrome above the typing line.',
|
|
76
|
+
},
|
|
77
|
+
console: {
|
|
78
|
+
label: 'Console',
|
|
79
|
+
description: 'A monospace status rail under the box, with an omp prompt glyph. Reads like the rest of the telemetry UI.',
|
|
80
|
+
},
|
|
81
|
+
stage: {
|
|
82
|
+
label: 'Stage',
|
|
83
|
+
description: 'Classic once a chat is running; a wider, taller card while the session is still empty.',
|
|
84
|
+
},
|
|
85
|
+
glass: {
|
|
86
|
+
label: 'Glass',
|
|
87
|
+
description: 'A translucent capsule: the card is frosted paper over whatever sits behind it, with the draft and controls on one surface. Same controls, softer edge.',
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A row of the composer card, in render order. Rows own the pieces that must
|
|
93
|
+
* stay next to each other (the notice belongs to the draft it refuses), and
|
|
94
|
+
* every one of them is always drawn.
|
|
95
|
+
*/
|
|
96
|
+
export type ComposerRow =
|
|
97
|
+
| 'attachments'
|
|
98
|
+
| 'notice'
|
|
99
|
+
| 'draft'
|
|
100
|
+
| 'voice'
|
|
101
|
+
| 'toolbar';
|
|
102
|
+
|
|
103
|
+
/** One bar of the settings card's miniature wireframe. */
|
|
104
|
+
export type ComposerWireRow = 'chip' | 'draft' | 'controls';
|
|
105
|
+
|
|
106
|
+
export interface ComposerStyleLayout {
|
|
107
|
+
/** Rows in render order. Every row is rendered; none is optional. */
|
|
108
|
+
rows: readonly ComposerRow[];
|
|
109
|
+
/** Wireframe for the settings card — the same order, drawn small. */
|
|
110
|
+
wire: readonly ComposerWireRow[];
|
|
111
|
+
/**
|
|
112
|
+
* `rail` renders the control row as a monospace status line. The CONTROLS
|
|
113
|
+
* are the same; only the typography and the separators change.
|
|
114
|
+
*/
|
|
115
|
+
toolbarTone: 'plain' | 'rail';
|
|
116
|
+
/** Draw the `omp ›` prompt glyph at the card's leading edge. */
|
|
117
|
+
promptGlyph: boolean;
|
|
118
|
+
/** Read by CSS only, through `[data-composer-style]`. */
|
|
119
|
+
attributeValue: ComposerStyle;
|
|
120
|
+
/** Read by CSS only, through `[data-composer-hero]`. */
|
|
121
|
+
hero: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface ComposerStyleInput {
|
|
125
|
+
style: ComposerStyle;
|
|
126
|
+
/** Whether the session is still empty; only `stage` reads it. */
|
|
127
|
+
hero: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The layout for a style.
|
|
132
|
+
*
|
|
133
|
+
* A pure table: same inputs, same shape, no DOM and no settings read — which is
|
|
134
|
+
* what makes it testable and what lets the renderer stay a loop over `rows`.
|
|
135
|
+
*
|
|
136
|
+
* **It states ORDER and STRUCTURE only, never a Tailwind size.** A style table
|
|
137
|
+
* that wrote `rounded-md` or `min-h-[132px]` would be a table that loses to the
|
|
138
|
+
* expansion frame's own `rounded-xl` / `min-h-[68px]`: Tailwind resolves two
|
|
139
|
+
* utilities of the same property by the order the rules were EMITTED in, not by
|
|
140
|
+
* the order the classes appear in `className`. Measured on the console style,
|
|
141
|
+
* `rounded-xl rounded-md` rendered 12px. The pixels therefore live in CSS,
|
|
142
|
+
* keyed by the attributes below — the same split `data-chat-width` already uses
|
|
143
|
+
* for the chat column.
|
|
144
|
+
*/
|
|
145
|
+
export function composerStyleLayout({ style, hero }: ComposerStyleInput): ComposerStyleLayout {
|
|
146
|
+
const base = { attributeValue: style, hero: style === 'stage' && hero };
|
|
147
|
+
|
|
148
|
+
switch (style) {
|
|
149
|
+
case 'calm':
|
|
150
|
+
return { ...base, rows: ['draft', 'notice', 'attachments', 'voice', 'toolbar'], wire: ['draft', 'chip', 'controls'], toolbarTone: 'plain', promptGlyph: false };
|
|
151
|
+
|
|
152
|
+
case 'console':
|
|
153
|
+
return { ...base, rows: ['notice', 'draft', 'attachments', 'voice', 'toolbar'], wire: ['draft', 'chip', 'controls'], toolbarTone: 'rail', promptGlyph: true };
|
|
154
|
+
|
|
155
|
+
// The hero card is the only difference, and only while empty: a taller
|
|
156
|
+
// draft so the first prompt is not written into a 68px slot in the middle
|
|
157
|
+
// of a blank screen. Everything else is `classic`.
|
|
158
|
+
case 'stage':
|
|
159
|
+
return { ...base, rows: ['attachments', 'notice', 'draft', 'voice', 'toolbar'], wire: ['chip', 'draft', 'controls'], toolbarTone: 'plain', promptGlyph: false };
|
|
160
|
+
|
|
161
|
+
// `glass` is a SURFACE, not an order: it keeps `classic`'s rows and changes
|
|
162
|
+
// only the frame (translucency, blur, a sheen). Stated here rather than
|
|
163
|
+
// implied by the default arm so the intent survives the next style.
|
|
164
|
+
case 'glass':
|
|
165
|
+
return { ...base, rows: ['attachments', 'notice', 'draft', 'voice', 'toolbar'], wire: ['chip', 'draft', 'controls'], toolbarTone: 'plain', promptGlyph: false };
|
|
166
|
+
|
|
167
|
+
case 'classic':
|
|
168
|
+
default:
|
|
169
|
+
return { ...base, rows: ['attachments', 'notice', 'draft', 'voice', 'toolbar'], wire: ['chip', 'draft', 'controls'], toolbarTone: 'plain', promptGlyph: false };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -45,6 +45,9 @@ describe('isTuiOnlySlashCommand', () => {
|
|
|
45
45
|
expect(isTuiOnlySlashCommand('/q')).toBe(true);
|
|
46
46
|
expect(isTuiOnlySlashCommand('/status')).toBe(true);
|
|
47
47
|
expect(isTuiOnlySlashCommand('/rewind')).toBe(true);
|
|
48
|
+
// `hub` and its 18.14.0 alias `subagents` are the same TUI-only entry.
|
|
49
|
+
expect(isTuiOnlySlashCommand('/hub')).toBe(true);
|
|
50
|
+
expect(isTuiOnlySlashCommand('/subagents')).toBe(true);
|
|
48
51
|
});
|
|
49
52
|
|
|
50
53
|
test('lets every command omp answers over RPC through', () => {
|
|
@@ -77,6 +77,11 @@ export const TUI_ONLY_SLASH_COMMANDS: Record<string, true> = {
|
|
|
77
77
|
agents: true,
|
|
78
78
|
git: true,
|
|
79
79
|
hub: true,
|
|
80
|
+
// omp 18.14.0 added `subagents` as an ALIAS of the TUI-only `hub`. The guard
|
|
81
|
+
// is keyed on names, so without this row the alias reached the model as
|
|
82
|
+
// literal text — measured on 18.14.0: `/subagents` is absent from
|
|
83
|
+
// `available_commands_update` and `handleTui` is its only handler.
|
|
84
|
+
subagents: true,
|
|
80
85
|
branch: true,
|
|
81
86
|
rewind: true,
|
|
82
87
|
fork: true,
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The frame a transcript BLOCK wears, per render style.
|
|
8
|
+
*
|
|
9
|
+
* A tool call is not the only block in the timeline: thinking, a system
|
|
10
|
+
* notice, a task result and a goal injection are the same shape — a header that
|
|
11
|
+
* states the thing, a body that opens on demand. Before this module each of
|
|
12
|
+
* them spelled the card's frame out itself, so `toolRenderStyle` reached the
|
|
13
|
+
* tool rows and left every neighbour in the old card: a compact transcript sat
|
|
14
|
+
* between thinking and notices drawn as cards, which is a setting that half
|
|
15
|
+
* applies.
|
|
16
|
+
*
|
|
17
|
+
* Pure class strings, no DOM and no Preact — the same split `gutter.ts` uses,
|
|
18
|
+
* and for the same reason: the styles are asserted without mounting anything.
|
|
19
|
+
*
|
|
20
|
+
* - `card` — the bordered, rounded block Kabmo has always shipped.
|
|
21
|
+
* - `compact` — a bare header row; the body hangs off a dashed rail.
|
|
22
|
+
* - `trace` — a header row with a node, on the transcript's rail.
|
|
23
|
+
* - `minimal` — the quietest: small type, no frame, a dashed body.
|
|
24
|
+
*
|
|
25
|
+
* The CURSOR and HOVER classes are deliberately NOT here: whether a block can
|
|
26
|
+
* be toggled is a per-block fact (`canToggle`), not a property of the style.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import type { ToolRenderMode } from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
30
|
+
|
|
31
|
+
export interface BlockChrome {
|
|
32
|
+
/** Outer wrapper. Empty for the frameless styles. */
|
|
33
|
+
root: string;
|
|
34
|
+
/** The framed surface; empty when the style has no frame. */
|
|
35
|
+
frame: string;
|
|
36
|
+
/** The header row (a `<button>` when the block can be toggled). */
|
|
37
|
+
header: string;
|
|
38
|
+
/** The leading glyph. */
|
|
39
|
+
icon: string;
|
|
40
|
+
/** The block's name. */
|
|
41
|
+
title: string;
|
|
42
|
+
/** The one line under the title while collapsed. */
|
|
43
|
+
subtitle: string;
|
|
44
|
+
/** The body container. */
|
|
45
|
+
body: string;
|
|
46
|
+
/** `trace` only: the node this block places on its own rail. */
|
|
47
|
+
node?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const CARD: BlockChrome = {
|
|
51
|
+
root: '',
|
|
52
|
+
frame: 'overflow-hidden rounded-xl border border-ink/10 bg-paper transition-colors hover:border-ink/20',
|
|
53
|
+
header: 'flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors',
|
|
54
|
+
icon: 'flex h-7 w-7 shrink-0 items-center justify-center rounded-lg',
|
|
55
|
+
title: 'text-[12px] font-semibold tracking-tight text-ink',
|
|
56
|
+
subtitle: 'truncate font-mono text-[10.5px] text-ink/45',
|
|
57
|
+
body: 'border-t border-ink/8 bg-canvas/40 px-3 py-3',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const COMPACT: BlockChrome = {
|
|
61
|
+
root: '',
|
|
62
|
+
frame: '',
|
|
63
|
+
header: 'flex w-full items-center gap-2 px-1.5 py-1 text-left transition-colors',
|
|
64
|
+
icon: 'flex shrink-0 items-center justify-center',
|
|
65
|
+
title: 'shrink-0 text-[12px] font-semibold tracking-tight text-ink',
|
|
66
|
+
subtitle: 'truncate font-mono text-[10.5px] text-ink/45',
|
|
67
|
+
body: 'ml-5 mt-0.5 overflow-hidden border-l border-dashed border-ink/15 py-2 pl-3',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const TRACE: BlockChrome = {
|
|
71
|
+
root: 'relative pl-4',
|
|
72
|
+
frame: '',
|
|
73
|
+
header: 'flex w-full items-center gap-2 px-1.5 py-1 text-left transition-colors',
|
|
74
|
+
icon: 'flex shrink-0 items-center justify-center',
|
|
75
|
+
title: 'shrink-0 text-[12px] font-semibold tracking-tight text-ink',
|
|
76
|
+
subtitle: 'truncate font-mono text-[10.5px] text-ink/45',
|
|
77
|
+
body: 'mb-1 ml-[3.5px] overflow-hidden border-l border-ink/10 py-2 pl-3',
|
|
78
|
+
// Placed at the root's left edge with no translate: the rail is a 1px line at
|
|
79
|
+
// `left-[3.5px]`, so an 8px node at `left-0` has its centre on that line
|
|
80
|
+
// (measured: node 315 / rail 315). A `-translate-x-[3.5px]` here put the node
|
|
81
|
+
// 3.5px left of its own rail — the exact drift the tool row avoids.
|
|
82
|
+
node: 'absolute left-0 top-[9px] flex h-2 w-2 items-center justify-center rounded-full bg-ink/20',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const MINIMAL: BlockChrome = {
|
|
86
|
+
root: '',
|
|
87
|
+
frame: '',
|
|
88
|
+
header: 'flex w-full items-baseline gap-1.5 px-1 py-0.5 text-left transition-colors',
|
|
89
|
+
icon: 'flex shrink-0 self-center items-center justify-center',
|
|
90
|
+
title: 'shrink-0 text-[11.5px] font-medium text-ink/70',
|
|
91
|
+
subtitle: 'min-w-0 truncate font-mono text-[10.5px] text-ink/45',
|
|
92
|
+
body: 'my-1.5 overflow-hidden rounded-md border border-dashed border-ink/15 px-3 py-2.5',
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const BY_MODE: Record<ToolRenderMode, BlockChrome> = {
|
|
96
|
+
card: CARD,
|
|
97
|
+
compact: COMPACT,
|
|
98
|
+
trace: TRACE,
|
|
99
|
+
minimal: MINIMAL,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export function blockChrome(mode: ToolRenderMode): BlockChrome {
|
|
103
|
+
return BY_MODE[mode];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The left inset non-block content needs so the `trace` rail does not strike it.
|
|
108
|
+
*
|
|
109
|
+
* A trace BLOCK reserves the rail's column itself (`mx-3` gutter plus `pl-4`), so
|
|
110
|
+
* its node sits at the rail and its text starts 16px past it. Prose, a notice
|
|
111
|
+
* body, a diagnostic note and the summary card reserve nothing — they start at
|
|
112
|
+
* `px-3` (12px) — and the rail, measured at x=315 in a 1440px window, landed
|
|
113
|
+
* 4px INSIDE the first character of the answer. Measured with the rail's own
|
|
114
|
+
* box: text elements at 311–979 against a rail at 315–316.
|
|
115
|
+
*
|
|
116
|
+
* - `text` (`ml-4`): transparent prose and the standalone intent. 16px puts
|
|
117
|
+
* the box past the rail's 16.5px edge and the text at 28px, exactly where a
|
|
118
|
+
* block's own content sits.
|
|
119
|
+
* - `boxed` (`ml-5`): a card with a background or a left border — the error
|
|
120
|
+
* strip, the diagnostic note, the summary. 20px clears the node's 8px width
|
|
121
|
+
* so the rail never runs across a fill.
|
|
122
|
+
*
|
|
123
|
+
* A phone needs neither: there the rail is at 3.5px and content already starts
|
|
124
|
+
* at 12px (measured: rail x=20, nodes x=20, text clear).
|
|
125
|
+
*/
|
|
126
|
+
export function traceInset(mode: ToolRenderMode, isMobile: boolean, boxed = false): string {
|
|
127
|
+
if (mode !== 'trace' || isMobile) return '';
|
|
128
|
+
return boxed ? 'ml-5' : 'ml-4';
|
|
129
|
+
}
|