@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.
Files changed (148) 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-bnrrw242.css +1 -0
  4. package/dist/client/static/js/{index-vzb1qz51.js → index-w6jx0h0p.js} +780 -780
  5. package/marketplace/plugins/command-runner/package.json +2 -2
  6. package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
  7. package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
  8. package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
  9. package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
  10. package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
  11. package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
  12. package/package.json +2 -2
  13. package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
  14. package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
  15. package/src/client/components/common/code-surface/extensions.ts +7 -1
  16. package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
  17. package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
  18. package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
  19. package/src/client/components/common/session-row/index.tsx +215 -0
  20. package/src/client/components/common/session-row/session-row.test.tsx +154 -0
  21. package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
  22. package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
  23. package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
  24. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
  25. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
  26. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
  27. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +56 -0
  28. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +193 -0
  29. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
  30. package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
  31. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
  32. package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
  33. package/src/client/components/mobile/SessionSidebar.tsx +137 -146
  34. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
  35. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
  36. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
  37. package/src/client/components/settings/Modal.tsx +5 -27
  38. package/src/client/components/settings/Sidebar.tsx +1 -1
  39. package/src/client/components/settings/apply-side-effects.test.ts +102 -0
  40. package/src/client/components/settings/apply-side-effects.ts +90 -0
  41. package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
  42. package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
  43. package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
  44. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
  45. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
  46. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
  47. package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
  48. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
  49. package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
  50. package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
  51. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
  52. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
  53. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +15 -5
  55. package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
  56. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
  57. package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
  58. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +117 -75
  59. package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
  60. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
  61. package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
  62. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +178 -0
  63. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
  64. package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
  65. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
  66. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
  67. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
  68. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
  69. package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
  70. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
  71. package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
  73. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
  80. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
  81. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
  82. package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
  83. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
  84. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
  85. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
  86. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
  87. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
  88. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
  89. package/src/client/components/workspace/diff-panel/folding.ts +6 -1
  90. package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
  91. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
  92. package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
  93. package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
  94. package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
  95. package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
  96. package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
  97. package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
  98. package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
  99. package/src/client/data/settings/omp-schema.json +151 -6
  100. package/src/client/hooks/chat/composer/style.ts +66 -0
  101. package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
  102. package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
  103. package/src/client/hooks/chat/timeline/row-window.ts +59 -133
  104. package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
  105. package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
  106. package/src/client/hooks/settings/providers/login.ts +11 -2
  107. package/src/client/hooks/ui/window-event.ts +20 -4
  108. package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
  109. package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
  110. package/src/client/hooks/workspace/batch-archive.ts +78 -0
  111. package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
  112. package/src/client/hooks/workspace/sidebar-style.ts +66 -0
  113. package/src/client/tailwind.css +111 -0
  114. package/src/server/index.ts +10 -134
  115. package/src/server/lib/lifecycle/after-listen.ts +178 -0
  116. package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
  117. package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
  118. package/src/server/lib/lifecycle/tls.test.ts +7 -7
  119. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
  120. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
  121. package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
  122. package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
  123. package/src/server/lib/plugins/background.server.ts +17 -1
  124. package/src/server/lib/plugins/background.test.ts +33 -0
  125. package/src/server/routes/sessions/batch-archive.test.ts +113 -0
  126. package/src/server/routes/sessions/batch-archive.ts +80 -0
  127. package/src/server/routes/sessions/index.ts +4 -0
  128. package/src/shared/lib/chat/composer/style.test.ts +126 -0
  129. package/src/shared/lib/chat/composer/style.ts +171 -0
  130. package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
  131. package/src/shared/lib/chat/composer/tui-only.ts +5 -0
  132. package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
  133. package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
  134. package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
  135. package/src/shared/lib/chat/timeline/trace-groups.test.ts +132 -0
  136. package/src/shared/lib/chat/timeline/trace-groups.ts +95 -0
  137. package/src/shared/lib/settings/defaults.ts +6 -0
  138. package/src/shared/lib/workspace/session-focus.test.ts +93 -0
  139. package/src/shared/lib/workspace/session-focus.ts +71 -0
  140. package/src/shared/lib/workspace/session-state/store.ts +5 -0
  141. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
  142. package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
  143. package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
  144. package/src/shared/lib/workspace/sidebar-style.ts +86 -0
  145. package/src/shared/types/omp/agent.ts +6 -0
  146. package/src/shared/types/settings/state.ts +31 -0
  147. package/dist/client/static/js/index-68w8h33q.css +0 -1
  148. package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
@@ -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>
@@ -22,6 +22,7 @@ import { Window } from 'happy-dom';
22
22
  import { h, render } from 'preact';
23
23
  import { act } from 'preact/test-utils';
24
24
  import { ModelDropdownSection } from '@/client/components/workspace/model-dropdown/Section';
25
+ import { buildPickerGroups } from '@/client/components/workspace/model-dropdown/groups';
25
26
  import { modelKey } from '@/shared/lib/models/identity';
26
27
  import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
27
28
  import type { AIModelOption } from '@/shared/types';
@@ -42,7 +43,7 @@ afterEach(() => {
42
43
  restoreDomGlobals();
43
44
  });
44
45
 
45
- function mountSection(): void {
46
+ function mountSection(overrides: Partial<Parameters<typeof ModelDropdownSection>[0]> = {}): void {
46
47
  act(() => {
47
48
  render(
48
49
  h(ModelDropdownSection, {
@@ -53,11 +54,13 @@ function mountSection(): void {
53
54
  onToggleCollapse: () => {},
54
55
  selectedModelKey: '',
55
56
  modelIndex: {},
57
+ ambiguousNames: new Set<string>(),
56
58
  focusedIndex: -1,
57
59
  onSelect: () => {},
58
60
  onToggleFavorite: () => {},
59
61
  onCycleThinking: () => {},
60
62
  onHoverItem: () => {},
63
+ ...overrides,
61
64
  }),
62
65
  container,
63
66
  );
@@ -120,12 +123,119 @@ describe('model picker section header columns', () => {
120
123
  expect(chevronSlot.querySelector('svg')).not.toBeNull();
121
124
  });
122
125
 
123
- test('a row carries its composite key, which the specs card anchors to', () => {
126
+ test('a row carries its row id, which the specs card anchors to', () => {
124
127
  mountSection();
125
128
 
126
129
  // Without this the card has no row to sit beside and falls back to the
127
- // panel's own top — the drift that made it describe a model rows away.
130
+ // panel's own top — the drift that made it describe a model rows away. The
131
+ // anchor is the ROW, not the model: one model is drawn twice.
128
132
  const row = container.querySelector('[role="button"]') as HTMLElement;
129
- expect(row.getAttribute('data-model-key')).toBe(modelKey(MODELS[0]));
133
+ expect(row.getAttribute('data-picker-row')).toBe(`DEEPSEEK::${modelKey(MODELS[0])}`);
134
+ });
135
+ });
136
+
137
+ describe('model picker rail rows and the provider tag', () => {
138
+ const SHARED: AIModelOption[] = [
139
+ { id: 'v4-pro', name: 'DeepSeek V4 Pro', provider: 'deepseek' },
140
+ { id: 'v4-pro', name: 'DeepSeek V4 Pro', provider: 'kenari' },
141
+ ];
142
+
143
+ /** The provider tag is the only `span` whose text is a bare provider slug. */
144
+ function tags(): HTMLElement[] {
145
+ return Array.from(container.querySelectorAll('[role="button"] span')).filter(
146
+ (span) => (span.getAttribute('title') ?? '').startsWith('Provider: '),
147
+ ) as HTMLElement[];
148
+ }
149
+
150
+ test('a rail row tags a name that two providers serve', () => {
151
+ mountSection({ id: 'favorites', title: 'FAVORITES', iconType: 'star', models: SHARED, ambiguousNames: new Set(['deepseek v4 pro']) });
152
+
153
+ const rendered = tags().map((tag) => tag.textContent);
154
+ expect(rendered).toEqual(['deepseek', 'kenari']);
155
+ });
156
+
157
+ test('a rail row stays untagged when the name is unique to one provider', () => {
158
+ mountSection({ id: 'recent', title: 'RECENT', iconType: 'recent', ambiguousNames: new Set() });
159
+
160
+ expect(tags()).toEqual([]);
161
+ });
162
+
163
+ test('a provider section never tags a row — its header already says so', () => {
164
+ // The same rows, drawn under the DEEPSEEK heading: a tag here would repeat
165
+ // the section title on every line.
166
+ mountSection({ models: SHARED, ambiguousNames: new Set(['deepseek v4 pro']) });
167
+
168
+ expect(tags()).toEqual([]);
169
+ });
170
+
171
+ test('the tag never shrinks or wraps, so `kenari` and `kenari-jatis` stay distinguishable', () => {
172
+ mountSection({
173
+ id: 'recent',
174
+ title: 'RECENT',
175
+ iconType: 'recent',
176
+ models: [{ id: 'x', name: 'Shared', provider: 'kenari-jatis' }],
177
+ ambiguousNames: new Set(['shared']),
178
+ });
179
+
180
+ const [tag] = tags();
181
+ expect(tag?.className).toContain('shrink-0');
182
+ expect(tag?.className).toContain('whitespace-nowrap');
183
+ // The name is the only cell that gives up width.
184
+ const name = container.querySelector('[role="button"] span[title^="Shared"]') as HTMLElement;
185
+ expect(name.className).toContain('truncate');
186
+ expect(name.getAttribute('title')).toBe('Shared · kenari-jatis');
187
+ });
188
+
189
+ test('each row anchors on its own id, not on the model it shows', () => {
190
+ mountSection({ id: 'favorites', title: 'FAVORITES', iconType: 'star', models: SHARED.slice(0, 1) });
191
+
192
+ const row = container.querySelector('[role="button"][data-picker-row]') as HTMLElement;
193
+ expect(row.getAttribute('data-picker-row')).toBe('favorites::deepseek:v4-pro');
194
+ });
195
+
196
+ test('the rail copy and the provider copy of one model report different rows', () => {
197
+ // The end-to-end shape of the bug: a favorite is drawn in the rail and again
198
+ // under its provider, and before row ids the two resolved to one index — so
199
+ // ArrowDown stepped over the rail and both rows highlighted together.
200
+ const groups = buildPickerGroups(SHARED, '', {}, ['deepseek:v4-pro'], []);
201
+ const hovered: number[] = [];
202
+ const onHoverItem = (index: number) => hovered.push(index);
203
+
204
+ act(() => {
205
+ render(
206
+ h(ModelDropdownSection, {
207
+ id: 'favorites',
208
+ title: 'FAVORITES',
209
+ iconType: 'star',
210
+ models: groups.favorites,
211
+ isCollapsed: false,
212
+ onToggleCollapse: () => {},
213
+ selectedModelKey: '',
214
+ modelIndex: groups.index,
215
+ ambiguousNames: groups.ambiguousNames,
216
+ focusedIndex: -1,
217
+ onSelect: () => {},
218
+ onToggleFavorite: () => {},
219
+ onCycleThinking: () => {},
220
+ onHoverItem,
221
+ }),
222
+ container,
223
+ );
224
+ });
225
+
226
+ // happy-dom has no `MouseEvent` on the test global, so the event comes off
227
+ // the document's own view; Preact proxies `onMouseEnter` through `mouseover`.
228
+ const view = container.ownerDocument.defaultView as unknown as {
229
+ Event: new (type: string, init: { bubbles: boolean }) => Event;
230
+ };
231
+ const row = container.querySelector('[role="button"][data-picker-row]') as HTMLElement;
232
+ act(() => {
233
+ row.dispatchEvent(new view.Event('mouseover', { bubbles: true }));
234
+ row.dispatchEvent(new view.Event('mouseenter', { bubbles: false }));
235
+ });
236
+
237
+ expect(hovered).toEqual([0]);
238
+ // …and the provider section's copy of the same model is a different index.
239
+ expect(groups.index['DEEPSEEK::deepseek:v4-pro']).not.toBe(0);
130
240
  });
131
241
  });
@@ -2,6 +2,7 @@ import type { TargetedMouseEvent } from 'preact';
2
2
  import { ChevronDown, ChevronUp, History, Star } from 'lucide-preact';
3
3
  import type { AIModelOption } from '@/shared/types';
4
4
  import { ModelDropdownItem } from '@/client/components/workspace/model-dropdown/Item';
5
+ import { normalizedModelName, rowIdFor } from '@/client/components/workspace/model-dropdown/groups';
5
6
  import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
6
7
  import { modelKey } from '@/shared/lib/models/identity';
7
8
 
@@ -14,13 +15,16 @@ interface ModelDropdownSectionProps {
14
15
  onToggleCollapse: (id: string) => void;
15
16
  /** Composite (`provider:id`) key of the active selection. */
16
17
  selectedModelKey: string;
17
- /** Composite key → index in the keyboard-navigation flat list. */
18
+ /** Row id (`section::provider:id`) → index in the keyboard-navigation flat list. */
18
19
  modelIndex: Record<string, number>;
20
+ /** Lower-cased model names served by more than one provider. */
21
+ ambiguousNames: ReadonlySet<string>;
19
22
  focusedIndex: number;
20
23
  onSelect: (model: AIModelOption) => void;
21
24
  onToggleFavorite: (model: AIModelOption, e: TargetedMouseEvent<HTMLElement>) => void;
22
25
  onCycleThinking: (model: AIModelOption, e: TargetedMouseEvent<HTMLElement>) => void;
23
- onHoverItem: (index: number, model: AIModelOption) => void;
26
+ /** Row index in the flat list; the panel resolves it to the row it renders. */
27
+ onHoverItem: (index: number) => void;
24
28
  }
25
29
 
26
30
  export function ModelDropdownSection({
@@ -32,6 +36,7 @@ export function ModelDropdownSection({
32
36
  onToggleCollapse,
33
37
  selectedModelKey,
34
38
  modelIndex,
39
+ ambiguousNames,
35
40
  focusedIndex,
36
41
  onSelect,
37
42
  onToggleFavorite,
@@ -92,20 +97,27 @@ export function ModelDropdownSection({
92
97
  {!isCollapsed && (
93
98
  <div className="space-y-0.5">
94
99
  {models.map((m) => {
95
- // Identity is provider + id: the same model id is served by several
96
- // providers, so an id-only match would focus/select their rows too.
97
- const key = modelKey(m);
98
- const index = modelIndex[key] ?? -1;
100
+ // Identity is per ROW, not per model: the same model id is served
101
+ // by several providers, and one model is drawn in a rail AND in its
102
+ // provider section. `section::provider:id` keeps every row's hover
103
+ // index and specs anchor its own.
104
+ const rowId = rowIdFor(id, m);
105
+ const index = modelIndex[rowId] ?? -1;
99
106
  return (
100
107
  <ModelDropdownItem
101
- key={`${id}-${key}`}
108
+ key={rowId}
109
+ rowId={rowId}
102
110
  model={m}
103
- isSelected={selectedModelKey === key}
111
+ // A rail has no provider heading above it, so a name shared by
112
+ // two providers would render twice identically. A provider
113
+ // section already says the provider in its header.
114
+ showProvider={iconType !== 'provider' && ambiguousNames.has(normalizedModelName(m))}
115
+ isSelected={selectedModelKey === modelKey(m)}
104
116
  isFocused={focusedIndex === index}
105
117
  onSelect={onSelect}
106
118
  onToggleFavorite={onToggleFavorite}
107
119
  onCycleThinking={onCycleThinking}
108
- onMouseEnter={() => onHoverItem(index, m)}
120
+ onMouseEnter={() => onHoverItem(index)}
109
121
  />
110
122
  );
111
123
  })}