@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,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The tool-render style is a stored string, so it has to survive three things
|
|
8
|
+
* without ever pointing at a renderer that does not exist: a fresh install, a
|
|
9
|
+
* value written by another build, and a corrupted blob.
|
|
10
|
+
*
|
|
11
|
+
* The copy is asserted too, because the settings control is generated from the
|
|
12
|
+
* same table — a mode added without copy renders a card with no label.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_TOOL_RENDER_MODE,
|
|
18
|
+
TOOL_RENDER_MODE_COPY,
|
|
19
|
+
TOOL_RENDER_MODES,
|
|
20
|
+
isToolRenderMode,
|
|
21
|
+
resolveToolRenderMode,
|
|
22
|
+
} from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
23
|
+
|
|
24
|
+
describe('tool render mode', () => {
|
|
25
|
+
test('every listed mode is a mode, and nothing else is', () => {
|
|
26
|
+
for (const mode of TOOL_RENDER_MODES) expect(isToolRenderMode(mode)).toBe(true);
|
|
27
|
+
expect(isToolRenderMode('cards')).toBe(false);
|
|
28
|
+
expect(isToolRenderMode('')).toBe(false);
|
|
29
|
+
expect(isToolRenderMode(null)).toBe(false);
|
|
30
|
+
expect(isToolRenderMode(undefined)).toBe(false);
|
|
31
|
+
expect(isToolRenderMode(3)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('a value this build cannot draw resolves to the default', () => {
|
|
35
|
+
expect(resolveToolRenderMode('compact')).toBe('compact');
|
|
36
|
+
expect(resolveToolRenderMode('from-a-newer-build')).toBe(DEFAULT_TOOL_RENDER_MODE);
|
|
37
|
+
expect(resolveToolRenderMode(undefined)).toBe(DEFAULT_TOOL_RENDER_MODE);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('the default is the style Kabmo shipped before the setting existed', () => {
|
|
41
|
+
expect(DEFAULT_TOOL_RENDER_MODE).toBe('card');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('every mode carries a label and a description for the settings card', () => {
|
|
45
|
+
for (const mode of TOOL_RENDER_MODES) {
|
|
46
|
+
const copy = TOOL_RENDER_MODE_COPY[mode];
|
|
47
|
+
expect(copy.label.length).toBeGreaterThan(0);
|
|
48
|
+
expect(copy.description.length).toBeGreaterThan(0);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How a tool call is drawn in the chat transcript, as ONE of four modes.
|
|
8
|
+
*
|
|
9
|
+
* This is a READING style, not a capability: every mode renders the same call,
|
|
10
|
+
* the same facts and the same body — only the frame, the density and the
|
|
11
|
+
* grouping change. No mode hides information, and the collapsed form always
|
|
12
|
+
* states the outcome (the rule `ToolCardShell` was built around).
|
|
13
|
+
*
|
|
14
|
+
* - `card` — the bordered, collapsible card Kabmo has always shipped.
|
|
15
|
+
* - `compact` — one status line per call, facts inline, body inset on demand.
|
|
16
|
+
* - `trace` — a vertical rail per section, one node per call.
|
|
17
|
+
* - `minimal` — a faint line per call, read as part of the answer.
|
|
18
|
+
*
|
|
19
|
+
* **The mode NAMES and the copy live here**; the markup lives in
|
|
20
|
+
* `tool-renderers/styles/`. A mode added here without a renderer is a build
|
|
21
|
+
* error at the switch in `ToolCallingSection`, not a silent fallback.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export type ToolRenderMode = 'card' | 'compact' | 'trace' | 'minimal';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The mode a document with no stored preference renders at. It is the value
|
|
28
|
+
* Kabmo shipped before the setting existed, so an upgrade changes nothing.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_TOOL_RENDER_MODE: ToolRenderMode = 'card';
|
|
31
|
+
|
|
32
|
+
/** Every mode, in the order the settings control lists them: fullest first. */
|
|
33
|
+
export const TOOL_RENDER_MODES = ['card', 'compact', 'trace', 'minimal'] as const;
|
|
34
|
+
|
|
35
|
+
/** A stored value written by another build is not a mode this one can draw. */
|
|
36
|
+
export function isToolRenderMode(value: unknown): value is ToolRenderMode {
|
|
37
|
+
return value === 'card' || value === 'compact' || value === 'trace' || value === 'minimal';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The mode to APPLY for a stored value. Anything this build cannot draw — a
|
|
42
|
+
* value from a newer build, a corrupted blob, `undefined` on a fresh install —
|
|
43
|
+
* falls back to the default rather than to a renderer that does not exist.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveToolRenderMode(value: unknown): ToolRenderMode {
|
|
46
|
+
return isToolRenderMode(value) ? value : DEFAULT_TOOL_RENDER_MODE;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ToolRenderModeCopy {
|
|
50
|
+
/** Control label. */
|
|
51
|
+
label: string;
|
|
52
|
+
/** One line under the label, in the settings card. */
|
|
53
|
+
description: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Labels for the settings control. */
|
|
57
|
+
export const TOOL_RENDER_MODE_COPY: Record<ToolRenderMode, ToolRenderModeCopy> = {
|
|
58
|
+
card: {
|
|
59
|
+
label: 'Card',
|
|
60
|
+
description: 'A bordered card per call: the outcome, the facts, and a body that opens on click.',
|
|
61
|
+
},
|
|
62
|
+
compact: {
|
|
63
|
+
label: 'Compact',
|
|
64
|
+
description: 'One status line per call, with the facts inline and the body inset on demand.',
|
|
65
|
+
},
|
|
66
|
+
trace: {
|
|
67
|
+
label: 'Trace',
|
|
68
|
+
description: 'A vertical rail per section: every step on one line, expanded in place.',
|
|
69
|
+
},
|
|
70
|
+
minimal: {
|
|
71
|
+
label: 'Minimal',
|
|
72
|
+
description: 'The quietest form: a faint line per call, read as part of the answer.',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `trace` rail belongs to the RUN, and this is where that rule is pinned.
|
|
8
|
+
*
|
|
9
|
+
* The defect it prevents: the rail was drawn per BLOCK. Measured in the browser
|
|
10
|
+
* on the 39-call sample session, that produced three disconnected segments with
|
|
11
|
+
* gaps of 256px and 99px, because a turn is several message rows (thinking +
|
|
12
|
+
* tools, then a notice, then the answer) and prose sits between them. A line
|
|
13
|
+
* whose only job is "these steps are one sequence" cannot break at every row.
|
|
14
|
+
*
|
|
15
|
+
* The grouping is pure so this suite needs no DOM: mounting a real timeline is
|
|
16
|
+
* heavy enough to disturb the runner's file loading, and the rule itself has
|
|
17
|
+
* nothing to do with rendering.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, expect, test } from 'bun:test';
|
|
21
|
+
import { groupTraceRows, hasTraceContent } from '@/shared/lib/chat/timeline/trace-groups';
|
|
22
|
+
import { traceInset } from '@/shared/lib/chat/timeline/block-chrome';
|
|
23
|
+
import type { ChatMessageData } from '@/shared/types/chat';
|
|
24
|
+
|
|
25
|
+
const tool = { id: 'c1', type: 'bash', name: 'bash', title: 'Bash', status: 'success' };
|
|
26
|
+
|
|
27
|
+
/** A turn as omp writes it: thinking + tools, then a notice row, then prose. */
|
|
28
|
+
const TURN = [
|
|
29
|
+
{ id: 'u1', role: 'user', content: 'run it' },
|
|
30
|
+
{ id: 'a1', role: 'ai', thinking: { thought: 'Consider the suite.' }, toolCalls: [tool], content: '' },
|
|
31
|
+
{ id: 'n1', role: 'ai', content: '', notice: 'Reminder: one thing\nSecond line' },
|
|
32
|
+
{ id: 'a2', role: 'ai', content: 'All done.' },
|
|
33
|
+
] as unknown as ChatMessageData[];
|
|
34
|
+
|
|
35
|
+
describe('trace grouping', () => {
|
|
36
|
+
test('a whole turn is ONE group, so it draws one rail', () => {
|
|
37
|
+
const groups = groupTraceRows(TURN);
|
|
38
|
+
expect(groups).toHaveLength(2);
|
|
39
|
+
expect(groups[0]).toEqual({ key: 'u1', rows: [0], trace: false });
|
|
40
|
+
expect(groups[1]).toEqual({ key: 'a1', rows: [1, 2, 3], trace: true });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('a user row closes the run: two turns are two groups', () => {
|
|
44
|
+
const twoTurns = [
|
|
45
|
+
...TURN,
|
|
46
|
+
{ id: 'u2', role: 'user', content: 'again' },
|
|
47
|
+
{ id: 'a3', role: 'ai', toolCalls: [{ ...tool, id: 'c2' }], content: '' },
|
|
48
|
+
] as unknown as ChatMessageData[];
|
|
49
|
+
const groups = groupTraceRows(twoTurns);
|
|
50
|
+
expect(groups.map((group) => group.rows)).toEqual([[0], [1, 2, 3], [4], [5]]);
|
|
51
|
+
expect(groups.filter((group) => group.trace)).toHaveLength(2);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a run of pure prose draws no rail', () => {
|
|
55
|
+
const prose = [
|
|
56
|
+
{ id: 'u1', role: 'user', content: 'hi' },
|
|
57
|
+
{ id: 'a1', role: 'ai', content: 'Just an answer.' },
|
|
58
|
+
] as unknown as ChatMessageData[];
|
|
59
|
+
const groups = groupTraceRows(prose);
|
|
60
|
+
expect(groups).toHaveLength(2);
|
|
61
|
+
expect(groups.every((group) => group.trace === false)).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('trace content on ANY row marks the whole run', () => {
|
|
65
|
+
const late = [
|
|
66
|
+
{ id: 'u1', role: 'user', content: 'go' },
|
|
67
|
+
{ id: 'a1', role: 'ai', content: 'Thinking out loud.' },
|
|
68
|
+
{ id: 'a2', role: 'ai', toolCalls: [tool], content: '' },
|
|
69
|
+
] as unknown as ChatMessageData[];
|
|
70
|
+
const groups = groupTraceRows(late);
|
|
71
|
+
expect(groups[1].rows).toEqual([1, 2]);
|
|
72
|
+
expect(groups[1].trace).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('a window groups only the rows it covers', () => {
|
|
76
|
+
const groups = groupTraceRows(TURN, 2, 4);
|
|
77
|
+
expect(groups).toHaveLength(1);
|
|
78
|
+
expect(groups[0].rows).toEqual([2, 3]);
|
|
79
|
+
// Row 2 is the notice, which carries trace content on its own.
|
|
80
|
+
expect(groups[0].trace).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('a truncated run keeps the key of its first row, so a window shift cannot remount it', () => {
|
|
84
|
+
// The timeline mounts a WINDOW of rows, so the run is routinely rendered
|
|
85
|
+
// from the middle. Keying the group by `rows[0]` renamed it every time a
|
|
86
|
+
// measurement moved `start` by one row, and a renamed key remounts the
|
|
87
|
+
// whole run — which threw away the thinking accordion's own open state
|
|
88
|
+
// (measured: one expand removed and re-added all 14 rows of the run).
|
|
89
|
+
const whole = groupTraceRows(TURN, 1, 4);
|
|
90
|
+
const shifted = groupTraceRows(TURN, 2, 4);
|
|
91
|
+
expect(whole[0].key).toBe('a1');
|
|
92
|
+
expect(shifted[0].key).toBe(whole[0].key);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('hasTraceContent reads each shape omp writes', () => {
|
|
96
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', notice: 'n' } as unknown as ChatMessageData)).toBe(true);
|
|
97
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', thinking: { thought: 't' } } as unknown as ChatMessageData)).toBe(true);
|
|
98
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', monologue: 'm' } as unknown as ChatMessageData)).toBe(true);
|
|
99
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', toolCalls: [tool] } as unknown as ChatMessageData)).toBe(true);
|
|
100
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: 'plain' } as unknown as ChatMessageData)).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The inset that keeps the rail off the content.
|
|
106
|
+
*
|
|
107
|
+
* Measured defect: the rail sat at x=315 in a 1440px window while the answer's
|
|
108
|
+
* `<p>`/`<ul>` started at 311 — the line ran 4px INSIDE the first character.
|
|
109
|
+
* A trace block reserves the column itself (`mx-3` + `pl-4`); prose, a notice
|
|
110
|
+
* body, a diagnostic note and the summary card reserve nothing, so they need
|
|
111
|
+
* this inset.
|
|
112
|
+
*/
|
|
113
|
+
describe('traceInset', () => {
|
|
114
|
+
test('only the trace style, and only off a phone, insets content', () => {
|
|
115
|
+
expect(traceInset('trace', false)).toBe('ml-4');
|
|
116
|
+
expect(traceInset('trace', false, true)).toBe('ml-5');
|
|
117
|
+
expect(traceInset('trace', true)).toBe('');
|
|
118
|
+
expect(traceInset('card', false)).toBe('');
|
|
119
|
+
expect(traceInset('compact', false)).toBe('');
|
|
120
|
+
expect(traceInset('minimal', false)).toBe('');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('a boxed element clears the node, a text element only needs the rail', () => {
|
|
124
|
+
// The rail occupies 15.5–16.5px and the node 12–20px from the container.
|
|
125
|
+
// `ml-4` (16px) clears the line for transparent prose; `ml-5` (20px) clears
|
|
126
|
+
// the node too, so a background or a left border is never crossed.
|
|
127
|
+
const px = (cls: string) => Number(cls.replace('ml-', '')) * 4;
|
|
128
|
+
expect(px(traceInset('trace', false))).toBe(16);
|
|
129
|
+
expect(px(traceInset('trace', false, true))).toBe(20);
|
|
130
|
+
expect(px(traceInset('trace', false, true))).toBeGreaterThan(16.5);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How the timeline's rows are grouped for the `trace` rail.
|
|
8
|
+
*
|
|
9
|
+
* A rail belongs to a RUN, not to a row and not to a block. omp writes one turn
|
|
10
|
+
* as several rows — thinking + tool calls, a notice, then the answer — so a line
|
|
11
|
+
* drawn per row (or per block) breaks at every boundary: measured in the browser
|
|
12
|
+
* on the 39-call sample session, per-block segments left gaps of 256px and 99px
|
|
13
|
+
* between the thinking block, the tool section and the notice.
|
|
14
|
+
*
|
|
15
|
+
* A run is therefore "the consecutive non-user rows", and a user row closes it.
|
|
16
|
+
* That is the whole rule, and it is PURE — the timeline groups its rows here and
|
|
17
|
+
* draws one rail per group, so the decision can be tested without mounting a
|
|
18
|
+
* timeline (which is heavy enough to disturb the runner's file loading).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ChatMessageData } from '@/shared/types/chat';
|
|
22
|
+
import { isNoticeRow } from '@/shared/lib/chat/notice-row';
|
|
23
|
+
|
|
24
|
+
export interface TraceGroup {
|
|
25
|
+
/**
|
|
26
|
+
* Render key: the id of the row that STARTS the run — which is the window's
|
|
27
|
+
* first row only when the window happens to begin at the run's first row.
|
|
28
|
+
*
|
|
29
|
+
* It used to be `rows[0]` unconditionally, and that is what made a block
|
|
30
|
+
* inside a run collapse the moment it was expanded. The timeline mounts a
|
|
31
|
+
* WINDOW of rows, so every measurement that moved the window's `start` by one
|
|
32
|
+
* row renamed the group; a renamed `key` remounts the whole run, and a
|
|
33
|
+
* remount throws away every block's local state — the thinking accordion's
|
|
34
|
+
* own `useState` included, which is why expanding a thought snapped shut
|
|
35
|
+
* again (measured in the browser: one click removed and re-added all 14 rows
|
|
36
|
+
* of the run). A key derived from the run's first row is the same string for
|
|
37
|
+
* every window that covers part of that run.
|
|
38
|
+
*/
|
|
39
|
+
key: string;
|
|
40
|
+
/** Indices into the caller's `messages` array, in order. */
|
|
41
|
+
rows: number[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether this group draws a rail. A run of pure prose draws none — a line
|
|
44
|
+
* beside an answer that has no steps would claim a sequence that is not there.
|
|
45
|
+
*/
|
|
46
|
+
trace: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Whether a row contributes a node: a notice, thinking, or tool calls. */
|
|
50
|
+
export function hasTraceContent(msg: ChatMessageData): boolean {
|
|
51
|
+
if (isNoticeRow(msg)) return true;
|
|
52
|
+
if (msg.thinking || msg.monologue) return true;
|
|
53
|
+
return Boolean((msg.toolCalls?.length ?? 0) || (msg.actions?.length ?? 0) || (msg.actions2?.length ?? 0));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The absolute index where the run containing `index` begins: the first row
|
|
58
|
+
* after the previous user row. Walks back past the window's own `start`,
|
|
59
|
+
* because the key must not depend on where the window happens to begin.
|
|
60
|
+
*/
|
|
61
|
+
function runStartIndex(messages: ChatMessageData[], index: number): number {
|
|
62
|
+
let cursor = index;
|
|
63
|
+
while (cursor > 0 && messages[cursor - 1].role !== 'user') cursor -= 1;
|
|
64
|
+
return cursor;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Group `messages[start, end)` into render units.
|
|
69
|
+
*
|
|
70
|
+
* A user row is its own unit; every other row joins the run above it. The
|
|
71
|
+
* group's `trace` is the OR of its rows' trace content, so a run whose steps sit
|
|
72
|
+
* on one row and whose answer sits on the next still draws one line across both.
|
|
73
|
+
*
|
|
74
|
+
* A truncated run keeps the key of its FIRST row, outside the window included —
|
|
75
|
+
* see `TraceGroup.key`.
|
|
76
|
+
*/
|
|
77
|
+
export function groupTraceRows(messages: ChatMessageData[], start = 0, end = messages.length): TraceGroup[] {
|
|
78
|
+
const groups: TraceGroup[] = [];
|
|
79
|
+
const last = Math.min(end, messages.length);
|
|
80
|
+
for (let idx = start; idx < last; idx++) {
|
|
81
|
+
const msg = messages[idx];
|
|
82
|
+
if (msg.role === 'user') {
|
|
83
|
+
groups.push({ key: msg.id, rows: [idx], trace: false });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const open = groups[groups.length - 1];
|
|
87
|
+
if (open && messages[open.rows[0]].role !== 'user') {
|
|
88
|
+
open.rows.push(idx);
|
|
89
|
+
open.trace = open.trace || hasTraceContent(msg);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
groups.push({ key: messages[runStartIndex(messages, idx)].id, rows: [idx], trace: hasTraceContent(msg) });
|
|
93
|
+
}
|
|
94
|
+
return groups;
|
|
95
|
+
}
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
import type { SettingsState } from '@/shared/types';
|
|
22
22
|
import { DEFAULT_THEME_ID } from '@/shared/lib/theme/catalog';
|
|
23
23
|
import { DEFAULT_CHAT_WIDTH_MODE } from '@/shared/lib/chat/timeline/width-mode';
|
|
24
|
+
import { DEFAULT_TOOL_RENDER_MODE } from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
25
|
+
import { DEFAULT_SIDEBAR_STYLE } from '@/shared/lib/workspace/sidebar-style';
|
|
26
|
+
import { DEFAULT_COMPOSER_STYLE } from '@/shared/lib/chat/composer/style';
|
|
24
27
|
import { EDITOR_DEFAULT_FONT_FAMILY } from '@/shared/lib/code/editor/typography';
|
|
25
28
|
import { EDITOR_DEFAULT_THEME_ID } from '@/shared/lib/code/editor/themes';
|
|
26
29
|
|
|
@@ -35,6 +38,9 @@ export const DEFAULT_SETTINGS = {
|
|
|
35
38
|
goalAuditModel: '',
|
|
36
39
|
goalDefaultBudget: null,
|
|
37
40
|
chatWidthMode: DEFAULT_CHAT_WIDTH_MODE,
|
|
41
|
+
toolRenderStyle: DEFAULT_TOOL_RENDER_MODE,
|
|
42
|
+
sidebarStyle: DEFAULT_SIDEBAR_STYLE,
|
|
43
|
+
composerStyle: DEFAULT_COMPOSER_STYLE,
|
|
38
44
|
followUpBehavior: 'queue',
|
|
39
45
|
keybindingSend: 'Enter',
|
|
40
46
|
keybindingNewLine: 'Shift + Enter',
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The focus filter behind the modern sidebar's `Running` chip.
|
|
8
|
+
*
|
|
9
|
+
* Two properties are load-bearing and each is a bug if lost:
|
|
10
|
+
*
|
|
11
|
+
* - **a workspace with nothing running is DROPPED**, not drawn as an empty
|
|
12
|
+
* header. A focus switch that leaves a column of empty workspaces has not
|
|
13
|
+
* focused anything.
|
|
14
|
+
* - **"running" means the user is waiting on this row** — a run in flight, a
|
|
15
|
+
* held prompt, or an agent blocked on a question. A `finish` badge is NOT
|
|
16
|
+
* running: it is a one-shot mark that clears when the session opens, so
|
|
17
|
+
* counting it would keep finished chats in a "running" list forever.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, expect, test } from 'bun:test';
|
|
21
|
+
import { focusFolders, isRunningSession, runningSessionCount } from '@/shared/lib/workspace/session-focus';
|
|
22
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
23
|
+
|
|
24
|
+
function session(id: string, extra: Partial<SessionItemData> = {}): SessionItemData {
|
|
25
|
+
return { id, folder_id: 1, title: id, ...extra };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function folder(id: number, sessions: SessionItemData[]): WorkspaceFolderData {
|
|
29
|
+
return {
|
|
30
|
+
id,
|
|
31
|
+
name: `ws-${id}`,
|
|
32
|
+
isExpanded: true,
|
|
33
|
+
sessions,
|
|
34
|
+
hasMore: false,
|
|
35
|
+
totalSessions: sessions.length,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const statusOf = (map: Record<string, 'stream' | 'finish' | 'abort'>) =>
|
|
40
|
+
(id: string) => map[id];
|
|
41
|
+
|
|
42
|
+
describe('isRunningSession', () => {
|
|
43
|
+
test('a stream status is running', () => {
|
|
44
|
+
expect(isRunningSession(session('a'), 'stream')).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('a finished or aborted run is not running', () => {
|
|
48
|
+
expect(isRunningSession(session('a'), 'finish')).toBe(false);
|
|
49
|
+
expect(isRunningSession(session('a'), 'abort')).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('a blocked agent and a held prompt count, with no stream status at all', () => {
|
|
53
|
+
expect(isRunningSession(session('a', { awaitingInput: true }))).toBe(true);
|
|
54
|
+
expect(isRunningSession(session('b', { waitingFor: { waitId: 'w', sessionId: 'b', title: null } }))).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('focusFolders', () => {
|
|
59
|
+
const folders = [
|
|
60
|
+
folder(1, [session('a'), session('b')]),
|
|
61
|
+
folder(2, [session('c')]),
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
test('all returns the list untouched', () => {
|
|
65
|
+
expect(focusFolders(folders, { focus: 'all', statusOf: statusOf({}) })).toBe(folders);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('running keeps only the rows that are running and drops empty workspaces', () => {
|
|
69
|
+
const filtered = focusFolders(folders, {
|
|
70
|
+
focus: 'running',
|
|
71
|
+
statusOf: statusOf({ b: 'stream' }),
|
|
72
|
+
});
|
|
73
|
+
expect(filtered.map((f) => f.id)).toEqual([1]);
|
|
74
|
+
expect(filtered[0].sessions.map((s) => s.id)).toEqual(['b']);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('nothing running is an empty list, never the whole list', () => {
|
|
78
|
+
expect(focusFolders(folders, { focus: 'running', statusOf: statusOf({}) })).toEqual([]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('runningSessionCount', () => {
|
|
83
|
+
test('counts rows across every workspace', () => {
|
|
84
|
+
const count = runningSessionCount(
|
|
85
|
+
[
|
|
86
|
+
folder(1, [session('a'), session('b')]),
|
|
87
|
+
folder(2, [session('c', { awaitingInput: true })]),
|
|
88
|
+
],
|
|
89
|
+
statusOf({ a: 'stream' }),
|
|
90
|
+
);
|
|
91
|
+
expect(count).toBe(2);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's focus filter: the list shows everything, or only the
|
|
8
|
+
* chats that are doing something right now.
|
|
9
|
+
*
|
|
10
|
+
* It is a FILTER over the same folders, never a second query: the rows, their
|
|
11
|
+
* actions, their archives and their worktrees are the ones the server already
|
|
12
|
+
* sent. A workspace with nothing left to show is dropped entirely rather than
|
|
13
|
+
* drawn as an empty header — the same rule the search filter follows, and the
|
|
14
|
+
* reason a focus switch does not leave a column of empty workspaces.
|
|
15
|
+
*
|
|
16
|
+
* "Doing something" is deliberately three states and not one: a run in flight,
|
|
17
|
+
* a prompt held behind another session, and an agent blocked on a question all
|
|
18
|
+
* mean the user is waiting on this row. A finished run is not — `finish` is a
|
|
19
|
+
* one-shot badge that clears when the session opens.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
23
|
+
|
|
24
|
+
export type SessionFocus = 'all' | 'running';
|
|
25
|
+
|
|
26
|
+
export const SESSION_FOCUSES: readonly SessionFocus[] = ['all', 'running'];
|
|
27
|
+
|
|
28
|
+
export type SessionStatusLookup = (sessionId: string) => 'stream' | 'finish' | 'abort' | undefined;
|
|
29
|
+
|
|
30
|
+
/** True when this row is the reason the user opened the sidebar. */
|
|
31
|
+
export function isRunningSession(session: SessionItemData, status?: string): boolean {
|
|
32
|
+
if (session.awaitingInput) return true;
|
|
33
|
+
if (session.waitingFor) return true;
|
|
34
|
+
return status === 'stream';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface FocusFilterInput {
|
|
38
|
+
focus: SessionFocus;
|
|
39
|
+
statusOf: SessionStatusLookup;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The folders a focus filter offers. `all` returns the input untouched — the
|
|
44
|
+
* caller compares by identity to know whether it has to expand anything.
|
|
45
|
+
*/
|
|
46
|
+
export function focusFolders(
|
|
47
|
+
folders: readonly WorkspaceFolderData[],
|
|
48
|
+
{ focus, statusOf }: FocusFilterInput,
|
|
49
|
+
): WorkspaceFolderData[] {
|
|
50
|
+
if (focus === 'all') return folders as WorkspaceFolderData[];
|
|
51
|
+
return folders
|
|
52
|
+
.map((folder) => ({
|
|
53
|
+
...folder,
|
|
54
|
+
sessions: folder.sessions.filter((session) => isRunningSession(session, statusOf(String(session.id)))),
|
|
55
|
+
}))
|
|
56
|
+
.filter((folder) => folder.sessions.length > 0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** How many rows the focus filter would keep — the chip's badge. */
|
|
60
|
+
export function runningSessionCount(
|
|
61
|
+
folders: readonly WorkspaceFolderData[],
|
|
62
|
+
statusOf: SessionStatusLookup,
|
|
63
|
+
): number {
|
|
64
|
+
let count = 0;
|
|
65
|
+
for (const folder of folders) {
|
|
66
|
+
for (const session of folder.sessions) {
|
|
67
|
+
if (isRunningSession(session, statusOf(String(session.id)))) count += 1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return count;
|
|
71
|
+
}
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
* from another conversation is never restored
|
|
67
67
|
* - chat.draft string
|
|
68
68
|
* - chat.draftAttachments attachment metadata array
|
|
69
|
+
* - chat.toolOpen Record<toolId, boolean> — the tool cards the
|
|
70
|
+
* reader opened or closed (see `useToolOpenState`)
|
|
71
|
+
* - chat.thinkingOpen Record<messageId, boolean> — the same for the
|
|
72
|
+
* thinking accordions (`useThinkingOpenState`), so a
|
|
73
|
+
* block stays open when the row window unmounts it
|
|
69
74
|
*
|
|
70
75
|
* The module is three files, because one had passed the per-file ceiling: this
|
|
71
76
|
* one owns the PUBLIC API (read, write, load, migrate) and what a write means;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which form the filter row's Select control takes, and when the chip group
|
|
8
|
+
* moves to the right edge.
|
|
9
|
+
*
|
|
10
|
+
* The thresholds are the point of this file, so they are pinned by width rather
|
|
11
|
+
* than described: the sidebar's floor is 264px (240px of row content) and its
|
|
12
|
+
* default is 280px (256px), which is exactly where four chips stop fitting —
|
|
13
|
+
* measured 265px — and why the trailing glyph is what ships at the default.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import {
|
|
18
|
+
FILTER_CHIP_PX,
|
|
19
|
+
FILTER_ROW_GAP_PX,
|
|
20
|
+
filterChipGroupWidth,
|
|
21
|
+
filterSelectForm,
|
|
22
|
+
} from '@/shared/lib/workspace/sidebar-filter-row';
|
|
23
|
+
|
|
24
|
+
/** The row's content width at a given sidebar width (its `px-3` removed). */
|
|
25
|
+
const contentAt = (sidebarWidth: number) => sidebarWidth - 24;
|
|
26
|
+
|
|
27
|
+
describe('filterChipGroupWidth', () => {
|
|
28
|
+
test('three chips plus two gaps', () => {
|
|
29
|
+
expect(filterChipGroupWidth(0, false)).toBe(
|
|
30
|
+
FILTER_CHIP_PX.all + FILTER_CHIP_PX.running + FILTER_CHIP_PX.archived + 2 * FILTER_ROW_GAP_PX,
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('the Select chip adds its own width and one more gap', () => {
|
|
35
|
+
expect(filterChipGroupWidth(0, true) - filterChipGroupWidth(0, false)).toBe(
|
|
36
|
+
FILTER_CHIP_PX.select + FILTER_ROW_GAP_PX,
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('a count badge widens the Running chip', () => {
|
|
41
|
+
expect(filterChipGroupWidth(3, false) - filterChipGroupWidth(0, false)).toBe(FILTER_CHIP_PX.runningCount);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('filterSelectForm', () => {
|
|
46
|
+
test('the 264px floor and the 280px default both take the trailing glyph', () => {
|
|
47
|
+
expect(filterSelectForm(contentAt(264), 0)).toBe('button');
|
|
48
|
+
expect(filterSelectForm(contentAt(280), 0)).toBe('button');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('the default does NOT fit four chips — the reason the row used to wrap', () => {
|
|
52
|
+
expect(filterChipGroupWidth(0, true)).toBeGreaterThan(contentAt(280));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('a wide sidebar takes the fourth chip, which is when the group right-aligns', () => {
|
|
56
|
+
const wide = filterChipGroupWidth(0, true);
|
|
57
|
+
expect(filterSelectForm(wide, 0)).toBe('chip');
|
|
58
|
+
expect(filterSelectForm(wide - 1, 0)).toBe('button');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('a running count moves the threshold with it', () => {
|
|
62
|
+
const withoutCount = filterChipGroupWidth(0, true);
|
|
63
|
+
const withCount = filterChipGroupWidth(2, true);
|
|
64
|
+
expect(withCount).toBeGreaterThan(withoutCount);
|
|
65
|
+
expect(filterSelectForm(withoutCount, 2)).toBe('button');
|
|
66
|
+
expect(filterSelectForm(withCount, 2)).toBe('chip');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('an unmeasured row keeps the narrow form rather than guessing', () => {
|
|
70
|
+
expect(filterSelectForm(0, 0)).toBe('button');
|
|
71
|
+
expect(filterSelectForm(Number.NaN, 0)).toBe('button');
|
|
72
|
+
});
|
|
73
|
+
});
|