@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
|
@@ -1,32 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The thinking accordion, drawn in the same style as the tool rows around it.
|
|
8
|
+
*
|
|
9
|
+
* It used to spell the tool card's frame out itself, so `toolRenderStyle`
|
|
10
|
+
* reached the tool blocks and left thinking sitting in the old card — a setting
|
|
11
|
+
* that half applied. The frame, the header row and the body container now come
|
|
12
|
+
* from `blockChrome` (`shared/lib/chat/timeline/block-chrome.ts`), the one
|
|
13
|
+
* place that states them per style.
|
|
14
|
+
*
|
|
15
|
+
* What is NOT shared, deliberately: this block's own rules. A generating run
|
|
16
|
+
* opens itself, the body follows the tail while it streams, and a notice
|
|
17
|
+
* embedded in the thought renders as its own inset — behaviour that belongs to
|
|
18
|
+
* thinking and to nothing else.
|
|
19
|
+
*
|
|
20
|
+
* The toggle carries `aria-expanded` and no `aria-label`, as it always has:
|
|
21
|
+
* `chat.e2e.ts` collects `[aria-label^="Expand "]` and requires every entry to
|
|
22
|
+
* name a TOOL, so a second block spelling its control that way would be read as
|
|
23
|
+
* a tool card with a title of "Thinking".
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
2
27
|
import { BrainCircuit, ChevronDown, Sparkles } from 'lucide-preact';
|
|
3
28
|
import type { ThinkingData } from '@/shared/types';
|
|
4
29
|
import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
|
|
5
30
|
import { CopyButton } from '@/client/components/common/CopyButton';
|
|
6
31
|
import { transcriptGutter } from '@/shared/lib/chat/timeline/gutter';
|
|
32
|
+
import { blockChrome, traceInset } from '@/shared/lib/chat/timeline/block-chrome';
|
|
33
|
+
import { useToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
34
|
+
import { useThinkingOpenState } from '@/client/hooks/chat/timeline/thinking-open';
|
|
7
35
|
|
|
8
36
|
interface ThinkingSectionProps {
|
|
9
37
|
thinking: ThinkingData | string;
|
|
38
|
+
/**
|
|
39
|
+
* The row this block belongs to, and the key its open state is stored under.
|
|
40
|
+
* Optional: a block mounted outside a timeline still toggles, it just cannot
|
|
41
|
+
* remember the choice across the row being unmounted (see `thinking-open`).
|
|
42
|
+
*/
|
|
43
|
+
messageId?: string;
|
|
10
44
|
defaultExpanded?: boolean;
|
|
11
45
|
showSeparator?: boolean;
|
|
12
46
|
/** Phone layout: the section's frame is the timeline gutter itself. */
|
|
13
47
|
isMobile?: boolean;
|
|
14
48
|
}
|
|
15
49
|
|
|
16
|
-
export function ThinkingSection({
|
|
17
|
-
thinking,
|
|
50
|
+
export function ThinkingSection({
|
|
51
|
+
thinking,
|
|
52
|
+
messageId,
|
|
18
53
|
defaultExpanded = false,
|
|
19
54
|
showSeparator = false,
|
|
20
55
|
isMobile = false,
|
|
21
56
|
}: ThinkingSectionProps) {
|
|
57
|
+
const mode = useToolRenderMode();
|
|
58
|
+
const chrome = blockChrome(mode);
|
|
59
|
+
const framed = mode === 'card';
|
|
60
|
+
|
|
22
61
|
const isGenerating = typeof thinking === 'object' ? Boolean(thinking.isGenerating) : false;
|
|
23
|
-
const
|
|
62
|
+
const { isOpen, toggle: toggleOpen } = useThinkingOpenState(messageId, defaultExpanded, isGenerating);
|
|
24
63
|
const thoughtBodyRef = useRef<HTMLDivElement>(null);
|
|
25
64
|
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (isGenerating) setIsOpen(true);
|
|
28
|
-
}, [isGenerating]);
|
|
29
|
-
|
|
30
65
|
const thoughtText = typeof thinking === 'string' ? thinking : thinking.thought || '';
|
|
31
66
|
const noticeMatch = thoughtText.match(/<system-notice[^>]*>([\s\S]*?)<\/system-notice>/);
|
|
32
67
|
const noticeText = noticeMatch?.[1]?.trim() ?? '';
|
|
@@ -42,92 +77,99 @@ export function ThinkingSection({
|
|
|
42
77
|
if (el) el.scrollTop = el.scrollHeight;
|
|
43
78
|
}, [isOpen, cleanThought, isGenerating]);
|
|
44
79
|
|
|
45
|
-
const toggleOpen = () => setIsOpen(prev => !prev);
|
|
46
|
-
|
|
47
80
|
if (!cleanThought) return null;
|
|
81
|
+
const iconTone = framed ? 'bg-ink/5 text-ink/70' : 'text-ink/40';
|
|
48
82
|
|
|
49
83
|
return (
|
|
50
84
|
<div className={`${transcriptGutter(isMobile)} ${showSeparator ? 'space-y-1.5' : ''}`}>
|
|
51
85
|
{showSeparator && (
|
|
52
|
-
<div className=
|
|
86
|
+
<div className={`flex items-center gap-2 px-1 pt-0.5 ${traceInset(mode, isMobile)}`}>
|
|
53
87
|
<span className="text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35">
|
|
54
88
|
Thinking
|
|
55
89
|
</span>
|
|
56
90
|
<span className="h-px flex-1 bg-ink/8" />
|
|
57
91
|
</div>
|
|
58
92
|
)}
|
|
59
|
-
<div className=
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
className=
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{!isOpen && summary && (
|
|
75
|
-
<span className="truncate font-mono text-[10.5px] text-ink/45">{summary}</span>
|
|
76
|
-
)}
|
|
77
|
-
</span>
|
|
78
|
-
{duration && (
|
|
79
|
-
<span className="shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50">
|
|
80
|
-
{duration}
|
|
81
|
-
</span>
|
|
82
|
-
)}
|
|
83
|
-
<ChevronDown
|
|
84
|
-
size={14}
|
|
85
|
-
className={`shrink-0 text-ink/35 transition-transform duration-200 ${isOpen ? 'rotate-180' : ''}`}
|
|
86
|
-
/>
|
|
87
|
-
</button>
|
|
88
|
-
|
|
89
|
-
{isOpen && (
|
|
90
|
-
<div className="border-t border-ink/8 bg-canvas/40 px-3 py-3">
|
|
91
|
-
<div className="flex items-center justify-between pb-1.5">
|
|
92
|
-
<span className="text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40">
|
|
93
|
-
Model Reasoning & Strategy
|
|
93
|
+
<div className={chrome.root || undefined}>
|
|
94
|
+
{/* The rail is drawn once per TURN by `TurnRail`; this block only places
|
|
95
|
+
its node. `trace` is the one style with a node. */}
|
|
96
|
+
{mode === 'trace' && <span aria-hidden="true" className={chrome.node} />}
|
|
97
|
+
<div className={chrome.frame || undefined}>
|
|
98
|
+
<button
|
|
99
|
+
type="button"
|
|
100
|
+
onClick={toggleOpen}
|
|
101
|
+
aria-expanded={isOpen}
|
|
102
|
+
className={`${chrome.header} cursor-pointer select-none ${
|
|
103
|
+
framed ? 'hover:bg-ink/[0.03]' : 'hover:bg-ink/[0.03] rounded-md'
|
|
104
|
+
} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
|
|
105
|
+
>
|
|
106
|
+
<span className={`${chrome.icon} ${iconTone}`}>
|
|
107
|
+
<Sparkles size={13} />
|
|
94
108
|
</span>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
className="
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
<span className="flex min-w-0 flex-1 items-center gap-1.5">
|
|
110
|
+
<span className={chrome.title}>Thinking</span>
|
|
111
|
+
{isGenerating && <span className="h-1.5 w-1.5 rounded-full bg-ink/60 animate-pulse" />}
|
|
112
|
+
{!isOpen && (
|
|
113
|
+
<>
|
|
114
|
+
{!framed && <span className="text-ink/25">—</span>}
|
|
115
|
+
<span className={`${chrome.subtitle} ${framed ? '' : 'flex-1'}`}>{summary}</span>
|
|
116
|
+
</>
|
|
117
|
+
)}
|
|
118
|
+
</span>
|
|
119
|
+
{duration && (
|
|
120
|
+
<span className="shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50">
|
|
121
|
+
{duration}
|
|
122
|
+
</span>
|
|
123
|
+
)}
|
|
124
|
+
<ChevronDown
|
|
125
|
+
size={14}
|
|
126
|
+
className={`shrink-0 text-ink/35 transition-transform duration-200 ${isOpen ? 'rotate-180' : ''}`}
|
|
101
127
|
/>
|
|
102
|
-
</
|
|
128
|
+
</button>
|
|
103
129
|
|
|
104
|
-
{
|
|
105
|
-
<div className=
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
{isOpen && (
|
|
131
|
+
<div className={chrome.body}>
|
|
132
|
+
<div className="flex items-center justify-between pb-1.5">
|
|
133
|
+
<span className="text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40">
|
|
134
|
+
Model Reasoning & Strategy
|
|
135
|
+
</span>
|
|
136
|
+
<CopyButton
|
|
137
|
+
text={cleanThought}
|
|
138
|
+
className="flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink"
|
|
139
|
+
title="Copy thinking"
|
|
140
|
+
wrapLabel
|
|
141
|
+
label="Copy"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{noticeText && (
|
|
146
|
+
<div className="mb-2 flex items-start gap-2.5 rounded-lg border border-ink/15 bg-paper px-3 py-2.5">
|
|
147
|
+
<span className="mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink/10">
|
|
148
|
+
<BrainCircuit size={13} className="text-ink/70" />
|
|
149
|
+
</span>
|
|
150
|
+
<div className="min-w-0 flex-1">
|
|
151
|
+
<div className="mb-0.5 text-[9.5px] font-semibold uppercase tracking-[0.12em] text-ink/50">
|
|
152
|
+
System Notice
|
|
153
|
+
</div>
|
|
154
|
+
<div className="text-[12px] leading-relaxed text-ink/85">
|
|
155
|
+
<MarkdownRenderer content={noticeText} className="text-[12px] text-ink/85 leading-relaxed" />
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
115
158
|
</div>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
<div
|
|
162
|
+
ref={thoughtBodyRef}
|
|
163
|
+
className="max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container select-text"
|
|
164
|
+
>
|
|
165
|
+
<MarkdownRenderer
|
|
166
|
+
content={cleanThought}
|
|
167
|
+
className="text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"
|
|
168
|
+
/>
|
|
116
169
|
</div>
|
|
117
170
|
</div>
|
|
118
171
|
)}
|
|
119
|
-
|
|
120
|
-
<div
|
|
121
|
-
ref={thoughtBodyRef}
|
|
122
|
-
className="max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container select-text"
|
|
123
|
-
>
|
|
124
|
-
<MarkdownRenderer
|
|
125
|
-
content={cleanThought}
|
|
126
|
-
className="text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
129
172
|
</div>
|
|
130
|
-
)}
|
|
131
173
|
</div>
|
|
132
174
|
</div>
|
|
133
175
|
);
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
* section's children are only headings and cards.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
25
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
26
26
|
import { Window } from 'happy-dom';
|
|
27
27
|
import { h, render } from 'preact';
|
|
28
28
|
import { act } from 'preact/test-utils';
|
|
29
29
|
import { ToolCallingSection } from '@/client/components/workspace/chat-timeline/ToolCallingSection';
|
|
30
30
|
import { SessionStateProvider } from '@/client/components/common/session-state-provider';
|
|
31
|
+
import { primeKabmoSettings } from '@/shared/lib/settings/client';
|
|
31
32
|
import type { ToolCallData } from '@/shared/types/chat';
|
|
32
33
|
|
|
33
34
|
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'Event', 'MouseEvent', 'KeyboardEvent'] as const;
|
|
@@ -51,6 +52,19 @@ afterAll(() => {
|
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The `card` style, pinned.
|
|
57
|
+
*
|
|
58
|
+
* The style is read from Kabmo's settings snapshot, which is PROCESS-wide and
|
|
59
|
+
* primed by whichever file ran last — `styles.test.tsx` leaves `trace` behind.
|
|
60
|
+
* Bun's file order differs per platform, so an unpinned run drew whatever the
|
|
61
|
+
* previous file had chosen: measured, this file passed on macOS and its three
|
|
62
|
+
* order assertions failed on Windows with the card rows missing entirely.
|
|
63
|
+
*/
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
primeKabmoSettings({ kabmo_settings: { toolRenderStyle: 'card' } });
|
|
66
|
+
});
|
|
67
|
+
|
|
54
68
|
function tool(id: string, intent: string | undefined, title = 'Bash'): ToolCallData {
|
|
55
69
|
return { id, type: 'bash', name: 'bash', title, intent, status: 'success', output: 'ok' } as ToolCallData;
|
|
56
70
|
}
|
|
@@ -73,17 +87,23 @@ async function mount(tools: ToolCallData[]) {
|
|
|
73
87
|
/**
|
|
74
88
|
* The section's direct children in render order: intent headings and their
|
|
75
89
|
* cards. A section renders nothing else.
|
|
90
|
+
*
|
|
91
|
+
* A card is found by `data-tool-row`, the contract every style sets, not by a
|
|
92
|
+
* substring of its Tailwind classes. The class form was measured failing on
|
|
93
|
+
* Windows: the same three assertions reported `Received: 0` cards, with the
|
|
94
|
+
* heading text still present, and the class string it looked for is assembled
|
|
95
|
+
* from a template that platform does not change — so the lookup was the
|
|
96
|
+
* fragile part, not the render.
|
|
76
97
|
*/
|
|
77
98
|
function sequence(el: HTMLElement): Array<{ kind: 'heading' | 'card'; text: string }> {
|
|
78
99
|
const section = el.querySelector('[data-tool-section]')!;
|
|
79
100
|
const items = Array.from(section.children).map((child) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
return { kind: 'card' as const, text: (col.children[0]?.textContent || '').trim() };
|
|
101
|
+
if (!(child instanceof HTMLElement) || !child.hasAttribute('data-tool-row')) {
|
|
102
|
+
const label = child.querySelector('span');
|
|
103
|
+
return { kind: 'heading' as const, text: label ? (label.textContent || '').trim() : '' };
|
|
84
104
|
}
|
|
85
|
-
const
|
|
86
|
-
return { kind: '
|
|
105
|
+
const col = child.querySelector('button')!.children[1];
|
|
106
|
+
return { kind: 'card' as const, text: (col.children[0]?.textContent || '').trim() };
|
|
87
107
|
});
|
|
88
108
|
return items.filter((item) => item.kind !== 'heading' || item.text);
|
|
89
109
|
}
|
|
@@ -111,7 +131,7 @@ describe('ToolCallingSection per-card intent heading', () => {
|
|
|
111
131
|
// No header row: every direct child is a card.
|
|
112
132
|
const children = Array.from(el.querySelector('[data-tool-section]')!.children) as HTMLElement[];
|
|
113
133
|
expect(children).toHaveLength(2);
|
|
114
|
-
expect(children.every((child) => child.
|
|
134
|
+
expect(children.every((child) => child.getAttribute('data-tool-row') === 'card')).toBe(true);
|
|
115
135
|
});
|
|
116
136
|
|
|
117
137
|
test('a card without an intent simply has no heading', async () => {
|
|
@@ -3,12 +3,37 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* A block of tool calls in the transcript, drawn in the style the user chose.
|
|
8
|
+
*
|
|
9
|
+
* The section owns three things and delegates the rest:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Normalization** — the MOCK/sample path carries `AgentActionData`, which
|
|
12
|
+
* is mapped onto `ToolCallData` so every style reads one shape.
|
|
13
|
+
* 2. **Openness** — persisted per session by `useToolOpenState`, so a reload or
|
|
14
|
+
* a history page-in does not close the call the reader opened.
|
|
15
|
+
* 3. **The intent heading** — one line above a call, naming what the call was
|
|
16
|
+
* for. It is drawn by the section, not by a style, so the four styles cannot
|
|
17
|
+
* disagree about it.
|
|
18
|
+
*
|
|
19
|
+
* The STYLE decides the frame: `card` draws `CardRow`, `compact` a status line,
|
|
20
|
+
* `trace` a rail node, `minimal` a faint line. Every style receives the same
|
|
21
|
+
* tool and the same openness, and each renders the shared `ToolBody`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
6
24
|
import { Fragment } from 'preact';
|
|
7
25
|
import { useMemo } from 'preact/hooks';
|
|
26
|
+
import type { FunctionComponent } from 'preact/compat';
|
|
8
27
|
import type { AgentActionData, ToolCallData, ToolType } from '@/shared/types';
|
|
9
|
-
import { ToolCallCard } from '@/client/components/workspace/chat-timeline/ToolCallCard';
|
|
10
28
|
import { useToolOpenState } from '@/client/hooks/chat/timeline/tool-open';
|
|
29
|
+
import { useToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
11
30
|
import { transcriptGutter } from '@/shared/lib/chat/timeline/gutter';
|
|
31
|
+
import type { ToolRenderMode } from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
32
|
+
import { CardRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Card';
|
|
33
|
+
import { CompactRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Compact';
|
|
34
|
+
import { TraceRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Trace';
|
|
35
|
+
import { MinimalRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal';
|
|
36
|
+
import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
|
|
12
37
|
|
|
13
38
|
interface ToolCallingSectionProps {
|
|
14
39
|
tools: (ToolCallData | AgentActionData)[];
|
|
@@ -17,6 +42,14 @@ interface ToolCallingSectionProps {
|
|
|
17
42
|
isMobile?: boolean;
|
|
18
43
|
}
|
|
19
44
|
|
|
45
|
+
/** One renderer per mode — a total map, so a new mode is a build error here. */
|
|
46
|
+
const ROW_BY_MODE: Record<ToolRenderMode, FunctionComponent<ToolRowProps>> = {
|
|
47
|
+
card: CardRow,
|
|
48
|
+
compact: CompactRow,
|
|
49
|
+
trace: TraceRow,
|
|
50
|
+
minimal: MinimalRow,
|
|
51
|
+
};
|
|
52
|
+
|
|
20
53
|
function normalizeToolData(action: ToolCallData | AgentActionData, index: number): ToolCallData {
|
|
21
54
|
if ('id' in action && action.id) {
|
|
22
55
|
return action as ToolCallData;
|
|
@@ -57,6 +90,9 @@ function normalizeToolData(action: ToolCallData | AgentActionData, index: number
|
|
|
57
90
|
}
|
|
58
91
|
|
|
59
92
|
export function ToolCallingSection({ tools, defaultExpanded = false, isMobile = false }: ToolCallingSectionProps) {
|
|
93
|
+
const mode = useToolRenderMode();
|
|
94
|
+
const Row = ROW_BY_MODE[mode];
|
|
95
|
+
|
|
60
96
|
const normalizedTools = useMemo(() => {
|
|
61
97
|
return (tools || []).map((t, i) => normalizeToolData(t, i));
|
|
62
98
|
}, [tools]);
|
|
@@ -68,13 +104,21 @@ export function ToolCallingSection({ tools, defaultExpanded = false, isMobile =
|
|
|
68
104
|
if (!normalizedTools || normalizedTools.length === 0) return null;
|
|
69
105
|
|
|
70
106
|
return (
|
|
71
|
-
<div
|
|
107
|
+
<div
|
|
108
|
+
className={`${transcriptGutter(isMobile)} ${mode === 'trace' ? 'relative' : 'space-y-1.5'}`}
|
|
109
|
+
data-tool-section
|
|
110
|
+
data-tool-style={mode}
|
|
111
|
+
>
|
|
112
|
+
{/* The rail itself is drawn ONCE per turn by `TurnRail` (see
|
|
113
|
+
`MessageItem`): a segment per section broke wherever prose sat between
|
|
114
|
+
two blocks, which is exactly what a trace may not do. A row still
|
|
115
|
+
places its own node. */}
|
|
72
116
|
{normalizedTools.map((tool) => {
|
|
73
117
|
const intent = tool.intent?.trim();
|
|
74
118
|
return (
|
|
75
119
|
<Fragment key={tool.id}>
|
|
76
120
|
{intent && (
|
|
77
|
-
<div className=
|
|
121
|
+
<div className={`flex items-center gap-2 px-1 pt-0.5 ${mode === 'trace' ? 'pl-4' : ''}`}>
|
|
78
122
|
{/* Label sizes to its text; the rule takes everything left over,
|
|
79
123
|
so the line runs to the panel edge the way `ThinkingSection`
|
|
80
124
|
draws it. The label is NOT `flex-1` — two `flex-1` items split
|
|
@@ -91,7 +135,7 @@ export function ToolCallingSection({ tools, defaultExpanded = false, isMobile =
|
|
|
91
135
|
<span className="h-px min-w-6 flex-1 bg-ink/8" />
|
|
92
136
|
</div>
|
|
93
137
|
)}
|
|
94
|
-
<
|
|
138
|
+
<Row
|
|
95
139
|
tool={tool}
|
|
96
140
|
isOpen={Boolean(openMap[tool.id])}
|
|
97
141
|
onToggle={toggle}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `trace` rail for ONE turn, drawn by the turn rather than by each block.
|
|
8
|
+
*
|
|
9
|
+
* The first shape gave every block (thinking, the tool section, a notice) its
|
|
10
|
+
* own segment sized to that block. Measured on the 39-call sample session in the
|
|
11
|
+
* browser, that produced three disconnected lines with real gaps between them:
|
|
12
|
+
*
|
|
13
|
+
* thinking -1390 → -1356 (34px)
|
|
14
|
+
* gap 256px ← the answer text in between
|
|
15
|
+
* tool section -1100 → 368 (1468px)
|
|
16
|
+
* gap 99px
|
|
17
|
+
* notice 467 → 512 (45px)
|
|
18
|
+
*
|
|
19
|
+
* A rail whose whole job is to say "these steps are one sequence" cannot break
|
|
20
|
+
* wherever prose happens to sit between them, so the line belongs to the
|
|
21
|
+
* container that holds them all and each block only places its NODE on it.
|
|
22
|
+
*
|
|
23
|
+
* The horizontal origin is the blocks' own gutter: every block is inset by
|
|
24
|
+
* `transcriptGutter` (12px on desktop, 0 on a phone) and puts its node at its
|
|
25
|
+
* own `left-0`, so the rail sits at `gutter + 3.5px` — measured `rail 315 /
|
|
26
|
+
* node 315` for thinking, a notice and a tool row alike.
|
|
27
|
+
*
|
|
28
|
+
* Rendered only when the turn actually has a trace block; a line drawn beside a
|
|
29
|
+
* plain answer would claim a sequence that is not there.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
interface TurnRailProps {
|
|
33
|
+
/** The turn has at least one block that draws a node. */
|
|
34
|
+
visible: boolean;
|
|
35
|
+
isMobile: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function TurnRail({ visible, isMobile }: TurnRailProps) {
|
|
39
|
+
if (!visible) return null;
|
|
40
|
+
return (
|
|
41
|
+
<span
|
|
42
|
+
aria-hidden="true"
|
|
43
|
+
data-turn-rail
|
|
44
|
+
// The line spans the run, so it starts a little above the first node and
|
|
45
|
+
// ends a little below the last (the row's own margin plus the node's 9px
|
|
46
|
+
// offset — measured 21px / 32px). Both ends taper, so the rail reads as the
|
|
47
|
+
// run's column rather than a bar with cut ends.
|
|
48
|
+
//
|
|
49
|
+
// The taper is an INLINE style, not `[mask-image:…]`: an arbitrary-value
|
|
50
|
+
// class only exists if the CSS generator emitted that exact string, and
|
|
51
|
+
// measured in the browser the computed `mask-image` was `none` — the class
|
|
52
|
+
// was in the bundle but the dev asset serving the page had not been
|
|
53
|
+
// regenerated, which is the silent failure mode the wiki records for
|
|
54
|
+
// arbitrary classes (a missing rule fails without an error).
|
|
55
|
+
style={{
|
|
56
|
+
maskImage: 'linear-gradient(to bottom, transparent 0, black 10px, black calc(100% - 10px), transparent 100%)',
|
|
57
|
+
WebkitMaskImage: 'linear-gradient(to bottom, transparent 0, black 10px, black calc(100% - 10px), transparent 100%)',
|
|
58
|
+
}}
|
|
59
|
+
className={`pointer-events-none absolute top-0 bottom-0 w-px bg-ink/15 ${
|
|
60
|
+
isMobile ? 'left-[3.5px]' : 'left-[15.5px]'
|
|
61
|
+
}`}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Every transcript block wears the frame of the chosen style — not just the
|
|
8
|
+
* tool rows.
|
|
9
|
+
*
|
|
10
|
+
* The defect this pins: `toolRenderStyle` reached `ToolCallingSection` only, so
|
|
11
|
+
* a user on `compact` got compact tool rows sandwiched between a thinking card
|
|
12
|
+
* and a notice card in the old frame. A setting that half applies is a setting
|
|
13
|
+
* that reads as broken, and the fix is structural — one `blockChrome` table
|
|
14
|
+
* consulted by every block.
|
|
15
|
+
*
|
|
16
|
+
* Mounted against happy-dom and read from RENDERED markup, because the classes
|
|
17
|
+
* were right in the table while a component still spelled its own frame out.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { Window } from 'happy-dom';
|
|
22
|
+
import { h, render } from 'preact';
|
|
23
|
+
import { act } from 'preact/test-utils';
|
|
24
|
+
import { ThinkingSection } from '@/client/components/workspace/chat-timeline/ThinkingSection';
|
|
25
|
+
import { SystemNotice } from '@/client/components/workspace/chat-timeline/SystemNotice';
|
|
26
|
+
import { SessionStateProvider } from '@/client/components/common/session-state-provider';
|
|
27
|
+
import { primeKabmoSettings } from '@/shared/lib/settings/client';
|
|
28
|
+
import { applyToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
29
|
+
import { blockChrome } from '@/shared/lib/chat/timeline/block-chrome';
|
|
30
|
+
import { forgetSession } from '@/shared/lib/workspace/session-state/store';
|
|
31
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
32
|
+
|
|
33
|
+
let container: HTMLElement;
|
|
34
|
+
/** The runner's own fetch, so a leaked stub cannot be mistaken for it. */
|
|
35
|
+
const nativeFetch = Bun.fetch;
|
|
36
|
+
/** A pending id: the provider loads it like any other and nothing is stored. */
|
|
37
|
+
const SESSION = 'spec-block-chrome';
|
|
38
|
+
|
|
39
|
+
beforeAll(() => installDomGlobals(new Window({ url: 'http://localhost' })));
|
|
40
|
+
afterAll(() => restoreDomGlobals());
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
// The DOM globals are installed ONCE for the file (beforeAll): swapping
|
|
44
|
+
// them per test churns `window`/`Event` for every other suite sharing the
|
|
45
|
+
// process, which made a later file register its hooks after the run had
|
|
46
|
+
// completed (`Cannot call beforeEach() after the test run has completed`).
|
|
47
|
+
container = document.createElement('div');
|
|
48
|
+
document.body.appendChild(container);
|
|
49
|
+
// The blocks remember their openness per session, so the provider they are
|
|
50
|
+
// mounted under asks for this session's blob.
|
|
51
|
+
(globalThis as unknown as Record<string, unknown>).fetch = async () =>
|
|
52
|
+
new Response(JSON.stringify({ sessionId: SESSION, state: {} }), {
|
|
53
|
+
status: 200,
|
|
54
|
+
headers: { 'content-type': 'application/json' },
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
render(null, container);
|
|
60
|
+
container.remove();
|
|
61
|
+
forgetSession(SESSION);
|
|
62
|
+
(globalThis as unknown as Record<string, unknown>).fetch = nativeFetch;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** A thought long enough that the block renders (an empty one renders nothing). */
|
|
66
|
+
const THOUGHT = { thought: 'Read the summary module, then patch the header row.', duration: '1.2s' };
|
|
67
|
+
/** A multi-line notice: single-line notices have nothing to expand. */
|
|
68
|
+
const NOTICE = 'Line one\nLine two';
|
|
69
|
+
const MULTI_LINE_NOTICE = NOTICE;
|
|
70
|
+
|
|
71
|
+
async function paint(style: string, node: preact.ComponentChildren): Promise<HTMLElement> {
|
|
72
|
+
// Unmount first: preact reuses the instance for a same-type vnode, so a
|
|
73
|
+
// mounted hook keeps the mode it read on its FIRST render and a second
|
|
74
|
+
// paint would assert against the previous style.
|
|
75
|
+
render(null, container);
|
|
76
|
+
primeKabmoSettings({ kabmo_settings: { toolRenderStyle: style } });
|
|
77
|
+
// The blocks remember their openness per session (`useToolOpenState`,
|
|
78
|
+
// `useThinkingOpenState`), so they are mounted the way the timeline mounts
|
|
79
|
+
// them: inside the provider.
|
|
80
|
+
await act(async () => {
|
|
81
|
+
render(h(SessionStateProvider, { sessionId: SESSION, children: node }) as never, container);
|
|
82
|
+
});
|
|
83
|
+
// The provider's blob load settles across a tick.
|
|
84
|
+
for (let i = 0; i < 4; i += 1) await act(async () => {});
|
|
85
|
+
return container;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
describe('blockChrome', () => {
|
|
89
|
+
test('only the card style has a frame', () => {
|
|
90
|
+
expect(blockChrome('card').frame).toContain('rounded-xl');
|
|
91
|
+
expect(blockChrome('card').frame).toContain('border-ink/10');
|
|
92
|
+
for (const mode of ['compact', 'trace', 'minimal'] as const) {
|
|
93
|
+
expect(blockChrome(mode).frame).toBe('');
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('only the trace style places a node, and it is the only one with a relative root', () => {
|
|
98
|
+
expect(blockChrome('trace').node).toBeDefined();
|
|
99
|
+
expect(blockChrome('trace').root).toContain('relative');
|
|
100
|
+
expect(blockChrome('compact').node).toBeUndefined();
|
|
101
|
+
expect(blockChrome('card').node).toBeUndefined();
|
|
102
|
+
expect(blockChrome('minimal').node).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('the minimal style is the smallest type, the frame styles the largest', () => {
|
|
106
|
+
expect(blockChrome('minimal').title).toContain('text-[11.5px]');
|
|
107
|
+
expect(blockChrome('card').title).toContain('text-[12px]');
|
|
108
|
+
expect(blockChrome('card').header).toContain('px-3 py-2.5');
|
|
109
|
+
expect(blockChrome('compact').header).toContain('py-1');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('thinking follows the render style', () => {
|
|
114
|
+
test('the card frame is present on card, absent on every line style', async () => {
|
|
115
|
+
const card = await paint('card', h(ThinkingSection, { thinking: THOUGHT }));
|
|
116
|
+
expect(card.innerHTML).toContain('rounded-xl');
|
|
117
|
+
|
|
118
|
+
for (const style of ['compact', 'trace', 'minimal']) {
|
|
119
|
+
const el = await paint(style, h(ThinkingSection, { thinking: THOUGHT }));
|
|
120
|
+
expect(el.innerHTML).not.toContain('rounded-xl');
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('trace places a NODE on the turn rail; the other styles place none', async () => {
|
|
125
|
+
const trace = await paint('trace', h(ThinkingSection, { thinking: THOUGHT }));
|
|
126
|
+
const marks = Array.from(trace.querySelectorAll('[aria-hidden="true"]')) as HTMLElement[];
|
|
127
|
+
// The block contributes its node only — the LINE is the turn's (TurnRail),
|
|
128
|
+
// because a per-block segment broke wherever prose sat between blocks.
|
|
129
|
+
expect(marks.some((el) => el.className.includes('rounded-full'))).toBe(true);
|
|
130
|
+
expect(marks.some((el) => el.className.includes('w-px'))).toBe(false);
|
|
131
|
+
|
|
132
|
+
const compact = await paint('compact', h(ThinkingSection, { thinking: THOUGHT }));
|
|
133
|
+
const compactMarks = Array.from(compact.querySelectorAll('[aria-hidden="true"]')) as HTMLElement[];
|
|
134
|
+
expect(compactMarks.some((el) => el.className.includes('rounded-full'))).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('a style change reaches a mounted thinking block', async () => {
|
|
138
|
+
await paint('card', h(ThinkingSection, { thinking: THOUGHT }));
|
|
139
|
+
expect(container.innerHTML).toContain('rounded-xl');
|
|
140
|
+
|
|
141
|
+
await act(async () => applyToolRenderMode('minimal'));
|
|
142
|
+
expect(container.innerHTML).not.toContain('rounded-xl');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('system notice follows the render style', () => {
|
|
147
|
+
test('the card frame is present on card, absent on every line style', async () => {
|
|
148
|
+
const card = await paint('card', h(SystemNotice, { notice: MULTI_LINE_NOTICE }));
|
|
149
|
+
expect(card.innerHTML).toContain('rounded-xl');
|
|
150
|
+
|
|
151
|
+
for (const style of ['compact', 'trace', 'minimal']) {
|
|
152
|
+
const el = await paint(style, h(SystemNotice, { notice: MULTI_LINE_NOTICE }));
|
|
153
|
+
expect(el.innerHTML).not.toContain('rounded-xl');
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('the notice body uses the style body container, so it hangs off the same rail', async () => {
|
|
158
|
+
const el = await paint('compact', h(SystemNotice, { notice: MULTI_LINE_NOTICE }));
|
|
159
|
+
const toggle = el.querySelector('button[aria-expanded]') as HTMLButtonElement;
|
|
160
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('false');
|
|
161
|
+
await act(async () => {
|
|
162
|
+
toggle.click();
|
|
163
|
+
});
|
|
164
|
+
expect(el.querySelector('.border-l.border-dashed')).not.toBeNull();
|
|
165
|
+
expect(el.textContent).toContain('Line two');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('a goal notice still renders OPEN with no toggle, in every style', async () => {
|
|
169
|
+
for (const style of ['card', 'compact', 'trace', 'minimal']) {
|
|
170
|
+
const el = await paint(style, h(SystemNotice, {
|
|
171
|
+
notice: '<objective>Ship it.</objective>\n`goal` tool: get.',
|
|
172
|
+
source: 'goal-mode-context',
|
|
173
|
+
}));
|
|
174
|
+
expect(el.textContent).toContain('Goal context');
|
|
175
|
+
expect(el.querySelector('button[aria-expanded]')).toBeNull();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|