@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
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The guard is `String(… ?? 'unknown')`, so the row stays visible under a
|
|
17
17
|
* stable section instead of vanishing from a list the user may have selected.
|
|
18
|
+
*
|
|
19
|
+
* The second rule pinned here is row identity: `section::provider:id`. A model
|
|
20
|
+
* is drawn in a rail AND in its provider section, and a `modelKey`-keyed index
|
|
21
|
+
* could describe only one of the two — so ArrowDown stepped over the rail rows
|
|
22
|
+
* and the specs card anchored to the wrong one.
|
|
23
|
+
*
|
|
24
|
+
* The third is the rails' LABEL: FAVORITES and RECENT have no provider heading,
|
|
25
|
+
* so `ambiguousNames` (the names more than one provider serves) is what decides
|
|
26
|
+
* whether a rail row carries a provider tag. The catalog-wide cases at the
|
|
27
|
+
* bottom moved here from `usage-and-picker.test.ts`, which had grown past the
|
|
28
|
+
* 350-line ceiling — grouping is this module's subject, and the usage panel is
|
|
29
|
+
* not.
|
|
18
30
|
*/
|
|
19
31
|
|
|
20
32
|
import { describe, expect, test } from 'bun:test';
|
|
@@ -32,7 +44,7 @@ describe('buildPickerGroups', () => {
|
|
|
32
44
|
expect(Object.keys(groups.byProvider).sort()).toEqual(['P', 'UNKNOWN']);
|
|
33
45
|
expect(groups.byProvider.UNKNOWN?.map((m) => m.id)).toEqual(['b']);
|
|
34
46
|
// It is still a row the user can see and pick.
|
|
35
|
-
expect(groups.visibleFlatList.map((
|
|
47
|
+
expect(groups.visibleFlatList.map((row) => row.model.id).sort()).toEqual(['a', 'b']);
|
|
36
48
|
});
|
|
37
49
|
|
|
38
50
|
test('an empty provider string lands in the same section as a missing one', () => {
|
|
@@ -46,6 +58,73 @@ describe('buildPickerGroups', () => {
|
|
|
46
58
|
expect(groups.filtered.map((m) => m.id)).toEqual(['b']);
|
|
47
59
|
});
|
|
48
60
|
|
|
61
|
+
test('the same model drawn in a rail and in its section makes two rows', () => {
|
|
62
|
+
const rows = [
|
|
63
|
+
model({ id: 'v4', provider: 'deepseek', name: 'DeepSeek V4' }),
|
|
64
|
+
model({ id: 'v4', provider: 'kenari', name: 'DeepSeek V4' }),
|
|
65
|
+
];
|
|
66
|
+
const groups = buildPickerGroups(rows, '', {}, ['deepseek:v4'], []);
|
|
67
|
+
|
|
68
|
+
// A rail row and its provider-section copy are different rows: without this
|
|
69
|
+
// the hover index held one of the two, ArrowDown skipped the rail, and both
|
|
70
|
+
// rows highlighted together.
|
|
71
|
+
expect(groups.visibleFlatList.map((row) => row.rowId)).toEqual([
|
|
72
|
+
'favorites::deepseek:v4',
|
|
73
|
+
'DEEPSEEK::deepseek:v4',
|
|
74
|
+
'KENARI::kenari:v4',
|
|
75
|
+
]);
|
|
76
|
+
expect(groups.index['favorites::deepseek:v4']).toBe(0);
|
|
77
|
+
expect(groups.index['DEEPSEEK::deepseek:v4']).toBe(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('only a name two providers serve is ambiguous, so one row per duplicate is tagged', () => {
|
|
81
|
+
const groups = buildPickerGroups(
|
|
82
|
+
[
|
|
83
|
+
model({ id: 'v4', provider: 'deepseek', name: 'DeepSeek V4' }),
|
|
84
|
+
model({ id: 'v4', provider: 'kenari', name: 'DeepSeek V4' }),
|
|
85
|
+
model({ id: 'solo', provider: 'openai', name: 'GPT-5' }),
|
|
86
|
+
],
|
|
87
|
+
'gpt',
|
|
88
|
+
{},
|
|
89
|
+
[],
|
|
90
|
+
[],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Computed over the whole catalog, not the filtered list: a tag that came and
|
|
94
|
+
// went as the reader typed made the rows jump.
|
|
95
|
+
expect([...groups.ambiguousNames]).toEqual(['deepseek v4']);
|
|
96
|
+
expect(groups.filtered).toHaveLength(1);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('a repeated stored key draws one row, not two', () => {
|
|
100
|
+
const groups = buildPickerGroups(
|
|
101
|
+
[model({ id: 'a', provider: 'p' })],
|
|
102
|
+
'',
|
|
103
|
+
{},
|
|
104
|
+
[],
|
|
105
|
+
['p:a', 'p:a'],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Two copies of a row id would share one index and one anchor.
|
|
109
|
+
expect(groups.recent).toHaveLength(1);
|
|
110
|
+
expect(groups.visibleFlatList.map((row) => row.rowId)).toEqual(['recent::p:a', 'P::p:a']);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('one provider spelled two ways does not make its model name ambiguous', () => {
|
|
114
|
+
const groups = buildPickerGroups(
|
|
115
|
+
[model({ id: 'a', provider: 'deepseek', name: 'Flash' }), model({ id: 'b', provider: 'DeepSeek', name: 'Flash' })],
|
|
116
|
+
'',
|
|
117
|
+
{},
|
|
118
|
+
[],
|
|
119
|
+
[],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// Both rows land in the one DEEPSEEK section, so a tag would claim an
|
|
123
|
+
// ambiguity the reader cannot see.
|
|
124
|
+
expect(Object.keys(groups.byProvider)).toEqual(['DEEPSEEK']);
|
|
125
|
+
expect([...groups.ambiguousNames]).toEqual([]);
|
|
126
|
+
});
|
|
127
|
+
|
|
49
128
|
test('rows group by upper-cased provider and keep catalog order', () => {
|
|
50
129
|
const groups = buildPickerGroups(
|
|
51
130
|
[model({ id: 'a', provider: 'anthropic' }), model({ id: 'b', provider: 'Anthropic' })],
|
|
@@ -58,3 +137,87 @@ describe('buildPickerGroups', () => {
|
|
|
58
137
|
expect(groups.byProvider.ANTHROPIC?.map((m) => m.id)).toEqual(['a', 'b']);
|
|
59
138
|
});
|
|
60
139
|
});
|
|
140
|
+
|
|
141
|
+
describe('buildPickerGroups', () => {
|
|
142
|
+
const model = (provider: string, id: string, name: string, extra: Partial<AIModelOption> = {}): AIModelOption =>
|
|
143
|
+
({ id, name, provider, ...extra }) as AIModelOption;
|
|
144
|
+
|
|
145
|
+
const catalog: AIModelOption[] = [
|
|
146
|
+
model('deepseek', 'v4-flash', 'Flash', { contextWindow: 128000, capabilities: ['tools'] }),
|
|
147
|
+
model('kenari', 'v4-flash', 'Flash (Kenari)', { contextWindow: 64000 }),
|
|
148
|
+
model('openai', 'gpt-5', 'GPT-5'),
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
test('a search filters on name, provider, context window and capability', () => {
|
|
152
|
+
expect(buildPickerGroups(catalog, 'flash', {}, [], []).filtered).toHaveLength(2);
|
|
153
|
+
expect(buildPickerGroups(catalog, 'OPENAI', {}, [], []).filtered.map((m) => m.id)).toEqual(['gpt-5']);
|
|
154
|
+
expect(buildPickerGroups(catalog, '64000', {}, [], []).filtered.map((m) => m.provider)).toEqual(['kenari']);
|
|
155
|
+
expect(buildPickerGroups(catalog, 'tools', {}, [], []).filtered.map((m) => m.provider)).toEqual(['deepseek']);
|
|
156
|
+
expect(buildPickerGroups(catalog, ' ', {}, [], []).filtered).toHaveLength(3);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('the rails follow the stored key order, not the catalog order', () => {
|
|
160
|
+
const groups = buildPickerGroups(catalog, '', {}, ['openai:gpt-5', 'deepseek:v4-flash'], ['kenari:v4-flash', 'openai:gpt-5']);
|
|
161
|
+
expect(groups.favorites.map((m) => m.id)).toEqual(['gpt-5', 'v4-flash']);
|
|
162
|
+
expect(groups.recent.map((m) => m.provider)).toEqual(['kenari']);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('the rails are narrowed by the search like every other section', () => {
|
|
166
|
+
const groups = buildPickerGroups(catalog, 'flash', {}, ['openai:gpt-5', 'deepseek:v4-flash'], []);
|
|
167
|
+
expect(groups.favorites.map((m) => m.provider)).toEqual(['deepseek']);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('providers are grouped under upper-cased names in catalog order', () => {
|
|
171
|
+
const groups = buildPickerGroups(catalog, '', {}, [], []);
|
|
172
|
+
expect(Object.keys(groups.byProvider)).toEqual(['DEEPSEEK', 'KENARI', 'OPENAI']);
|
|
173
|
+
expect(groups.byProvider.DEEPSEEK).toHaveLength(1);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('the flat list renders rails first, then provider sections', () => {
|
|
177
|
+
const groups = buildPickerGroups(catalog, '', {}, ['openai:gpt-5'], ['deepseek:v4-flash']);
|
|
178
|
+
// A rail model is NOT removed from its provider section: the flat list is the
|
|
179
|
+
// order the panel walks for hover/keyboard focus, and a model appearing once
|
|
180
|
+
// under a rail and again under its provider is the shipped behavior.
|
|
181
|
+
expect(groups.visibleFlatList.map((row) => `${row.model.provider}:${row.model.id}`)).toEqual([
|
|
182
|
+
'openai:gpt-5', // favorites rail
|
|
183
|
+
'deepseek:v4-flash', // recent rail
|
|
184
|
+
'deepseek:v4-flash', // DEEPSEEK section
|
|
185
|
+
'kenari:v4-flash', // KENARI section
|
|
186
|
+
'openai:gpt-5', // OPENAI section
|
|
187
|
+
]);
|
|
188
|
+
// …and each of those five positions is its OWN row, even where two of them
|
|
189
|
+
// carry the same model.
|
|
190
|
+
expect(new Set(groups.visibleFlatList.map((row) => row.rowId)).size).toBe(5);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test('a collapsed section is dropped from the flat list but keeps its group', () => {
|
|
194
|
+
const groups = buildPickerGroups(catalog, '', { favorites: true, KENARI: true }, ['openai:gpt-5'], []);
|
|
195
|
+
expect(groups.visibleFlatList.map((row) => row.model.provider)).toEqual(['deepseek', 'openai']);
|
|
196
|
+
expect(groups.byProvider.KENARI).toHaveLength(1);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('the hover index is keyed by provider+id, so shared ids stay distinct', () => {
|
|
200
|
+
const groups = buildPickerGroups(catalog, '', {}, [], []);
|
|
201
|
+
expect(groups.index['DEEPSEEK::deepseek:v4-flash']).toBe(0);
|
|
202
|
+
expect(groups.index['KENARI::kenari:v4-flash']).toBe(1);
|
|
203
|
+
expect(groups.index['DEEPSEEK::deepseek:v4-flash'])
|
|
204
|
+
.not.toBe(groups.index['KENARI::kenari:v4-flash']);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('a row drawn twice gets two indexes and two anchors', () => {
|
|
208
|
+
// The bug this pins: a favorite is drawn in the rail and again under its
|
|
209
|
+
// provider. A `modelKey`-keyed index held only one of them, so the rails
|
|
210
|
+
// were skipped by ArrowDown and both rows lit up together.
|
|
211
|
+
const groups = buildPickerGroups(catalog, '', {}, ['openai:gpt-5'], []);
|
|
212
|
+
const rail = groups.index['favorites::openai:gpt-5'];
|
|
213
|
+
const provider = groups.index['OPENAI::openai:gpt-5'];
|
|
214
|
+
expect(rail).toBe(0);
|
|
215
|
+
expect(provider).toBeGreaterThan(rail ?? -1);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test('only a name served by two providers is marked ambiguous', () => {
|
|
219
|
+
const ambiguousCatalog = [...catalog, model('kenari', 'v4-flash-2', 'Flash', {})];
|
|
220
|
+
expect([...buildPickerGroups(ambiguousCatalog, '', {}, [], []).ambiguousNames].sort()).toEqual(['flash']);
|
|
221
|
+
expect([...buildPickerGroups(catalog, '', {}, [], []).ambiguousNames]).toEqual([]);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -6,18 +6,50 @@
|
|
|
6
6
|
import type { AIModelOption } from '@/shared/types';
|
|
7
7
|
import { modelKey } from '@/shared/lib/models/identity';
|
|
8
8
|
|
|
9
|
+
/** One rendered row: the model plus the section it is drawn in. */
|
|
10
|
+
export interface PickerRow {
|
|
11
|
+
/**
|
|
12
|
+
* Identity of the ROW, not of the model: `${section}::${modelKey}`.
|
|
13
|
+
*
|
|
14
|
+
* A model appears in a rail AND in its provider section (a favorite that is
|
|
15
|
+
* not removed from its provider list), so a `modelKey`-keyed map could only
|
|
16
|
+
* describe one of the two rows — the other's hover index pointed at its
|
|
17
|
+
* sibling, both lit up together, and the specs card anchored to whichever row
|
|
18
|
+
* `querySelector` found first.
|
|
19
|
+
*/
|
|
20
|
+
rowId: string;
|
|
21
|
+
model: AIModelOption;
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
export interface ModelPickerGroups {
|
|
10
25
|
filtered: AIModelOption[];
|
|
11
26
|
favorites: AIModelOption[];
|
|
12
27
|
recent: AIModelOption[];
|
|
13
28
|
/** Provider display name (upper-cased) → its models, in catalog order. */
|
|
14
29
|
byProvider: Record<string, AIModelOption[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Lower-cased model names served by MORE THAN ONE provider, over the whole
|
|
32
|
+
* catalog. Rows in a rail carry their provider tag only for these: an
|
|
33
|
+
* unconditional tag is noise on the 95% of rows whose name is already unique,
|
|
34
|
+
* and the rails have no provider header to disambiguate them.
|
|
35
|
+
*/
|
|
36
|
+
ambiguousNames: ReadonlySet<string>;
|
|
15
37
|
/** Sections expanded, in the order the panel renders them. */
|
|
16
|
-
visibleFlatList:
|
|
17
|
-
/**
|
|
38
|
+
visibleFlatList: PickerRow[];
|
|
39
|
+
/** Row id → index in `visibleFlatList`, for hover/keyboard focus. */
|
|
18
40
|
index: Record<string, number>;
|
|
19
41
|
}
|
|
20
42
|
|
|
43
|
+
/** Row identity: a section id plus the composite model key. */
|
|
44
|
+
export function rowIdFor(section: string, model: { provider: string; id: string }): string {
|
|
45
|
+
return `${section}::${modelKey(model)}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The name a row displays, normalized for the ambiguity check. */
|
|
49
|
+
export function normalizedModelName(model: AIModelOption): string {
|
|
50
|
+
return String(model.name ?? '').trim().toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
/**
|
|
22
54
|
* Models named by an ordered key list, in that order.
|
|
23
55
|
*
|
|
@@ -30,24 +62,56 @@ function modelsInKeyOrder(models: AIModelOption[], keys: readonly string[]): AIM
|
|
|
30
62
|
if (keys.length === 0) return [];
|
|
31
63
|
const byKey = new Map(models.map((model) => [modelKey(model), model]));
|
|
32
64
|
const ordered: AIModelOption[] = [];
|
|
65
|
+
// A key is claimed once. A stored list that repeats a key (hand-edited, or
|
|
66
|
+
// written by an older build) would otherwise draw the same row twice with the
|
|
67
|
+
// same row id, and the second copy would steal the first one's hover index
|
|
68
|
+
// and specs anchor.
|
|
69
|
+
const claimed = new Set<string>();
|
|
33
70
|
for (const key of keys) {
|
|
71
|
+
if (claimed.has(key)) continue;
|
|
34
72
|
const match = byKey.get(key);
|
|
35
|
-
if (match)
|
|
73
|
+
if (!match) continue;
|
|
74
|
+
claimed.add(key);
|
|
75
|
+
ordered.push(match);
|
|
36
76
|
}
|
|
37
77
|
return ordered;
|
|
38
78
|
}
|
|
39
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Names that cannot identify a row on their own, computed over the UNFILTERED
|
|
82
|
+
* catalog: a tag that appeared only while the search narrowed the list would
|
|
83
|
+
* flicker as the reader types.
|
|
84
|
+
*
|
|
85
|
+
* The provider is compared case-insensitively for the same reason the sections
|
|
86
|
+
* are (`DEEPSEEK` heads both `deepseek` and `DeepSeek`): one provider spelled two
|
|
87
|
+
* ways is still one provider, and tagging those rows would claim an ambiguity
|
|
88
|
+
* that does not exist.
|
|
89
|
+
*/
|
|
90
|
+
function findAmbiguousNames(models: AIModelOption[]): ReadonlySet<string> {
|
|
91
|
+
const providersByName = new Map<string, Set<string>>();
|
|
92
|
+
for (const model of models) {
|
|
93
|
+
const name = normalizedModelName(model);
|
|
94
|
+
if (!name) continue;
|
|
95
|
+
const providers = providersByName.get(name) ?? new Set<string>();
|
|
96
|
+
providers.add(String(model.provider || 'unknown').toUpperCase());
|
|
97
|
+
providersByName.set(name, providers);
|
|
98
|
+
}
|
|
99
|
+
const ambiguous = new Set<string>();
|
|
100
|
+
for (const [name, providers] of providersByName) {
|
|
101
|
+
if (providers.size > 1) ambiguous.add(name);
|
|
102
|
+
}
|
|
103
|
+
return ambiguous;
|
|
104
|
+
}
|
|
105
|
+
|
|
40
106
|
/**
|
|
41
107
|
* All derived picker state in one place: search filtering, the favorites/recent
|
|
42
|
-
* rails, the per-provider grouping, and the flattened
|
|
108
|
+
* rails, the per-provider grouping, and the flattened row→index map the
|
|
43
109
|
* keyboard navigation addresses rows through.
|
|
44
110
|
*
|
|
45
|
-
* Keying `index` on the
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* A row never appears twice: a favorite that is also recent is only listed under
|
|
50
|
-
* FAVORITES, and neither rail repeats the row in its provider section.
|
|
111
|
+
* Keying `index` on the ROW matters twice over: the same model id is served by
|
|
112
|
+
* several providers (an id-only key lit every provider's row), and one model is
|
|
113
|
+
* drawn in a rail and again in its provider section (a model-keyed index
|
|
114
|
+
* collapsed those two rows onto one entry).
|
|
51
115
|
*/
|
|
52
116
|
export function buildPickerGroups(
|
|
53
117
|
models: AIModelOption[],
|
|
@@ -85,17 +149,30 @@ export function buildPickerGroups(
|
|
|
85
149
|
(byProvider[provider] ??= []).push(model);
|
|
86
150
|
}
|
|
87
151
|
|
|
88
|
-
const visibleFlatList:
|
|
89
|
-
|
|
90
|
-
|
|
152
|
+
const visibleFlatList: PickerRow[] = [];
|
|
153
|
+
const push = (section: string, sectionModels: AIModelOption[]) => {
|
|
154
|
+
for (const model of sectionModels) {
|
|
155
|
+
visibleFlatList.push({ rowId: rowIdFor(section, model), model });
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
if (!collapsedSections['favorites']) push('favorites', favorites);
|
|
159
|
+
if (!collapsedSections['recent']) push('recent', recent);
|
|
91
160
|
for (const [provider, groupModels] of Object.entries(byProvider)) {
|
|
92
|
-
if (!collapsedSections[provider])
|
|
161
|
+
if (!collapsedSections[provider]) push(provider, groupModels);
|
|
93
162
|
}
|
|
94
163
|
|
|
95
164
|
const index: Record<string, number> = {};
|
|
96
|
-
visibleFlatList.forEach((
|
|
97
|
-
index[
|
|
165
|
+
visibleFlatList.forEach((row, i) => {
|
|
166
|
+
index[row.rowId] = i;
|
|
98
167
|
});
|
|
99
168
|
|
|
100
|
-
return {
|
|
169
|
+
return {
|
|
170
|
+
filtered,
|
|
171
|
+
favorites,
|
|
172
|
+
recent,
|
|
173
|
+
byProvider,
|
|
174
|
+
ambiguousNames: findAmbiguousNames(models),
|
|
175
|
+
visibleFlatList,
|
|
176
|
+
index,
|
|
177
|
+
};
|
|
101
178
|
}
|
|
@@ -8,7 +8,7 @@ import { ModelDropdownPanel } from '@/client/components/workspace/model-dropdown
|
|
|
8
8
|
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
9
9
|
import { useModelCatalog } from '@/client/components/workspace/model-dropdown/use-catalog';
|
|
10
10
|
import { useCollapsedSections } from '@/client/components/workspace/model-dropdown/collapsed';
|
|
11
|
-
import { buildPickerGroups } from '@/client/components/workspace/model-dropdown/groups';
|
|
11
|
+
import { buildPickerGroups, type PickerRow } from '@/client/components/workspace/model-dropdown/groups';
|
|
12
12
|
import { modelKey } from '@/shared/lib/models/identity';
|
|
13
13
|
import { RECENT_MODELS_LIMIT, filterKnownKeys, readModelPreferences, recordRecentKey, toggleFavoriteKey } from '@/shared/lib/models/preferences';
|
|
14
14
|
|
|
@@ -30,7 +30,10 @@ export function ModelDropdown({
|
|
|
30
30
|
const [isOpen, setIsOpen] = useState(false);
|
|
31
31
|
const [search, setSearch] = useState('');
|
|
32
32
|
const [focusedIndex, setFocusedIndex] = useState<number>(-1);
|
|
33
|
-
|
|
33
|
+
// Hover is a ROW, not a model: one model can be drawn twice (its rail and its
|
|
34
|
+
// provider section), and both the specs card and the keyboard focus have to
|
|
35
|
+
// address the row the pointer is actually on.
|
|
36
|
+
const [hoveredRow, setHoveredRow] = useState<PickerRow | null>(null);
|
|
34
37
|
const [collapsedSections, toggleSection] = useCollapsedSections();
|
|
35
38
|
const {
|
|
36
39
|
models,
|
|
@@ -71,7 +74,7 @@ export function ModelDropdown({
|
|
|
71
74
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
72
75
|
useOnClickOutside(containerRef, () => {
|
|
73
76
|
setIsOpen(false);
|
|
74
|
-
|
|
77
|
+
setHoveredRow(null);
|
|
75
78
|
setFocusedIndex(-1);
|
|
76
79
|
});
|
|
77
80
|
|
|
@@ -80,6 +83,7 @@ export function ModelDropdown({
|
|
|
80
83
|
favorites: favoriteModels,
|
|
81
84
|
recent: recentModels,
|
|
82
85
|
byProvider: providerGroups,
|
|
86
|
+
ambiguousNames,
|
|
83
87
|
visibleFlatList,
|
|
84
88
|
index: modelIndex,
|
|
85
89
|
} = useMemo(
|
|
@@ -91,7 +95,7 @@ export function ModelDropdown({
|
|
|
91
95
|
|
|
92
96
|
const handleAddProviderClick = () => {
|
|
93
97
|
setIsOpen(false);
|
|
94
|
-
|
|
98
|
+
setHoveredRow(null);
|
|
95
99
|
if (onOpenAddProvider) {
|
|
96
100
|
onOpenAddProvider();
|
|
97
101
|
} else {
|
|
@@ -180,7 +184,7 @@ export function ModelDropdown({
|
|
|
180
184
|
setSelectedModel(model);
|
|
181
185
|
onSelectModel?.(model);
|
|
182
186
|
setIsOpen(false);
|
|
183
|
-
|
|
187
|
+
setHoveredRow(null);
|
|
184
188
|
// Move the pick to the top of RECENT straight away — the server records it
|
|
185
189
|
// alongside the selection, and waiting for the round trip would leave the
|
|
186
190
|
// rail stale until the next full reload. Same rules as the server's write:
|
|
@@ -200,38 +204,38 @@ export function ModelDropdown({
|
|
|
200
204
|
} catch {}
|
|
201
205
|
};
|
|
202
206
|
|
|
207
|
+
/** The focused row, or the one under the pointer when no row is focused. */
|
|
208
|
+
const activeRow = (focusedIndex >= 0 ? visibleFlatList[focusedIndex] : null) || hoveredRow;
|
|
209
|
+
|
|
203
210
|
const handleKeyDown = (e: globalThis.KeyboardEvent) => {
|
|
204
211
|
if (!isOpen) return;
|
|
205
212
|
if (e.key === 'ArrowDown') {
|
|
206
213
|
e.preventDefault();
|
|
207
214
|
setFocusedIndex(prev => {
|
|
208
215
|
const next = (prev + 1) % Math.max(1, visibleFlatList.length);
|
|
209
|
-
|
|
216
|
+
setHoveredRow(visibleFlatList[next] || null);
|
|
210
217
|
return next;
|
|
211
218
|
});
|
|
212
219
|
} else if (e.key === 'ArrowUp') {
|
|
213
220
|
e.preventDefault();
|
|
214
221
|
setFocusedIndex(prev => {
|
|
215
222
|
const prevIdx = (prev - 1 + visibleFlatList.length) % Math.max(1, visibleFlatList.length);
|
|
216
|
-
|
|
223
|
+
setHoveredRow(visibleFlatList[prevIdx] || null);
|
|
217
224
|
return prevIdx;
|
|
218
225
|
});
|
|
219
226
|
} else if (e.key === 'Enter') {
|
|
220
227
|
e.preventDefault();
|
|
221
|
-
|
|
222
|
-
if (target) handleSelect(target);
|
|
228
|
+
if (activeRow) handleSelect(activeRow.model);
|
|
223
229
|
} else if (e.key === 'Escape') {
|
|
224
230
|
e.preventDefault();
|
|
225
231
|
setIsOpen(false);
|
|
226
|
-
|
|
232
|
+
setHoveredRow(null);
|
|
227
233
|
} else if (e.key === 'Tab') {
|
|
228
234
|
e.preventDefault();
|
|
229
|
-
|
|
230
|
-
if (target) toggleAgentCmd(target);
|
|
235
|
+
if (activeRow) toggleAgentCmd(activeRow.model);
|
|
231
236
|
} else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
|
232
237
|
e.preventDefault();
|
|
233
|
-
|
|
234
|
-
if (target) cycleThinkingLevel(target);
|
|
238
|
+
if (activeRow) cycleThinkingLevel(activeRow.model);
|
|
235
239
|
}
|
|
236
240
|
};
|
|
237
241
|
|
|
@@ -242,7 +246,7 @@ export function ModelDropdown({
|
|
|
242
246
|
type="button"
|
|
243
247
|
onClick={() => {
|
|
244
248
|
setIsOpen(prev => !prev);
|
|
245
|
-
|
|
249
|
+
setHoveredRow(null);
|
|
246
250
|
setFocusedIndex(-1);
|
|
247
251
|
}}
|
|
248
252
|
className="flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full"
|
|
@@ -292,20 +296,24 @@ export function ModelDropdown({
|
|
|
292
296
|
favoriteModels={favoriteModels}
|
|
293
297
|
recentModels={recentModels}
|
|
294
298
|
providerGroups={providerGroups}
|
|
299
|
+
ambiguousNames={ambiguousNames}
|
|
295
300
|
collapsedSections={collapsedSections}
|
|
296
301
|
onToggleCollapse={toggleSection}
|
|
297
302
|
selectedModelKey={selectedModelKey}
|
|
298
303
|
modelIndex={modelIndex}
|
|
299
304
|
focusedIndex={focusedIndex}
|
|
300
|
-
|
|
305
|
+
hoveredRow={hoveredRow}
|
|
301
306
|
onSelect={handleSelect}
|
|
302
307
|
onToggleFavorite={handleToggleFavorite}
|
|
303
308
|
onCycleThinking={cycleThinkingLevel}
|
|
304
|
-
onHoverItem={(idx
|
|
309
|
+
onHoverItem={(idx) => {
|
|
305
310
|
setFocusedIndex(idx);
|
|
306
|
-
|
|
311
|
+
// The flat list is the one order the panel renders, so an index is
|
|
312
|
+
// enough to name the exact row — including which of a model's two
|
|
313
|
+
// rows the pointer is on.
|
|
314
|
+
setHoveredRow(visibleFlatList[idx] ?? null);
|
|
307
315
|
}}
|
|
308
|
-
onMouseLeave={() =>
|
|
316
|
+
onMouseLeave={() => setHoveredRow(null)}
|
|
309
317
|
/>
|
|
310
318
|
)}
|
|
311
319
|
</div>
|