@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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The Usage panel
|
|
7
|
+
* The Usage panel and the composer's thinking-level rule.
|
|
8
8
|
*
|
|
9
9
|
* - `format.ts` renders every number the panel shows. The boundaries are the
|
|
10
10
|
* point: the compact-token thresholds sit exactly at 1_000/1_000_000/1_000_000_000,
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
* fixed precedence (kenari plan → DeepSeek balance → quota window), and picks
|
|
15
15
|
* the WORST used fraction — picking the first window instead shows a provider
|
|
16
16
|
* at 3% while it is actually at 98%.
|
|
17
|
-
* - `buildPickerGroups` keys its hover index on the composite `provider:id`, not
|
|
18
|
-
* the bare id: the same model id is served by several providers, and an
|
|
19
|
-
* id-only key highlighted every provider's row at once.
|
|
20
17
|
* - `resolveThinkingLevel` must keep a session's level when the ladder is
|
|
21
18
|
* unknown/empty, because an async catalog fetch resolving later used to reset
|
|
22
19
|
* the user's chosen effort to a ladder default.
|
|
@@ -40,7 +37,6 @@ import {
|
|
|
40
37
|
statusLabel,
|
|
41
38
|
type ProviderEntry,
|
|
42
39
|
} from '@/client/components/settings/categories/usage-settings/providers';
|
|
43
|
-
import { buildPickerGroups } from '@/client/components/workspace/model-dropdown/groups';
|
|
44
40
|
import {
|
|
45
41
|
resolveThinkingLevel,
|
|
46
42
|
selectionFor,
|
|
@@ -241,69 +237,6 @@ describe('buildProviders', () => {
|
|
|
241
237
|
});
|
|
242
238
|
});
|
|
243
239
|
|
|
244
|
-
describe('buildPickerGroups', () => {
|
|
245
|
-
const model = (provider: string, id: string, name: string, extra: Partial<AIModelOption> = {}): AIModelOption =>
|
|
246
|
-
({ id, name, provider, ...extra }) as AIModelOption;
|
|
247
|
-
|
|
248
|
-
const catalog: AIModelOption[] = [
|
|
249
|
-
model('deepseek', 'v4-flash', 'Flash', { contextWindow: 128000, capabilities: ['tools'] }),
|
|
250
|
-
model('kenari', 'v4-flash', 'Flash (Kenari)', { contextWindow: 64000 }),
|
|
251
|
-
model('openai', 'gpt-5', 'GPT-5'),
|
|
252
|
-
];
|
|
253
|
-
|
|
254
|
-
test('a search filters on name, provider, context window and capability', () => {
|
|
255
|
-
expect(buildPickerGroups(catalog, 'flash', {}, [], []).filtered).toHaveLength(2);
|
|
256
|
-
expect(buildPickerGroups(catalog, 'OPENAI', {}, [], []).filtered.map((m) => m.id)).toEqual(['gpt-5']);
|
|
257
|
-
expect(buildPickerGroups(catalog, '64000', {}, [], []).filtered.map((m) => m.provider)).toEqual(['kenari']);
|
|
258
|
-
expect(buildPickerGroups(catalog, 'tools', {}, [], []).filtered.map((m) => m.provider)).toEqual(['deepseek']);
|
|
259
|
-
expect(buildPickerGroups(catalog, ' ', {}, [], []).filtered).toHaveLength(3);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
test('the rails follow the stored key order, not the catalog order', () => {
|
|
263
|
-
const groups = buildPickerGroups(catalog, '', {}, ['openai:gpt-5', 'deepseek:v4-flash'], ['kenari:v4-flash', 'openai:gpt-5']);
|
|
264
|
-
expect(groups.favorites.map((m) => m.id)).toEqual(['gpt-5', 'v4-flash']);
|
|
265
|
-
expect(groups.recent.map((m) => m.provider)).toEqual(['kenari']);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
test('the rails are narrowed by the search like every other section', () => {
|
|
269
|
-
const groups = buildPickerGroups(catalog, 'flash', {}, ['openai:gpt-5', 'deepseek:v4-flash'], []);
|
|
270
|
-
expect(groups.favorites.map((m) => m.provider)).toEqual(['deepseek']);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
test('providers are grouped under upper-cased names in catalog order', () => {
|
|
274
|
-
const groups = buildPickerGroups(catalog, '', {}, [], []);
|
|
275
|
-
expect(Object.keys(groups.byProvider)).toEqual(['DEEPSEEK', 'KENARI', 'OPENAI']);
|
|
276
|
-
expect(groups.byProvider.DEEPSEEK).toHaveLength(1);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
test('the flat list renders rails first, then provider sections', () => {
|
|
280
|
-
const groups = buildPickerGroups(catalog, '', {}, ['openai:gpt-5'], ['deepseek:v4-flash']);
|
|
281
|
-
// A rail model is NOT removed from its provider section: the flat list is the
|
|
282
|
-
// order the panel walks for hover/keyboard focus, and a model appearing once
|
|
283
|
-
// under a rail and again under its provider is the shipped behavior.
|
|
284
|
-
expect(groups.visibleFlatList.map((m) => `${m.provider}:${m.id}`)).toEqual([
|
|
285
|
-
'openai:gpt-5', // favorites rail
|
|
286
|
-
'deepseek:v4-flash', // recent rail
|
|
287
|
-
'deepseek:v4-flash', // DEEPSEEK section
|
|
288
|
-
'kenari:v4-flash', // KENARI section
|
|
289
|
-
'openai:gpt-5', // OPENAI section
|
|
290
|
-
]);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test('a collapsed section is dropped from the flat list but keeps its group', () => {
|
|
294
|
-
const groups = buildPickerGroups(catalog, '', { favorites: true, KENARI: true }, ['openai:gpt-5'], []);
|
|
295
|
-
expect(groups.visibleFlatList.map((m) => m.provider)).toEqual(['deepseek', 'openai']);
|
|
296
|
-
expect(groups.byProvider.KENARI).toHaveLength(1);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test('the hover index is keyed by provider+id, so shared ids stay distinct', () => {
|
|
300
|
-
const groups = buildPickerGroups(catalog, '', {}, [], []);
|
|
301
|
-
expect(groups.index['deepseek:v4-flash']).toBe(0);
|
|
302
|
-
expect(groups.index['kenari:v4-flash']).toBe(1);
|
|
303
|
-
expect(groups.index['deepseek:v4-flash']).not.toBe(groups.index['kenari:v4-flash']);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
240
|
describe('resolveThinkingLevel', () => {
|
|
308
241
|
test('a session level the model offers is authoritative', () => {
|
|
309
242
|
expect(resolveThinkingLevel(['off', 'low', 'high'], 'high', 'low')).toBe('high');
|
|
@@ -59,6 +59,11 @@ interface ComposerDockProps {
|
|
|
59
59
|
* scroll-to-bottom affordance.
|
|
60
60
|
*/
|
|
61
61
|
shrinkWhileReading?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The chat has no turns yet. Only the `stage` composer style reads it, and it
|
|
64
|
+
* only ever changes the card's frame — never which controls exist.
|
|
65
|
+
*/
|
|
66
|
+
hero?: boolean;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
@@ -99,6 +104,7 @@ export function ComposerDock({
|
|
|
99
104
|
sessionThinkingLevel,
|
|
100
105
|
variant,
|
|
101
106
|
shrinkWhileReading = false,
|
|
107
|
+
hero = false,
|
|
102
108
|
}: ComposerDockProps) {
|
|
103
109
|
// Side questions take over the composer entirely: the chat's own input is
|
|
104
110
|
// hidden while the form is open, so a stray Enter cannot send to the wrong
|
|
@@ -167,6 +173,7 @@ export function ComposerDock({
|
|
|
167
173
|
sessionThinkingLevel={sessionThinkingLevel}
|
|
168
174
|
variant={variant}
|
|
169
175
|
expandable
|
|
176
|
+
hero={hero}
|
|
170
177
|
shrinkWhileReading={shrinkWhileReading}
|
|
171
178
|
/>
|
|
172
179
|
)}
|
|
@@ -303,6 +303,9 @@ export function EmptyWorkspacePrompt({
|
|
|
303
303
|
deferredComposerPickRef={deferredComposerPickRef}
|
|
304
304
|
variant={variant}
|
|
305
305
|
expandable
|
|
306
|
+
// A brand-new chat has no turns: the `stage` composer style draws its
|
|
307
|
+
// wider, taller card here and nowhere else.
|
|
308
|
+
hero={messages.length === 0}
|
|
306
309
|
/>
|
|
307
310
|
</div>
|
|
308
311
|
</div>
|
|
@@ -15,6 +15,8 @@ import { capitalizeFirstLetter } from '@/shared/lib/chat/capitalize';
|
|
|
15
15
|
import { isNoticeRow, messageAnswerText } from '@/shared/lib/chat/notice-row';
|
|
16
16
|
import { formatMessageStamp } from '@/shared/lib/format/time';
|
|
17
17
|
import { transcriptBlockPadding, transcriptGutter } from '@/shared/lib/chat/timeline/gutter';
|
|
18
|
+
import { traceInset } from '@/shared/lib/chat/timeline/block-chrome';
|
|
19
|
+
import { useToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
18
20
|
|
|
19
21
|
interface ChatMessageItemProps {
|
|
20
22
|
msg: ChatMessageData | any;
|
|
@@ -182,6 +184,13 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
182
184
|
const cleanIntent = msg.intent ? capitalizeFirstLetter(msg.intent.replace(/^[.\s]+/, '')) : null;
|
|
183
185
|
const hasToolCalls = Boolean(allToolCalls && allToolCalls.length > 0);
|
|
184
186
|
|
|
187
|
+
// `trace` draws a rail in the run's left gutter; content that reserves nothing
|
|
188
|
+
// there would be struck through by it. The inset is the same fact as the
|
|
189
|
+
// rail's own column, so it lives beside `blockChrome` (`traceInset`).
|
|
190
|
+
const mode = useToolRenderMode();
|
|
191
|
+
const textInset = traceInset(mode, isMobile);
|
|
192
|
+
const boxInset = traceInset(mode, isMobile, true);
|
|
193
|
+
|
|
185
194
|
return (
|
|
186
195
|
<div
|
|
187
196
|
id={msg.id}
|
|
@@ -199,6 +208,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
199
208
|
{thinkingData && (
|
|
200
209
|
<ThinkingSection
|
|
201
210
|
thinking={thinkingData}
|
|
211
|
+
messageId={String(msg.id)}
|
|
202
212
|
defaultExpanded={false}
|
|
203
213
|
showSeparator={isPrevAssistant}
|
|
204
214
|
isMobile={isMobile}
|
|
@@ -207,7 +217,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
207
217
|
|
|
208
218
|
{/* Provider / API Error Alert */}
|
|
209
219
|
{msg.error && (
|
|
210
|
-
<div className={`flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg ${transcriptGutter(isMobile)} px-3.5 py-2.5 text-[12px] text-ink select-text`}>
|
|
220
|
+
<div className={`flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg ${boxInset || transcriptGutter(isMobile)} px-3.5 py-2.5 text-[12px] text-ink select-text`}>
|
|
211
221
|
<AlertCircle size={15} className="text-error flex-shrink-0 mt-0.5" />
|
|
212
222
|
<div className="min-w-0 flex-1 space-y-0.5">
|
|
213
223
|
<div className="flex items-center space-x-2 flex-wrap">
|
|
@@ -239,14 +249,14 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
239
249
|
|
|
240
250
|
{/* Main AI Response Content (Rich Markdown with code blocks, tables, lists) rendered before tool calls */}
|
|
241
251
|
{hasRenderableContent && (
|
|
242
|
-
<div className=
|
|
252
|
+
<div className={`text-[13px] text-ink leading-relaxed font-sans bg-transparent px-3 py-1 select-text ${textInset}`}>
|
|
243
253
|
<MarkdownRenderer content={assistantContent} />
|
|
244
254
|
</div>
|
|
245
255
|
)}
|
|
246
256
|
|
|
247
257
|
{/* Tool Call Intent (rendered standalone only when there are no tool calls to absorb it as title) */}
|
|
248
258
|
{cleanIntent && !hasToolCalls && (!hasRenderableContent || !msg.content.toLowerCase().includes(msg.intent.toLowerCase().trim())) && (
|
|
249
|
-
<div className={`leading-relaxed font-sans px-3 select-text ${
|
|
259
|
+
<div className={`leading-relaxed font-sans px-3 select-text ${textInset} ${
|
|
250
260
|
hasRenderableContent
|
|
251
261
|
? 'text-[12px] text-ink/70 py-0.5'
|
|
252
262
|
: 'text-[13px] text-ink py-1'
|
|
@@ -266,7 +276,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
266
276
|
|
|
267
277
|
{/* Intermediate Diagnostic Note */}
|
|
268
278
|
{msg.systemNote && (
|
|
269
|
-
<div className=
|
|
279
|
+
<div className={`text-[12px] text-ink leading-relaxed border-l-2 border-ink/30 bg-paper/60 px-3 py-2 rounded-r-md font-mono break-words whitespace-pre-wrap select-text ${boxInset}`}>
|
|
270
280
|
<span className="text-[10px] text-ink/50 uppercase tracking-wider block mb-0.5 font-sans font-semibold">
|
|
271
281
|
Diagnostic Note
|
|
272
282
|
</span>
|
|
@@ -285,7 +295,7 @@ export const ChatMessageItem = memo(function ChatMessageItem({
|
|
|
285
295
|
|
|
286
296
|
{/* AI Final Summary / Conclusion Card (Only shown when not streaming) */}
|
|
287
297
|
{!isStreaming && msg.summary && (
|
|
288
|
-
<div className=
|
|
298
|
+
<div className={`text-[12px] text-ink bg-paper border border-ink/15 rounded-lg p-3 space-y-1 select-text font-sans ${boxInset}`}>
|
|
289
299
|
<div className="font-semibold text-ink flex items-center space-x-1.5 text-[12px]">
|
|
290
300
|
<span className="w-1.5 h-1.5 rounded-full bg-success" />
|
|
291
301
|
<span>Resolution Summary</span>
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { Fragment } from 'preact';
|
|
1
2
|
import { useMemo } from 'preact/hooks';
|
|
2
3
|
import { memo } from 'preact/compat';
|
|
3
4
|
|
|
4
5
|
import { ChatMessageItem } from '@/client/components/workspace/chat-timeline/MessageItem';
|
|
5
6
|
import { RunFooter } from '@/client/components/workspace/chat-timeline/RunFooter';
|
|
7
|
+
import { TurnRail } from '@/client/components/workspace/chat-timeline/TurnRail';
|
|
8
|
+
import { useToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
6
9
|
import { isNoticeRow } from '@/shared/lib/chat/notice-row';
|
|
7
10
|
import { previousNonNoticeIndex, resolveRunFooters, streamingRowIndex } from '@/shared/lib/chat/timeline/run-footer';
|
|
11
|
+
import { groupTraceRows } from '@/shared/lib/chat/timeline/trace-groups';
|
|
8
12
|
import type { TimelineRowWindow } from '@/client/hooks/chat/timeline/row-window';
|
|
9
13
|
import type { Attachment, ChatMessageData } from '@/shared/types';
|
|
10
14
|
|
|
@@ -81,6 +85,16 @@ export const MessageList = memo(function MessageList({
|
|
|
81
85
|
const start = rowWindow ? rowWindow.start : 0;
|
|
82
86
|
const end = rowWindow ? Math.min(rowWindow.end, messages.length) : messages.length;
|
|
83
87
|
const visible = start === 0 && end === messages.length ? messages : messages.slice(start, end);
|
|
88
|
+
const mode = useToolRenderMode();
|
|
89
|
+
|
|
90
|
+
// A `trace` rail belongs to the RUN, not to a row and not to one message.
|
|
91
|
+
// omp writes a turn as several rows (thinking + tools, then a notice, then the
|
|
92
|
+
// answer), so a per-row segment broke at every row boundary and a per-message
|
|
93
|
+
// one broke wherever a notice sat in its own row — measured in the browser as
|
|
94
|
+
// three disconnected segments with gaps of 256px and 99px. The rows of one run
|
|
95
|
+
// are therefore grouped under a single `relative` container that draws one
|
|
96
|
+
// line, and each block inside only places its node.
|
|
97
|
+
const groups = useMemo(() => groupTraceRows(messages, start, start + visible.length), [messages, start, visible.length]);
|
|
84
98
|
|
|
85
99
|
return (
|
|
86
100
|
<>
|
|
@@ -88,48 +102,83 @@ export const MessageList = memo(function MessageList({
|
|
|
88
102
|
geometry read in `scroll.ts` still see the whole session's height,
|
|
89
103
|
while only the rows around the viewport are DOM. */}
|
|
90
104
|
{start > 0 && <div data-timeline-spacer="top" aria-hidden="true" style={{ height: rowWindow?.padTop ?? 0 }} />}
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const isPrevAssistant = Boolean(msg.role !== 'user' && prevReal && prevReal.role !== 'user');
|
|
99
|
-
const footer = footers[idx];
|
|
105
|
+
{groups.map((group) => {
|
|
106
|
+
// The run footer belongs to the run but NOT to its trace: it is a model
|
|
107
|
+
// and duration stamp, not a step. Left inside the rail container it drew
|
|
108
|
+
// the line 58px past the last node (measured), so it renders after the
|
|
109
|
+
// grouped rows instead.
|
|
110
|
+
const lastIdx = group.rows[group.rows.length - 1];
|
|
111
|
+
const trailingFooter = footers[lastIdx];
|
|
100
112
|
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
113
|
+
<Fragment key={group.key}>
|
|
114
|
+
<div className={group.trace ? 'relative' : undefined} data-trace-group={group.trace || undefined}>
|
|
115
|
+
{group.trace && <TurnRail visible={mode === 'trace'} isMobile={isMobile} />}
|
|
116
|
+
{group.rows.map((idx) => {
|
|
117
|
+
const msg = messages[idx];
|
|
118
|
+
const prev = messages[idx - 1];
|
|
119
|
+
const isLoading = isGenerating && idx === streamingIdx && msg.role === 'ai';
|
|
120
|
+
const isAiFragment = msg.role !== 'user' && prev && prev.role !== 'user' && !isNoticeRow(prev);
|
|
121
|
+
const prevRealIdx = prevNonNoticeIdx[idx];
|
|
122
|
+
const prevReal = prevRealIdx >= 0 ? messages[prevRealIdx] : null;
|
|
123
|
+
const isPrevAssistant = Boolean(msg.role !== 'user' && prevReal && prevReal.role !== 'user');
|
|
124
|
+
const footer = footers[idx];
|
|
125
|
+
// A footer that is NOT the group's trailing one still renders in
|
|
126
|
+
// place — it closes an earlier run's row and the rail already ended.
|
|
127
|
+
const inlineFooter = footer && idx !== lastIdx ? footer : null;
|
|
128
|
+
return (
|
|
129
|
+
// `flow-root` contains the row's own margins, so the measured height
|
|
130
|
+
// is the row PLUS the gap it draws — a plain wrapper would let the
|
|
131
|
+
// margin collapse out and the layout would sit a few px short per row.
|
|
132
|
+
<div key={msg.id} data-row-id={msg.id} style={{ display: 'flow-root' }}>
|
|
133
|
+
<ChatMessageItem
|
|
134
|
+
msg={msg}
|
|
135
|
+
isStreaming={isLoading}
|
|
136
|
+
onUndo={onUndo}
|
|
137
|
+
onNewChat={onNewChat}
|
|
138
|
+
isPrevAssistant={isPrevAssistant}
|
|
139
|
+
userActions={userActions}
|
|
140
|
+
isMobile={isMobile}
|
|
141
|
+
className={isNoticeRow(msg) ? 'mt-3 mb-1' : isAiFragment ? 'mt-1' : 'mt-3'}
|
|
142
|
+
/>
|
|
143
|
+
{inlineFooter && (
|
|
144
|
+
<RunFooter
|
|
145
|
+
msg={inlineFooter.msg}
|
|
146
|
+
provider={provider}
|
|
147
|
+
providerNames={providerNames}
|
|
148
|
+
modelName={modelName}
|
|
149
|
+
modelNames={modelNames}
|
|
150
|
+
thinkingLevel={thinkingLevel}
|
|
151
|
+
durationMs={inlineFooter.durationMs}
|
|
152
|
+
answerText={inlineFooter.answerText}
|
|
153
|
+
retryTargetId={inlineFooter.runUserId}
|
|
154
|
+
onRetry={onRetry}
|
|
155
|
+
onNewChat={onNewChat}
|
|
156
|
+
isMobile={isMobile}
|
|
157
|
+
showActions={userActions}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
})}
|
|
163
|
+
</div>
|
|
164
|
+
{trailingFooter && (
|
|
165
|
+
<RunFooter
|
|
166
|
+
msg={trailingFooter.msg}
|
|
167
|
+
provider={provider}
|
|
168
|
+
providerNames={providerNames}
|
|
169
|
+
modelName={modelName}
|
|
170
|
+
modelNames={modelNames}
|
|
171
|
+
thinkingLevel={thinkingLevel}
|
|
172
|
+
durationMs={trailingFooter.durationMs}
|
|
173
|
+
answerText={trailingFooter.answerText}
|
|
174
|
+
retryTargetId={trailingFooter.runUserId}
|
|
175
|
+
onRetry={onRetry}
|
|
176
|
+
onNewChat={onNewChat}
|
|
177
|
+
isMobile={isMobile}
|
|
178
|
+
showActions={userActions}
|
|
179
|
+
/>
|
|
180
|
+
)}
|
|
181
|
+
</Fragment>
|
|
133
182
|
);
|
|
134
183
|
})}
|
|
135
184
|
{end < messages.length && <div data-timeline-spacer="bottom" aria-hidden="true" style={{ height: rowWindow?.padBottom ?? 0 }} />}
|
|
@@ -10,6 +10,8 @@ import { GoalNotice } from '@/client/components/workspace/chat-timeline/GoalNoti
|
|
|
10
10
|
import { TaskResultContent } from '@/client/components/workspace/chat-timeline/TaskResultContent';
|
|
11
11
|
import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
|
|
12
12
|
import { transcriptGutter } from '@/shared/lib/chat/timeline/gutter';
|
|
13
|
+
import { blockChrome } from '@/shared/lib/chat/timeline/block-chrome';
|
|
14
|
+
import { useToolRenderMode } from '@/client/hooks/chat/timeline/tool-render-mode';
|
|
13
15
|
|
|
14
16
|
const KIND_LABEL: Record<GoalNoticeData['kind'], string> = {
|
|
15
17
|
start: 'Goal started',
|
|
@@ -51,6 +53,8 @@ interface SystemNoticeProps {
|
|
|
51
53
|
* jobs, and <system-reminder> blocks, all collapsed by default; a goal-mode
|
|
52
54
|
* injection renders open and has no collapse control (see `forcedOpen`). */
|
|
53
55
|
export function SystemNotice({ notice, source, isMobile = false }: SystemNoticeProps) {
|
|
56
|
+
const mode = useToolRenderMode();
|
|
57
|
+
const chrome = blockChrome(mode);
|
|
54
58
|
const [userOpen, setUserOpen] = useState(false);
|
|
55
59
|
|
|
56
60
|
// 1. Check if notice contains a structured <task-result> block
|
|
@@ -203,20 +207,22 @@ export function SystemNotice({ notice, source, isMobile = false }: SystemNoticeP
|
|
|
203
207
|
|
|
204
208
|
return (
|
|
205
209
|
<div
|
|
206
|
-
className={`${transcriptGutter(isMobile)}
|
|
207
|
-
canToggle ? 'hover:border-ink/20' : ''
|
|
208
|
-
} select-text`}
|
|
210
|
+
className={`${transcriptGutter(isMobile)} text-[12px] text-ink select-text ${chrome.root}`}
|
|
209
211
|
>
|
|
212
|
+
{/* The rail is drawn once per TURN by `TurnRail`; this block only places
|
|
213
|
+
its node. A segment per block broke wherever prose sat between two. */}
|
|
214
|
+
{mode === 'trace' && <span aria-hidden="true" className={chrome.node} />}
|
|
215
|
+
<div className={chrome.frame || undefined}>
|
|
210
216
|
<button
|
|
211
217
|
type="button"
|
|
212
218
|
onClick={handleToggle}
|
|
213
219
|
disabled={!canToggle}
|
|
214
220
|
aria-expanded={canToggle ? isOpen : undefined}
|
|
215
|
-
className={
|
|
221
|
+
className={`${chrome.header} ${
|
|
216
222
|
canToggle ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
|
|
217
223
|
} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
|
|
218
224
|
>
|
|
219
|
-
<span className={
|
|
225
|
+
<span className={`${chrome.icon} ${noticeStyle.badgeClass}`}>
|
|
220
226
|
{noticeStyle.icon}
|
|
221
227
|
</span>
|
|
222
228
|
<span className="flex min-w-0 flex-1 flex-col">
|
|
@@ -276,7 +282,7 @@ export function SystemNotice({ notice, source, isMobile = false }: SystemNoticeP
|
|
|
276
282
|
</button>
|
|
277
283
|
|
|
278
284
|
{(forcedOpen || (isOpen && isExpandable)) && (
|
|
279
|
-
<div className=
|
|
285
|
+
<div className={chrome.body}>
|
|
280
286
|
{taskNotice ? (
|
|
281
287
|
<TaskResultContent task={taskNotice} />
|
|
282
288
|
) : goalNotice ? (
|
|
@@ -299,6 +305,7 @@ export function SystemNotice({ notice, source, isMobile = false }: SystemNoticeP
|
|
|
299
305
|
)}
|
|
300
306
|
</div>
|
|
301
307
|
)}
|
|
308
|
+
</div>
|
|
302
309
|
</div>
|
|
303
310
|
);
|
|
304
311
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A thinking block's open state belongs to the conversation, not to the mounted
|
|
8
|
+
* component instance.
|
|
9
|
+
*
|
|
10
|
+
* The defect this pins: the accordion kept its openness in a local
|
|
11
|
+
* `useState`, and `MessageList` mounts a WINDOW of rows. Expanding a thought
|
|
12
|
+
* grows its row, the next measurement moves the viewport, the row leaves the
|
|
13
|
+
* window and comes back with a fresh `useState(false)` — so the block snapped
|
|
14
|
+
* shut, and whether it did depended on how much content sat below it ("sometimes
|
|
15
|
+
* it works"). Measured in the browser on a real session: one click removed and
|
|
16
|
+
* re-added every row at the window's edge.
|
|
17
|
+
*
|
|
18
|
+
* Mounted against happy-dom and driven through the rendered button, because the
|
|
19
|
+
* claim is about what a click on the real control does across a remount.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
23
|
+
import { Window } from 'happy-dom';
|
|
24
|
+
import { h, render } from 'preact';
|
|
25
|
+
import { act } from 'preact/test-utils';
|
|
26
|
+
import { ThinkingSection } from '@/client/components/workspace/chat-timeline/ThinkingSection';
|
|
27
|
+
import { SessionStateProvider } from '@/client/components/common/session-state-provider';
|
|
28
|
+
import { forgetSession } from '@/shared/lib/workspace/session-state/store';
|
|
29
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
30
|
+
|
|
31
|
+
const SESSION = 'spec-thinking-open';
|
|
32
|
+
/** The runner's own fetch, so a leaked stub cannot be mistaken for it. */
|
|
33
|
+
const nativeFetch = Bun.fetch;
|
|
34
|
+
|
|
35
|
+
let container: HTMLElement;
|
|
36
|
+
|
|
37
|
+
const THOUGHT = { thought: 'Read the summary module, then patch the header row.', duration: '1.2s' };
|
|
38
|
+
|
|
39
|
+
beforeAll(() => installDomGlobals(new Window({ url: 'http://localhost' })));
|
|
40
|
+
afterAll(() => restoreDomGlobals());
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
container = document.createElement('div');
|
|
44
|
+
document.body.appendChild(container);
|
|
45
|
+
(globalThis as unknown as Record<string, unknown>).fetch = async () =>
|
|
46
|
+
new Response(JSON.stringify({ sessionId: SESSION, state: {} }), {
|
|
47
|
+
status: 200,
|
|
48
|
+
headers: { 'content-type': 'application/json' },
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
render(null, container);
|
|
54
|
+
container.remove();
|
|
55
|
+
forgetSession(SESSION);
|
|
56
|
+
(globalThis as unknown as Record<string, unknown>).fetch = nativeFetch;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
async function mount(messageId: string, thinking: typeof THOUGHT & { isGenerating?: boolean } = THOUGHT): Promise<void> {
|
|
60
|
+
await act(async () => {
|
|
61
|
+
render(
|
|
62
|
+
h(SessionStateProvider, {
|
|
63
|
+
sessionId: SESSION,
|
|
64
|
+
children: h(ThinkingSection, { thinking, messageId }),
|
|
65
|
+
}) as never,
|
|
66
|
+
container,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
for (let i = 0; i < 4; i += 1) await act(async () => {});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toggle(): HTMLButtonElement {
|
|
73
|
+
const button = container.querySelector<HTMLButtonElement>('button[aria-expanded]');
|
|
74
|
+
if (!button) throw new Error('no thinking toggle');
|
|
75
|
+
return button;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function click(): Promise<void> {
|
|
79
|
+
await act(async () => { toggle().click(); });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
describe('thinking open state', () => {
|
|
83
|
+
test('a block starts closed and a click opens it', async () => {
|
|
84
|
+
await mount('m1');
|
|
85
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('false');
|
|
86
|
+
await click();
|
|
87
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('true');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('the choice survives the row being unmounted and remounted', async () => {
|
|
91
|
+
await mount('m1');
|
|
92
|
+
await click();
|
|
93
|
+
// What the timeline's row window does when the expanded row grows and the
|
|
94
|
+
// reader moves: the row leaves the DOM and comes back.
|
|
95
|
+
render(null, container);
|
|
96
|
+
await mount('m1');
|
|
97
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('true');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('each row remembers its own choice', async () => {
|
|
101
|
+
await mount('m1');
|
|
102
|
+
await click();
|
|
103
|
+
render(null, container);
|
|
104
|
+
await mount('m2');
|
|
105
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('false');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('a generating run opens itself, and closing it during the run sticks', async () => {
|
|
109
|
+
await mount('m1', { ...THOUGHT, isGenerating: true });
|
|
110
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('true');
|
|
111
|
+
|
|
112
|
+
// The reader closes it mid-run. The run is still generating, so a default
|
|
113
|
+
// re-applied on the next frame would re-open it under their cursor.
|
|
114
|
+
await click();
|
|
115
|
+
expect(toggle().getAttribute('aria-expanded')).toBe('false');
|
|
116
|
+
});
|
|
117
|
+
});
|