@kabmo-labs/kabmo 0.13.0 → 0.14.0
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-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
- package/dist/client/static/js/index-tsgy3gd1.css +1 -0
- package/package.json +1 -1
- 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 +205 -0
- package/src/client/components/common/session-row/session-row.test.tsx +144 -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 +55 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -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/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 +14 -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.tsx +108 -67
- 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 +158 -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/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/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 +120 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +68 -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/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,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
|
+
}
|
|
@@ -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,120 @@
|
|
|
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('hasTraceContent reads each shape omp writes', () => {
|
|
84
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', notice: 'n' } as unknown as ChatMessageData)).toBe(true);
|
|
85
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', thinking: { thought: 't' } } as unknown as ChatMessageData)).toBe(true);
|
|
86
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', monologue: 'm' } as unknown as ChatMessageData)).toBe(true);
|
|
87
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: '', toolCalls: [tool] } as unknown as ChatMessageData)).toBe(true);
|
|
88
|
+
expect(hasTraceContent({ id: 'x', role: 'ai', content: 'plain' } as unknown as ChatMessageData)).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The inset that keeps the rail off the content.
|
|
94
|
+
*
|
|
95
|
+
* Measured defect: the rail sat at x=315 in a 1440px window while the answer's
|
|
96
|
+
* `<p>`/`<ul>` started at 311 — the line ran 4px INSIDE the first character.
|
|
97
|
+
* A trace block reserves the column itself (`mx-3` + `pl-4`); prose, a notice
|
|
98
|
+
* body, a diagnostic note and the summary card reserve nothing, so they need
|
|
99
|
+
* this inset.
|
|
100
|
+
*/
|
|
101
|
+
describe('traceInset', () => {
|
|
102
|
+
test('only the trace style, and only off a phone, insets content', () => {
|
|
103
|
+
expect(traceInset('trace', false)).toBe('ml-4');
|
|
104
|
+
expect(traceInset('trace', false, true)).toBe('ml-5');
|
|
105
|
+
expect(traceInset('trace', true)).toBe('');
|
|
106
|
+
expect(traceInset('card', false)).toBe('');
|
|
107
|
+
expect(traceInset('compact', false)).toBe('');
|
|
108
|
+
expect(traceInset('minimal', false)).toBe('');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('a boxed element clears the node, a text element only needs the rail', () => {
|
|
112
|
+
// The rail occupies 15.5–16.5px and the node 12–20px from the container.
|
|
113
|
+
// `ml-4` (16px) clears the line for transparent prose; `ml-5` (20px) clears
|
|
114
|
+
// the node too, so a background or a left border is never crossed.
|
|
115
|
+
const px = (cls: string) => Number(cls.replace('ml-', '')) * 4;
|
|
116
|
+
expect(px(traceInset('trace', false))).toBe(16);
|
|
117
|
+
expect(px(traceInset('trace', false, true))).toBe(20);
|
|
118
|
+
expect(px(traceInset('trace', false, true))).toBeGreaterThan(16.5);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
/** React key: the first row's id. */
|
|
26
|
+
key: string;
|
|
27
|
+
/** Indices into the caller's `messages` array, in order. */
|
|
28
|
+
rows: number[];
|
|
29
|
+
/**
|
|
30
|
+
* Whether this group draws a rail. A run of pure prose draws none — a line
|
|
31
|
+
* beside an answer that has no steps would claim a sequence that is not there.
|
|
32
|
+
*/
|
|
33
|
+
trace: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Whether a row contributes a node: a notice, thinking, or tool calls. */
|
|
37
|
+
export function hasTraceContent(msg: ChatMessageData): boolean {
|
|
38
|
+
if (isNoticeRow(msg)) return true;
|
|
39
|
+
if (msg.thinking || msg.monologue) return true;
|
|
40
|
+
return Boolean((msg.toolCalls?.length ?? 0) || (msg.actions?.length ?? 0) || (msg.actions2?.length ?? 0));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Group `messages[start, end)` into render units.
|
|
45
|
+
*
|
|
46
|
+
* A user row is its own unit; every other row joins the run above it. The
|
|
47
|
+
* group's `trace` is the OR of its rows' trace content, so a run whose steps sit
|
|
48
|
+
* on one row and whose answer sits on the next still draws one line across both.
|
|
49
|
+
*/
|
|
50
|
+
export function groupTraceRows(messages: ChatMessageData[], start = 0, end = messages.length): TraceGroup[] {
|
|
51
|
+
const groups: TraceGroup[] = [];
|
|
52
|
+
const last = Math.min(end, messages.length);
|
|
53
|
+
for (let idx = start; idx < last; idx++) {
|
|
54
|
+
const msg = messages[idx];
|
|
55
|
+
if (msg.role === 'user') {
|
|
56
|
+
groups.push({ key: msg.id, rows: [idx], trace: false });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const open = groups[groups.length - 1];
|
|
60
|
+
if (open && messages[open.rows[0]].role !== 'user') {
|
|
61
|
+
open.rows.push(idx);
|
|
62
|
+
open.trace = open.trace || hasTraceContent(msg);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
groups.push({ key: msg.id, rows: [idx], trace: hasTraceContent(msg) });
|
|
66
|
+
}
|
|
67
|
+
return groups;
|
|
68
|
+
}
|
|
@@ -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
|
+
}
|