@kabmo-labs/kabmo 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +319 -319
  3. package/dist/client/static/js/{index-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
  4. package/dist/client/static/js/index-tsgy3gd1.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
  7. package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
  8. package/src/client/components/common/code-surface/extensions.ts +7 -1
  9. package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
  10. package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
  11. package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
  12. package/src/client/components/common/session-row/index.tsx +205 -0
  13. package/src/client/components/common/session-row/session-row.test.tsx +144 -0
  14. package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
  15. package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
  16. package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
  17. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
  18. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
  19. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
  20. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +55 -0
  21. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -0
  22. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
  23. package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
  24. package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
  25. package/src/client/components/mobile/SessionSidebar.tsx +137 -146
  26. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
  27. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
  28. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
  29. package/src/client/components/settings/Modal.tsx +5 -27
  30. package/src/client/components/settings/Sidebar.tsx +1 -1
  31. package/src/client/components/settings/apply-side-effects.test.ts +102 -0
  32. package/src/client/components/settings/apply-side-effects.ts +90 -0
  33. package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
  34. package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
  35. package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
  36. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
  37. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
  38. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
  39. package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
  40. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
  41. package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
  42. package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
  43. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
  44. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
  45. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
  46. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -5
  47. package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
  48. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
  49. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +108 -67
  50. package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
  51. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
  52. package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
  53. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +158 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
  55. package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
  56. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
  58. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
  59. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
  60. package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
  61. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
  62. package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
  63. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
  64. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
  65. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
  66. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
  67. package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
  68. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
  69. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
  70. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
  71. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
  73. package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
  80. package/src/client/components/workspace/diff-panel/folding.ts +6 -1
  81. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
  82. package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
  83. package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
  84. package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
  85. package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
  86. package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
  87. package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
  88. package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
  89. package/src/client/data/settings/omp-schema.json +151 -6
  90. package/src/client/hooks/chat/composer/style.ts +66 -0
  91. package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
  92. package/src/client/hooks/settings/providers/login.ts +11 -2
  93. package/src/client/hooks/ui/window-event.ts +20 -4
  94. package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
  95. package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
  96. package/src/client/hooks/workspace/batch-archive.ts +78 -0
  97. package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
  98. package/src/client/hooks/workspace/sidebar-style.ts +66 -0
  99. package/src/client/tailwind.css +111 -0
  100. package/src/server/index.ts +10 -134
  101. package/src/server/lib/lifecycle/after-listen.ts +178 -0
  102. package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
  103. package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
  104. package/src/server/lib/lifecycle/tls.test.ts +7 -7
  105. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
  106. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
  107. package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
  108. package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
  109. package/src/server/lib/plugins/background.server.ts +17 -1
  110. package/src/server/lib/plugins/background.test.ts +33 -0
  111. package/src/server/routes/sessions/batch-archive.test.ts +113 -0
  112. package/src/server/routes/sessions/batch-archive.ts +80 -0
  113. package/src/server/routes/sessions/index.ts +4 -0
  114. package/src/shared/lib/chat/composer/style.test.ts +126 -0
  115. package/src/shared/lib/chat/composer/style.ts +171 -0
  116. package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
  117. package/src/shared/lib/chat/composer/tui-only.ts +5 -0
  118. package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
  119. package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
  120. package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
  121. package/src/shared/lib/chat/timeline/trace-groups.test.ts +120 -0
  122. package/src/shared/lib/chat/timeline/trace-groups.ts +68 -0
  123. package/src/shared/lib/settings/defaults.ts +6 -0
  124. package/src/shared/lib/workspace/session-focus.test.ts +93 -0
  125. package/src/shared/lib/workspace/session-focus.ts +71 -0
  126. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
  127. package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
  128. package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
  129. package/src/shared/lib/workspace/sidebar-style.ts +86 -0
  130. package/src/shared/types/omp/agent.ts +6 -0
  131. package/src/shared/types/settings/state.ts +31 -0
  132. package/dist/client/static/js/index-68w8h33q.css +0 -1
  133. package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
@@ -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
  ];
@@ -43,10 +43,12 @@ afterEach(() => {
43
43
 
44
44
  afterAll(() => restoreDomGlobals());
45
45
 
46
- function mount(model: AIModelOption): void {
46
+ function mount(model: AIModelOption, extra: { rowId?: string; showProvider?: boolean } = {}): void {
47
47
  act(() => {
48
48
  render(
49
49
  h(ModelDropdownItem, {
50
+ rowId: extra.rowId ?? `test::${model.provider}:${model.id}`,
51
+ ...(extra.showProvider === undefined ? {} : { showProvider: extra.showProvider }),
50
52
  model,
51
53
  isSelected: false,
52
54
  isFocused: false,
@@ -90,6 +92,11 @@ describe('model picker and the providerIcon slot', () => {
90
92
  });
91
93
 
92
94
  describe('composer row: provider mark and text grid', () => {
95
+ /** The fixed context column, which lives in the row's right cluster. */
96
+ function contextColumn(): HTMLElement {
97
+ return container.querySelector('[role="button"] > div:last-child > span.w-11') as HTMLElement;
98
+ }
99
+
93
100
  /** The row's plate — the fixed box that keeps every name at one x. */
94
101
  function plate(): HTMLElement | null {
95
102
  return container.querySelector('[role="button"] > div > span[aria-hidden]');
@@ -126,7 +133,10 @@ describe('composer row: provider mark and text grid', () => {
126
133
  const name = container.querySelector('[role="button"] span[title="DeepSeek V3"]') as HTMLElement;
127
134
  expect(name.className).toContain('flex-1');
128
135
  expect(name.className).toContain('truncate');
129
- const context = name.nextElementSibling as HTMLElement;
136
+ // The number lives in the RIGHT cluster now, so it is found by its column
137
+ // rather than by sitting next to the name.
138
+ const context = contextColumn();
139
+ expect(context.textContent).toBe('200K');
130
140
  expect(context.className).toContain('w-11');
131
141
  expect(context.className).toContain('text-right');
132
142
  expect(context.className).toContain('tabular-nums');
@@ -135,22 +145,86 @@ describe('composer row: provider mark and text grid', () => {
135
145
  test('a row with no context window keeps the column, so the names still align', () => {
136
146
  mount({ id: 'v3', name: 'DeepSeek V3', provider: 'DeepSeek' });
137
147
 
138
- const name = container.querySelector('[role="button"] span[title="DeepSeek V3"]') as HTMLElement;
139
- const context = name.nextElementSibling as HTMLElement;
148
+ const context = contextColumn();
140
149
  expect(context.textContent).toBe('');
141
150
  expect(context.className).toContain('w-11');
142
151
  });
143
152
  });
144
153
 
145
- describe('composer row: the context column is pinned', () => {
146
- test('the right cluster is a fixed width, so a check or a pill cannot move it', () => {
147
- // Measured in the browser before this: the context badge sat at x=572 on 94
148
- // rows and x=547 on the one selected row, whose checkmark and wider thinking
149
- // label grew the right cluster by 25px.
150
- mount({ id: 'v3', name: 'DeepSeek V3', provider: 'DeepSeek', contextWindow: 128000, thinkingLevel: 'auto' });
154
+ describe('composer row: the trailing cells', () => {
155
+ test('the order is context, thinking, provider, star', () => {
156
+ mount({ id: 'v3', name: 'DeepSeek V3', provider: 'Kenari', contextWindow: 128000, thinkingLevel: 'high' }, { showProvider: true });
151
157
 
152
158
  const right = container.querySelector('[role="button"] > div:last-child') as HTMLElement;
153
- expect(right.className).toContain('w-[100px]');
154
- expect(right.className).toContain('justify-end');
159
+ const kinds = [...right.children].map((child) => {
160
+ if (child.tagName === 'BUTTON') {
161
+ return (child.getAttribute('title') ?? '').startsWith('Thinking preset') ? 'thinking' : 'star';
162
+ }
163
+ return (child.getAttribute('title') ?? '').startsWith('Provider: ') ? 'provider' : 'context';
164
+ });
165
+ expect(kinds).toEqual(['context', 'thinking', 'provider', 'star']);
166
+ });
167
+
168
+ test('the checkmark is gone, and nothing else marks the selection in this cluster', () => {
169
+ // The check cost the cluster its geometry and said nothing the tinted
170
+ // background and the semibold name did not already say.
171
+ act(() => {
172
+ render(
173
+ h(ModelDropdownItem, {
174
+ rowId: 'test::DeepSeek:v3',
175
+ model: { id: 'v3', name: 'DeepSeek V3', provider: 'DeepSeek' },
176
+ isSelected: true,
177
+ isFocused: false,
178
+ onSelect: () => {},
179
+ onToggleFavorite: () => {},
180
+ onMouseEnter: () => {},
181
+ }),
182
+ container,
183
+ );
184
+ });
185
+
186
+ const row = container.querySelector('[role="button"]') as HTMLElement;
187
+ expect(row.querySelector('.lucide-check')).toBeNull();
188
+ // Context column + star, and nothing conditional on selection.
189
+ expect(row.querySelectorAll('[role="button"] > div:last-child > *')).toHaveLength(2);
190
+ expect(row.querySelector('[role="button"] span[title="DeepSeek V3"]')?.className).toContain('font-semibold');
191
+ expect(row.className).toContain('bg-ink/5');
192
+ });
193
+
194
+ test('a row without a thinking preset keeps the context column where it was', () => {
195
+ mount({ id: 'v3', name: 'DeepSeek V3', provider: 'DeepSeek', contextWindow: 64000 });
196
+
197
+ const right = container.querySelector('[role="button"] > div:last-child') as HTMLElement;
198
+ // The context cell is always the FIRST child, so its left edge does not move
199
+ // when the pill or the tag is absent.
200
+ expect(right.firstElementChild?.textContent).toBe('64K');
201
+ expect(right.firstElementChild?.className).toContain('w-11');
202
+ });
203
+
204
+ test('the thinking pill is a control, not a label: it stops the click from selecting', () => {
205
+ let selected = 0;
206
+ act(() => {
207
+ render(
208
+ h(ModelDropdownItem, {
209
+ rowId: 'test::DeepSeek:v3',
210
+ model: { id: 'v3', name: 'DeepSeek V3', provider: 'DeepSeek', thinkingLevel: 'high' },
211
+ isSelected: false,
212
+ isFocused: false,
213
+ onSelect: () => { selected += 1; },
214
+ onToggleFavorite: () => {},
215
+ onMouseEnter: () => {},
216
+ }),
217
+ container,
218
+ );
219
+ });
220
+
221
+ const pill = container.querySelector('button[title^="Thinking preset"]') as HTMLElement;
222
+ const view = container.ownerDocument.defaultView as unknown as {
223
+ Event: new (type: string, init: { bubbles: boolean }) => Event;
224
+ };
225
+ act(() => {
226
+ pill.dispatchEvent(new view.Event('click', { bubbles: true }));
227
+ });
228
+ expect(selected).toBe(0);
155
229
  });
156
230
  });
@@ -1,12 +1,20 @@
1
1
  import type { TargetedMouseEvent } from 'preact';
2
- import { Brain, Check, Command, GripVertical, Star } from 'lucide-preact';
2
+ import { Brain, Command, GripVertical, Star } from 'lucide-preact';
3
3
  import type { AIModelOption } from '@/shared/types';
4
4
  import { formatContextWindow } from '@/shared/lib/code/format';
5
5
  import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
6
- import { modelKey } from '@/shared/lib/models/identity';
7
6
 
8
7
  interface ModelDropdownItemProps {
9
8
  model: AIModelOption;
9
+ /** Identity of THIS row (`section::provider:id`); the specs card anchors to it. */
10
+ rowId: string;
11
+ /**
12
+ * Draw the provider tag. Set for a rail row whose model name is served by
13
+ * more than one provider — FAVORITES and RECENT have no provider header, so
14
+ * without the tag `DeepSeek V4 Pro` under `deepseek` and under `kenari` are
15
+ * two identical rows.
16
+ */
17
+ showProvider?: boolean;
10
18
  isSelected: boolean;
11
19
  isFocused: boolean;
12
20
  onSelect: (model: AIModelOption) => void;
@@ -28,6 +36,8 @@ interface ModelDropdownItemProps {
28
36
  */
29
37
  export function ModelDropdownItem({
30
38
  model,
39
+ rowId,
40
+ showProvider = false,
31
41
  isSelected,
32
42
  isFocused,
33
43
  onSelect,
@@ -40,9 +50,11 @@ export function ModelDropdownItem({
40
50
  role="button"
41
51
  tabIndex={0}
42
52
  // The specs card anchors to the row it describes, and it finds that row
43
- // by this key — the same composite identity the picker navigates by, so
44
- // the mouse and the keyboard resolve to one anchor.
45
- data-model-key={modelKey(model)}
53
+ // by `rowId` — the section PLUS the composite model key. The model key
54
+ // alone is ambiguous: a favorite is drawn in the rail and again in its
55
+ // provider section, so the card (and the hover index) resolved to the
56
+ // first of the two and described a row three rows away.
57
+ data-picker-row={rowId}
46
58
  onClick={() => onSelect(model)}
47
59
  onMouseEnter={onMouseEnter}
48
60
  className={`group relative w-full flex items-center justify-between gap-2 pl-1 pr-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer select-none ${
@@ -94,24 +106,37 @@ export function ModelDropdownItem({
94
106
  className={`flex-1 min-w-0 truncate ${
95
107
  isSelected ? 'font-semibold text-ink' : 'font-normal text-ink/90'
96
108
  }`}
97
- title={model.name}
109
+ title={showProvider ? `${model.name} · ${model.provider}` : model.name}
98
110
  >
99
111
  {model.name}
100
112
  </span>
101
- {/* Fixed column: a number has to be comparable down the list, and a
102
- badge that follows the name cannot be. */}
103
- <span className="w-11 shrink-0 text-right font-mono text-[10px] tabular-nums text-ink/45">
113
+ </div>
114
+
115
+ {/* Trailing cells in the reader's order: context number → thinking preset →
116
+ provider tag → star. The star is last because it is the one control on
117
+ every row and has to stay on the row's edge.
118
+ The check that used to live here is gone: selection is already the
119
+ row's tint and its semibold name, and the checkmark was the only thing
120
+ whose presence changed this cluster's width.
121
+ The number is no longer a column: it is the FIRST cell of a cluster
122
+ that is right-aligned, so its x moves with the width of the pill and
123
+ the tag to its right (measured over the seeded catalog: `626` on rows
124
+ with neither, down to `519` where both are present). The order is the
125
+ reader's, the alignment is the price.
126
+ On a tagged row at phone width the number yields instead of the name:
127
+ the row is 322px there, the tag costs 43-53px, and the name would have
128
+ collapsed to `Deepse…` (measured: 37px of a 99px name). Identity
129
+ outranks the context number on the one row whose identity is in
130
+ question. */}
131
+ <div className="flex items-center justify-end gap-1.5 flex-shrink-0">
132
+ <span
133
+ className={`w-11 shrink-0 text-right font-mono text-[10px] tabular-nums text-ink/45 ${
134
+ showProvider ? 'max-sm:hidden' : ''
135
+ }`}
136
+ >
104
137
  {model.contextWindow ? formatContextWindow(model.contextWindow) : ''}
105
138
  </span>
106
- </div>
107
139
 
108
- {/* Right: thinking pill, checkmark, star.
109
- A FIXED width, right-aligned: the pill's label and the checkmark's
110
- presence both change this cluster's width, which moved the context
111
- column 25px to the left on the one selected row (measured: 547 vs 572).
112
- Reserving the whole cluster pins that column, and the star — the one
113
- control on every row — stays on the row's edge. */}
114
- <div className="flex items-center justify-end gap-1.5 flex-shrink-0 w-[100px]">
115
140
  {model.thinkingLevel && (
116
141
  <button
117
142
  type="button"
@@ -120,14 +145,26 @@ export function ModelDropdownItem({
120
145
  onCycleThinking?.(model, e);
121
146
  }}
122
147
  title={`Thinking preset: ${model.thinkingLevel} (Click or use ← / → to change)`}
123
- className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer"
148
+ className="inline-flex shrink-0 items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer"
124
149
  >
125
150
  <Brain size={10} className="text-ink/50" />
126
151
  <span>{model.thinkingLevel}</span>
127
152
  </button>
128
153
  )}
129
154
 
130
- {isSelected && <Check size={13} className="text-ink flex-shrink-0" />}
155
+ {/* The provider tag, drawn only on a rail row whose name is shared by
156
+ another provider so the two rows are not identical. It never shrinks
157
+ and never wraps: `kenari` and `kenari-jatis` are two accounts, so an
158
+ ellipsis here would make them render identically — the same rule the
159
+ composer trigger follows. */}
160
+ {showProvider && (
161
+ <span
162
+ className="shrink-0 whitespace-nowrap rounded border border-ink/15 bg-ink/5 px-1 font-mono text-[9px] leading-4 text-ink/55"
163
+ title={`Provider: ${model.provider}`}
164
+ >
165
+ {model.provider}
166
+ </span>
167
+ )}
131
168
 
132
169
  <button
133
170
  type="button"
@@ -6,7 +6,7 @@ import { ModelDropdownSection } from '@/client/components/workspace/model-dropdo
6
6
  import { ModelDropdownFooter } from '@/client/components/workspace/model-dropdown/Footer';
7
7
  import { ModelDropdownSkeleton } from '@/client/components/workspace/model-dropdown/Skeleton';
8
8
  import { ModelSpecsTooltip } from '@/client/components/workspace/model-dropdown/SpecsTooltip';
9
- import { modelKey } from '@/shared/lib/models/identity';
9
+ import type { PickerRow } from '@/client/components/workspace/model-dropdown/groups';
10
10
 
11
11
  interface ModelDropdownPanelProps {
12
12
  search: string;
@@ -18,18 +18,21 @@ interface ModelDropdownPanelProps {
18
18
  favoriteModels: AIModelOption[];
19
19
  recentModels: AIModelOption[];
20
20
  providerGroups: Record<string, AIModelOption[]>;
21
+ /** Lower-cased model names served by more than one provider. */
22
+ ambiguousNames: ReadonlySet<string>;
21
23
  collapsedSections: Record<string, boolean>;
22
24
  onToggleCollapse: (section: string) => void;
23
25
  /** Composite (`provider:id`) key of the active selection. */
24
26
  selectedModelKey: string;
25
- /** Composite key → index in the keyboard-navigation flat list. */
27
+ /** Row id (`section::provider:id`) → index in the keyboard-navigation flat list. */
26
28
  modelIndex: Record<string, number>;
27
29
  focusedIndex: number;
28
- hoveredModel: AIModelOption | null;
30
+ hoveredRow: PickerRow | null;
29
31
  onSelect: (model: AIModelOption) => void;
30
32
  onToggleFavorite: (model: AIModelOption, e: TargetedMouseEvent<HTMLElement>) => void;
31
33
  onCycleThinking: (model: AIModelOption, e: TargetedMouseEvent<HTMLElement>) => void;
32
- onHoverItem: (index: number, model: AIModelOption) => void;
34
+ /** Row index in the flat list; the panel resolves it to the row it renders. */
35
+ onHoverItem: (index: number) => void;
33
36
  onMouseLeave: () => void;
34
37
  }
35
38
 
@@ -42,12 +45,13 @@ export function ModelDropdownPanel({
42
45
  favoriteModels,
43
46
  recentModels,
44
47
  providerGroups,
48
+ ambiguousNames,
45
49
  collapsedSections,
46
50
  onToggleCollapse,
47
51
  selectedModelKey,
48
52
  modelIndex,
49
53
  focusedIndex,
50
- hoveredModel,
54
+ hoveredRow,
51
55
  onSelect,
52
56
  onToggleFavorite,
53
57
  onCycleThinking,
@@ -61,21 +65,22 @@ export function ModelDropdownPanel({
61
65
 
62
66
  // The card belongs to the ROW it describes, not to the panel: a card pinned
63
67
  // to the panel's middle described a model three rows away from it. The anchor
64
- // is the row's own `data-model-key`, so the mouse and the keyboard resolve to
65
- // the same element, and the offset is clamped to the panel because a card
66
- // hanging past the list reads as a second, unrelated panel.
68
+ // is the row's own `data-picker-row`, so the mouse and the keyboard resolve to
69
+ // the same element — and so does each of the two rows one model can occupy
70
+ // (its rail and its provider section). The offset is clamped to the panel
71
+ // because a card hanging past the list reads as a second, unrelated panel.
67
72
  const alignCardToRow = useCallback(() => {
68
73
  const panel = panelRef.current;
69
74
  const card = cardRef.current;
70
- if (!panel || !card || !hoveredModel) return;
71
- const row = panel.querySelector(`[data-model-key="${CSS.escape(modelKey(hoveredModel))}"]`);
75
+ if (!panel || !card || !hoveredRow) return;
76
+ const row = panel.querySelector(`[data-picker-row="${CSS.escape(hoveredRow.rowId)}"]`);
72
77
  if (!row) return;
73
78
  const panelBox = panel.getBoundingClientRect();
74
79
  const maxTop = Math.max(0, panelBox.height - card.offsetHeight);
75
80
  const next = Math.min(maxTop, Math.max(0, row.getBoundingClientRect().top - panelBox.top));
76
81
  // Same offset ⇒ no state write, so scrolling does not re-render the panel.
77
82
  setCardTop((prev) => (prev === next ? prev : next));
78
- }, [hoveredModel]);
83
+ }, [hoveredRow]);
79
84
 
80
85
  useLayoutEffect(alignCardToRow, [alignCardToRow, collapsedSections]);
81
86
 
@@ -117,6 +122,7 @@ export function ModelDropdownPanel({
117
122
  onToggleCollapse={onToggleCollapse}
118
123
  selectedModelKey={selectedModelKey}
119
124
  modelIndex={modelIndex}
125
+ ambiguousNames={ambiguousNames}
120
126
  focusedIndex={focusedIndex}
121
127
  onSelect={onSelect}
122
128
  onToggleFavorite={onToggleFavorite}
@@ -133,6 +139,7 @@ export function ModelDropdownPanel({
133
139
  onToggleCollapse={onToggleCollapse}
134
140
  selectedModelKey={selectedModelKey}
135
141
  modelIndex={modelIndex}
142
+ ambiguousNames={ambiguousNames}
136
143
  focusedIndex={focusedIndex}
137
144
  onSelect={onSelect}
138
145
  onToggleFavorite={onToggleFavorite}
@@ -151,6 +158,7 @@ export function ModelDropdownPanel({
151
158
  onToggleCollapse={onToggleCollapse}
152
159
  selectedModelKey={selectedModelKey}
153
160
  modelIndex={modelIndex}
161
+ ambiguousNames={ambiguousNames}
154
162
  focusedIndex={focusedIndex}
155
163
  onSelect={onSelect}
156
164
  onToggleFavorite={onToggleFavorite}
@@ -168,13 +176,13 @@ export function ModelDropdownPanel({
168
176
  {/* Floating Specs Card: only visible when hovering or keyboard navigating.
169
177
  `translateY` rather than a top offset keeps it out of the flex row's
170
178
  sizing, so the card can never stretch or shift the panel itself. */}
171
- {hoveredModel && (
179
+ {hoveredRow && (
172
180
  <div
173
181
  ref={cardRef}
174
182
  className="hidden lg:block ml-2"
175
183
  style={{ transform: `translateY(${cardTop}px)` }}
176
184
  >
177
- <ModelSpecsTooltip model={hoveredModel} />
185
+ <ModelSpecsTooltip model={hoveredRow.model} />
178
186
  </div>
179
187
  )}
180
188
  </div>