@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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `card` style — the bordered, collapsible card Kabmo has always shipped.
|
|
8
|
+
*
|
|
9
|
+
* This file is the wiring only: `useToolView` derives what the card says, the
|
|
10
|
+
* shared `ToolBody` draws what it shows, and `ToolCardShell` owns the frame and
|
|
11
|
+
* the collapse state. The naming rules live in `card-header.ts`, the outcome
|
|
12
|
+
* chips in `toolSummary`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useCallback } from 'preact/hooks';
|
|
16
|
+
import { memo } from 'preact/compat';
|
|
17
|
+
import { Bell } from 'lucide-preact';
|
|
18
|
+
import { ArtifactChip } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip';
|
|
19
|
+
import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
|
|
20
|
+
import { ToolCardShell } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell';
|
|
21
|
+
import { useToolView } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view';
|
|
22
|
+
import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
|
|
23
|
+
|
|
24
|
+
export const CardRow = memo(function CardRow({ tool, isOpen, onToggle, defaultExpanded = false }: ToolRowProps) {
|
|
25
|
+
const view = useToolView(tool);
|
|
26
|
+
|
|
27
|
+
const handleToggle = useCallback(() => {
|
|
28
|
+
onToggle?.(tool.id);
|
|
29
|
+
}, [onToggle, tool.id]);
|
|
30
|
+
|
|
31
|
+
// A reminder envelope in the result is the runtime interrupting the call, not
|
|
32
|
+
// its outcome — the header flags it beside the status badge.
|
|
33
|
+
const actions = (
|
|
34
|
+
<>
|
|
35
|
+
<ArtifactChip tool={tool} />
|
|
36
|
+
{view.isReminder && (
|
|
37
|
+
<span className="inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error">
|
|
38
|
+
<Bell size={10} /> Reminder
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<ToolCardShell
|
|
46
|
+
tool={tool}
|
|
47
|
+
icon={view.icon}
|
|
48
|
+
title={view.header.title}
|
|
49
|
+
subtitle={view.subtitle}
|
|
50
|
+
summary={view.summary}
|
|
51
|
+
actions={actions}
|
|
52
|
+
isOpen={isOpen}
|
|
53
|
+
onToggle={onToggle ? handleToggle : undefined}
|
|
54
|
+
defaultExpanded={defaultExpanded}
|
|
55
|
+
alwaysExpanded={view.alwaysExpanded}
|
|
56
|
+
>
|
|
57
|
+
<ToolBody tool={tool} view={view} />
|
|
58
|
+
</ToolCardShell>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `compact` style — one status line per call, the body inset on demand.
|
|
8
|
+
*
|
|
9
|
+
* Modelled on the status line Claude's transcript and shadcn's `Trace` element
|
|
10
|
+
* use: no frame, no card, one row that states the outcome and the facts. The
|
|
11
|
+
* outcome is the glyph WITH its word for a screen reader (`status-glyph.tsx`),
|
|
12
|
+
* because a one-line style has no room for a badge but the collapsed state must
|
|
13
|
+
* still say whether the call failed.
|
|
14
|
+
*
|
|
15
|
+
* The facts stay whole and the subtitle truncates — the same rule the card
|
|
16
|
+
* learned: a half-ellipsized fact reads as a wrong fact.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
20
|
+
import { memo } from 'preact/compat';
|
|
21
|
+
import { ChevronDown } from 'lucide-preact';
|
|
22
|
+
import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
|
|
23
|
+
import { ToolFactChips } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips';
|
|
24
|
+
import { toolStatusGlyph, STATUS_TONE_CLASS } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph';
|
|
25
|
+
import { useToolView } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view';
|
|
26
|
+
import { toolToggleLabel } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label';
|
|
27
|
+
import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
|
|
28
|
+
|
|
29
|
+
export const CompactRow = memo(function CompactRow({ tool, isOpen, onToggle, defaultExpanded = false }: ToolRowProps) {
|
|
30
|
+
const view = useToolView(tool);
|
|
31
|
+
const [internalOpen, setInternalOpen] = useState(defaultExpanded);
|
|
32
|
+
const isExpanded = view.alwaysExpanded || (isOpen ?? internalOpen);
|
|
33
|
+
const status = toolStatusGlyph(tool);
|
|
34
|
+
|
|
35
|
+
const handleToggle = useCallback(() => {
|
|
36
|
+
if (onToggle) onToggle(tool.id);
|
|
37
|
+
else setInternalOpen((prev) => !prev);
|
|
38
|
+
}, [onToggle, tool.id]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="group" data-tool-row="compact">
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
onClick={handleToggle}
|
|
45
|
+
disabled={!view.hasBody || view.alwaysExpanded}
|
|
46
|
+
aria-expanded={isExpanded}
|
|
47
|
+
aria-label={view.hasBody && !view.alwaysExpanded ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined}
|
|
48
|
+
className={`flex w-full flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md px-1.5 py-1 text-left transition-colors ${
|
|
49
|
+
view.hasBody && !view.alwaysExpanded ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
|
|
50
|
+
} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
|
|
51
|
+
>
|
|
52
|
+
<span className={`shrink-0 ${STATUS_TONE_CLASS[status.tone]}`} aria-hidden="true">
|
|
53
|
+
{status.glyph}
|
|
54
|
+
</span>
|
|
55
|
+
<span className="sr-only">{status.word}</span>
|
|
56
|
+
<span className="shrink-0 text-ink/45" aria-hidden="true">
|
|
57
|
+
{view.icon}
|
|
58
|
+
</span>
|
|
59
|
+
<span className="shrink-0 truncate text-[12px] font-semibold tracking-tight text-ink">
|
|
60
|
+
{view.header.title}
|
|
61
|
+
</span>
|
|
62
|
+
{/* The subject and the facts share ONE clipping row, the way the card's
|
|
63
|
+
meta line does. Without the clip a long `+43 −16` chip pair widened
|
|
64
|
+
the section past the phone viewport: measured at 390, the section's
|
|
65
|
+
scrollWidth ran to 439 against a 362 client width. */}
|
|
66
|
+
<span className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
|
|
67
|
+
<span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/45">{view.subtitle}</span>
|
|
68
|
+
{view.summary && view.summary.facts.length > 0 && (
|
|
69
|
+
<span className="shrink-0">
|
|
70
|
+
<ToolFactChips facts={view.summary.facts} max={2} />
|
|
71
|
+
</span>
|
|
72
|
+
)}
|
|
73
|
+
</span>
|
|
74
|
+
{view.hasBody && !view.alwaysExpanded && (
|
|
75
|
+
<ChevronDown
|
|
76
|
+
size={13}
|
|
77
|
+
className={`shrink-0 text-ink/30 transition-transform duration-200 ${isExpanded ? 'rotate-180' : ''}`}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
{isExpanded && view.hasBody && (
|
|
83
|
+
<div className="ml-5 mt-0.5 overflow-hidden border-l border-dashed border-ink/15 py-2 pl-3 space-y-3 code-surface">
|
|
84
|
+
<ToolBody tool={tool} view={view} />
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `minimal` style — a faint line per call, read as part of the answer.
|
|
8
|
+
*
|
|
9
|
+
* This is the quietest form, and the one where being honest matters most: a
|
|
10
|
+
* line with no frame can look decorative, so it still carries the outcome
|
|
11
|
+
* glyph, the subject and the facts, and a failed call is the ONLY row that
|
|
12
|
+
* takes a tone. Everything else stays in the ink tones the palette reserves for
|
|
13
|
+
* text, which is what keeps the answer readable and the tool row subordinate to
|
|
14
|
+
* it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
18
|
+
import { memo } from 'preact/compat';
|
|
19
|
+
import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
|
|
20
|
+
import { toolStatusGlyph, STATUS_TONE_CLASS } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph';
|
|
21
|
+
import { useToolView } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view';
|
|
22
|
+
import { toolToggleLabel } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label';
|
|
23
|
+
import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
|
|
24
|
+
|
|
25
|
+
export const MinimalRow = memo(function MinimalRow({ tool, isOpen, onToggle, defaultExpanded = false }: ToolRowProps) {
|
|
26
|
+
const view = useToolView(tool);
|
|
27
|
+
const [internalOpen, setInternalOpen] = useState(defaultExpanded);
|
|
28
|
+
const isExpanded = view.alwaysExpanded || (isOpen ?? internalOpen);
|
|
29
|
+
const status = toolStatusGlyph(tool);
|
|
30
|
+
// Only an outcome the reader must not miss takes a tone; a success stays in
|
|
31
|
+
// ink so a run of ten calls does not read as ten warnings.
|
|
32
|
+
const toneClass = status.tone === 'error' || status.tone === 'warn' ? STATUS_TONE_CLASS[status.tone] : 'text-ink/35';
|
|
33
|
+
|
|
34
|
+
const handleToggle = useCallback(() => {
|
|
35
|
+
if (onToggle) onToggle(tool.id);
|
|
36
|
+
else setInternalOpen((prev) => !prev);
|
|
37
|
+
}, [onToggle, tool.id]);
|
|
38
|
+
|
|
39
|
+
const factsLine = view.summary?.line ? ` (${view.summary.line})` : '';
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="px-1" data-tool-row="minimal">
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
onClick={handleToggle}
|
|
46
|
+
disabled={!view.hasBody || view.alwaysExpanded}
|
|
47
|
+
aria-expanded={isExpanded}
|
|
48
|
+
aria-label={view.hasBody && !view.alwaysExpanded ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined}
|
|
49
|
+
className={`flex w-full items-baseline gap-1.5 rounded py-0.5 text-left text-[11.5px] transition-colors ${
|
|
50
|
+
view.hasBody && !view.alwaysExpanded ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
|
|
51
|
+
} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
|
|
52
|
+
>
|
|
53
|
+
<span className={`shrink-0 self-center ${toneClass}`} aria-hidden="true">
|
|
54
|
+
{status.glyph}
|
|
55
|
+
</span>
|
|
56
|
+
<span className="sr-only">{status.word}</span>
|
|
57
|
+
<span className="shrink-0 font-medium text-ink/70">{view.header.title}</span>
|
|
58
|
+
{(view.subtitle || factsLine) && <span className="text-ink/25">—</span>}
|
|
59
|
+
<span className="min-w-0 truncate font-mono text-ink/45">
|
|
60
|
+
{view.subtitle}
|
|
61
|
+
{factsLine}
|
|
62
|
+
</span>
|
|
63
|
+
</button>
|
|
64
|
+
|
|
65
|
+
{isExpanded && view.hasBody && (
|
|
66
|
+
<div className="my-1.5 overflow-hidden rounded-md border border-dashed border-ink/15 px-3 py-2.5 space-y-3 code-surface">
|
|
67
|
+
<ToolBody tool={tool} view={view} />
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `trace` style — a vertical rail per section, one node per call.
|
|
8
|
+
*
|
|
9
|
+
* The section draws the rail; a row draws its own node, its line, and — when
|
|
10
|
+
* opened — its body in place under that node. Modelled on the step cards Cursor
|
|
11
|
+
* and Devin use, and on shadcn's `Trace` primitives.
|
|
12
|
+
*
|
|
13
|
+
* The rail is `aria-hidden`: it is a drawing of order, and the order is already
|
|
14
|
+
* the DOM order a screen reader walks. The node's tone is the status, so a
|
|
15
|
+
* failed step is visible without opening anything.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
19
|
+
import { memo } from 'preact/compat';
|
|
20
|
+
import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
|
|
21
|
+
import { ToolFactChips } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips';
|
|
22
|
+
import { toolStatusGlyph, STATUS_TONE_CLASS } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph';
|
|
23
|
+
import { useToolView } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view';
|
|
24
|
+
import { toolToggleLabel } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label';
|
|
25
|
+
import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
|
|
26
|
+
|
|
27
|
+
export const TraceRow = memo(function TraceRow({ tool, isOpen, onToggle, defaultExpanded = false }: ToolRowProps) {
|
|
28
|
+
const view = useToolView(tool);
|
|
29
|
+
const [internalOpen, setInternalOpen] = useState(defaultExpanded);
|
|
30
|
+
const isExpanded = view.alwaysExpanded || (isOpen ?? internalOpen);
|
|
31
|
+
const status = toolStatusGlyph(tool);
|
|
32
|
+
|
|
33
|
+
const handleToggle = useCallback(() => {
|
|
34
|
+
if (onToggle) onToggle(tool.id);
|
|
35
|
+
else setInternalOpen((prev) => !prev);
|
|
36
|
+
}, [onToggle, tool.id]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="relative pl-4" data-tool-row="trace">
|
|
40
|
+
{/* The node, drawn ON the section's rail. `-left-px` centres it on the
|
|
41
|
+
1px line the section owns. */}
|
|
42
|
+
<span
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
className={`absolute left-0 top-[9px] flex h-2 w-2 items-center justify-center rounded-full ${
|
|
45
|
+
status.tone === 'error' ? 'bg-error' : status.tone === 'ok' ? 'bg-ink/45' : 'bg-ink/20'
|
|
46
|
+
}`}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
onClick={handleToggle}
|
|
52
|
+
disabled={!view.hasBody || view.alwaysExpanded}
|
|
53
|
+
aria-expanded={isExpanded}
|
|
54
|
+
aria-label={view.hasBody && !view.alwaysExpanded ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined}
|
|
55
|
+
className={`flex w-full flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md px-1.5 py-1 text-left transition-colors ${
|
|
56
|
+
view.hasBody && !view.alwaysExpanded ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
|
|
57
|
+
} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
|
|
58
|
+
>
|
|
59
|
+
<span className={`shrink-0 self-center ${STATUS_TONE_CLASS[status.tone]}`} aria-hidden="true">
|
|
60
|
+
{status.glyph}
|
|
61
|
+
</span>
|
|
62
|
+
<span className="sr-only">{status.word}</span>
|
|
63
|
+
<span className="shrink-0 text-[12px] font-semibold tracking-tight text-ink">{view.header.title}</span>
|
|
64
|
+
{/* Subject + facts in ONE clipping row, the way the card's meta line
|
|
65
|
+
draws it: without the clip a long chip pair widened the section past
|
|
66
|
+
the phone viewport (measured at 390: 455 scrollWidth against 362). */}
|
|
67
|
+
<span className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
|
|
68
|
+
<span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/45">{view.subtitle}</span>
|
|
69
|
+
{view.summary && view.summary.facts.length > 0 && (
|
|
70
|
+
<span className="shrink-0">
|
|
71
|
+
<ToolFactChips facts={view.summary.facts} max={2} />
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
</span>
|
|
75
|
+
</button>
|
|
76
|
+
|
|
77
|
+
{isExpanded && view.hasBody && (
|
|
78
|
+
<div className="mb-1 ml-[3.5px] overflow-hidden border-l border-ink/10 py-2 pl-3 space-y-3 code-surface">
|
|
79
|
+
<ToolBody tool={tool} view={view} />
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What every tool render style receives.
|
|
8
|
+
*
|
|
9
|
+
* Openness is owned by `useToolOpenState` in the section (it is persisted per
|
|
10
|
+
* session), so a style only draws what it is given. `defaultExpanded` and the
|
|
11
|
+
* internal-state fallback exist for a direct mount (a test, a plugin preview),
|
|
12
|
+
* the way `ToolCardShell` has them.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ToolCallData } from '@/shared/types';
|
|
16
|
+
|
|
17
|
+
export interface ToolRowProps {
|
|
18
|
+
tool: ToolCallData;
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
onToggle?: (toolId: string) => void;
|
|
21
|
+
defaultExpanded?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The four render styles, mounted through the real section.
|
|
8
|
+
*
|
|
9
|
+
* What is asserted is the CONTRACT every style shares, because that is what the
|
|
10
|
+
* user was promised when the setting was offered:
|
|
11
|
+
*
|
|
12
|
+
* - the same row count and the same titles, whatever the style;
|
|
13
|
+
* - a collapsed row names its tool and its subject in the expand control's
|
|
14
|
+
* `aria-label` (`chat.e2e.ts` collects `[aria-label^="Expand "]`, and
|
|
15
|
+
* `mobile.e2e.ts` clicks `/^Expand Bash/`);
|
|
16
|
+
* - a failed call is visually distinct from a successful one WITHOUT opening it
|
|
17
|
+
* — the reason the card had a status badge at all;
|
|
18
|
+
* - opening a row renders the same body the card would, and the body is
|
|
19
|
+
* suppressed again on close.
|
|
20
|
+
*
|
|
21
|
+
* The style comes from `toolRenderStyle` in the primed settings blob, so these
|
|
22
|
+
* mounts exercise the real read path rather than a prop.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
26
|
+
import { Window } from 'happy-dom';
|
|
27
|
+
import { h, render } from 'preact';
|
|
28
|
+
import { act } from 'preact/test-utils';
|
|
29
|
+
import { ToolCallingSection } from '@/client/components/workspace/chat-timeline/ToolCallingSection';
|
|
30
|
+
import { SessionStateProvider } from '@/client/components/common/session-state-provider';
|
|
31
|
+
import { primeKabmoSettings } from '@/shared/lib/settings/client';
|
|
32
|
+
import { applyToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
33
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
34
|
+
import type { ToolCallData } from '@/shared/types/chat';
|
|
35
|
+
|
|
36
|
+
let container: HTMLElement;
|
|
37
|
+
|
|
38
|
+
beforeAll(() => installDomGlobals(new Window({ url: 'http://localhost' })));
|
|
39
|
+
afterAll(() => restoreDomGlobals());
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
43
|
+
container = document.createElement('div');
|
|
44
|
+
document.body.appendChild(container);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
render(null, container);
|
|
49
|
+
container.remove();
|
|
50
|
+
restoreDomGlobals();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const OK_TOOL: ToolCallData = {
|
|
54
|
+
id: 't1',
|
|
55
|
+
type: 'bash',
|
|
56
|
+
name: 'bash',
|
|
57
|
+
title: 'Bash',
|
|
58
|
+
status: 'success',
|
|
59
|
+
command: 'bun test',
|
|
60
|
+
detail: 'bun test',
|
|
61
|
+
output: 'UNIQUE_OUTPUT_TOKEN_42',
|
|
62
|
+
intent: 'Running the suite',
|
|
63
|
+
} as ToolCallData;
|
|
64
|
+
|
|
65
|
+
const FAILED_TOOL: ToolCallData = {
|
|
66
|
+
id: 't2',
|
|
67
|
+
type: 'bash',
|
|
68
|
+
name: 'bash',
|
|
69
|
+
title: 'Bash',
|
|
70
|
+
status: 'error',
|
|
71
|
+
command: 'bun test',
|
|
72
|
+
detail: 'bun test',
|
|
73
|
+
output: 'boom',
|
|
74
|
+
} as ToolCallData;
|
|
75
|
+
|
|
76
|
+
async function mount(tools: ToolCallData[], style: string): Promise<HTMLElement> {
|
|
77
|
+
primeKabmoSettings({ kabmo_settings: { toolRenderStyle: style } });
|
|
78
|
+
await act(async () => {
|
|
79
|
+
render(
|
|
80
|
+
h(SessionStateProvider, {
|
|
81
|
+
sessionId: `test-${style}`,
|
|
82
|
+
children: h(ToolCallingSection, { tools }),
|
|
83
|
+
}),
|
|
84
|
+
container,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
return container;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Every row, whichever style drew it. */
|
|
91
|
+
function rows(el: HTMLElement): HTMLElement[] {
|
|
92
|
+
return Array.from(el.querySelectorAll('[data-tool-row]')) as HTMLElement[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function toggle(el: HTMLElement): HTMLElement {
|
|
96
|
+
return el.querySelector('[aria-label^="Expand "], [aria-label^="Collapse "]') as HTMLElement;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
describe.each(['card', 'compact', 'trace', 'minimal'])('tool render style: %s', (style) => {
|
|
100
|
+
test('draws one row per call and names it', async () => {
|
|
101
|
+
const el = await mount([OK_TOOL], style);
|
|
102
|
+
expect(el.querySelector('[data-tool-section]')?.getAttribute('data-tool-style')).toBe(style);
|
|
103
|
+
expect(rows(el)).toHaveLength(1);
|
|
104
|
+
expect(toggle(el).getAttribute('aria-label')).toBe('Expand Bash — bun test');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('keeps the per-card intent heading', async () => {
|
|
108
|
+
const el = await mount([OK_TOOL], style);
|
|
109
|
+
expect(el.textContent).toContain('Running the suite');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('opens the same body on click and closes it again', async () => {
|
|
113
|
+
const el = await mount([OK_TOOL], style);
|
|
114
|
+
expect(el.querySelector('.code-surface')).toBeNull();
|
|
115
|
+
|
|
116
|
+
await act(async () => {
|
|
117
|
+
toggle(el).click();
|
|
118
|
+
});
|
|
119
|
+
expect(el.querySelector('.code-surface')).not.toBeNull();
|
|
120
|
+
expect(toggle(el).getAttribute('aria-label')).toBe('Collapse Bash — bun test');
|
|
121
|
+
|
|
122
|
+
await act(async () => {
|
|
123
|
+
toggle(el).click();
|
|
124
|
+
});
|
|
125
|
+
expect(el.querySelector('.code-surface')).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('marks a failed call without opening it', async () => {
|
|
129
|
+
const el = await mount([FAILED_TOOL], style);
|
|
130
|
+
// The card spells it as a badge, the line styles as a glyph with a word for
|
|
131
|
+
// screen readers — both say it, and neither needs the body open.
|
|
132
|
+
expect(el.textContent?.toLowerCase()).toContain('fail');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('a style change reaches a mounted section', () => {
|
|
137
|
+
test('the section re-renders in the announced style', async () => {
|
|
138
|
+
const el = await mount([OK_TOOL], 'card');
|
|
139
|
+
expect(el.querySelector('[data-tool-style]')?.getAttribute('data-tool-style')).toBe('card');
|
|
140
|
+
|
|
141
|
+
await act(async () => {
|
|
142
|
+
applyToolRenderMode('trace');
|
|
143
|
+
});
|
|
144
|
+
expect(el.querySelector('[data-tool-style]')?.getAttribute('data-tool-style')).toBe('trace');
|
|
145
|
+
|
|
146
|
+
await act(async () => {
|
|
147
|
+
applyToolRenderMode('not-a-style');
|
|
148
|
+
});
|
|
149
|
+
// A value this build cannot draw falls back to the default, never to a
|
|
150
|
+
// style that has no renderer.
|
|
151
|
+
expect(el.querySelector('[data-tool-style]')?.getAttribute('data-tool-style')).toBe('card');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
import type { EditorState, Extension, Line } from '@codemirror/state';
|
|
35
|
-
import { bracketMatching, foldGutter, foldKeymap, foldService } from '@codemirror/language';
|
|
35
|
+
import { bracketMatching, codeFolding, foldGutter, foldKeymap, foldService } from '@codemirror/language';
|
|
36
36
|
import { keymap } from '@codemirror/view';
|
|
37
37
|
|
|
38
38
|
import { bracketGuide } from '@/client/components/common/code-surface/bracket-guide';
|
|
39
|
+
import { foldPlaceholderDom } from '@/client/components/common/code-surface/fold-placeholder';
|
|
39
40
|
import { indentFoldService, MAX_FOLD_LINES } from '@/client/components/common/code-surface/fold';
|
|
40
41
|
|
|
41
42
|
/** The brackets a line may open, and what closes each. */
|
|
@@ -130,5 +131,9 @@ export const diffFoldingExtensions: Extension[] = [
|
|
|
130
131
|
braceFoldService,
|
|
131
132
|
indentFoldService,
|
|
132
133
|
foldGutter(),
|
|
134
|
+
// The package placeholder is lost to the editor's mouse selection on WebKit;
|
|
135
|
+
// `foldPlaceholderDom` cancels the press so the click survives. Listed after
|
|
136
|
+
// `foldGutter()` because a later `codeFolding()` config wins the merge.
|
|
137
|
+
codeFolding({ placeholderDOM: foldPlaceholderDom }),
|
|
133
138
|
keymap.of(foldKeymap),
|
|
134
139
|
];
|
|
@@ -36,10 +36,24 @@ export function SvgPreview({ content, name }: SvgPreviewProps) {
|
|
|
36
36
|
{/* A checkerboard would be wrong here: an SVG is normally opaque or
|
|
37
37
|
intended to sit on a surface, and the panel's paper is that surface.
|
|
38
38
|
The SVG scales to the container via the CSS below rather than a
|
|
39
|
-
measured size, so no layout pass is needed.
|
|
39
|
+
measured size, so no layout pass is needed.
|
|
40
|
+
|
|
41
|
+
`w-full` on the wrapper is load-bearing, not cosmetic. A flex item is
|
|
42
|
+
shrink-to-fit, and an SVG that carries only a `viewBox` — no `width`
|
|
43
|
+
or `height` attributes, which is how most icon SVGs ship — defaults to
|
|
44
|
+
`width:100%` of its containing block. With no definite width above it,
|
|
45
|
+
that resolves against itself and the picture collapses to a 0x0 box:
|
|
46
|
+
the markup is in the DOM and nothing is drawn. The wrapper takes the
|
|
47
|
+
row's width, and the SVG then fills it, keeping its aspect ratio and
|
|
48
|
+
capped by `max-h`.
|
|
49
|
+
|
|
50
|
+
`mx-auto` pays for that width: an SVG that DOES declare its own size
|
|
51
|
+
is narrower than the wrapper, and the row's `justify-center` no longer
|
|
52
|
+
reaches it through a full-width child. It is a no-op for the filling
|
|
53
|
+
case above. */}
|
|
40
54
|
<div className="flex min-h-full items-center justify-center p-6">
|
|
41
55
|
<div
|
|
42
|
-
className="svg-preview max-w-full [&>svg]:h-auto [&>svg]:max-h-[80vh] [&>svg]:w-auto [&>svg]:max-w-full"
|
|
56
|
+
className="svg-preview w-full max-w-full [&>svg]:mx-auto [&>svg]:block [&>svg]:h-auto [&>svg]:max-h-[80vh] [&>svg]:w-auto [&>svg]:max-w-full"
|
|
43
57
|
role="img"
|
|
44
58
|
aria-label={name}
|
|
45
59
|
dangerouslySetInnerHTML={{ __html: safeSvg }}
|