@lynn123411/dsh-model-submenu 0.3.19 → 0.3.20

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/lib/index.js CHANGED
@@ -1,4 +1,34 @@
1
+ //#region src/account-model-facts.ts
2
+ const ACCOUNT_PROVIDER = "deepseek-account";
3
+ const ACCOUNT_FACTS_PATH = "/api/dsh-model-submenu/account-model-facts";
4
+ //#endregion
1
5
  //#region src/index.ts
2
- function apply() {}
6
+ function apply(ctx) {
7
+ ctx.inject(["connection", "llm"], (scope) => {
8
+ const { connection } = scope;
9
+ return connection.fetch.register({
10
+ path: ACCOUNT_FACTS_PATH,
11
+ methods: ["GET"],
12
+ requestBody: "buffered",
13
+ async fetch(request) {
14
+ try {
15
+ const llm = scope.llm;
16
+ const models = llm.listProviders().some((provider) => provider.id === "deepseek-account") ? await llm.listModels(ACCOUNT_PROVIDER) : [];
17
+ const rows = (await Promise.allSettled(models.map(async (model) => {
18
+ const info = await llm.resolveModelInfo(ACCOUNT_PROVIDER, model.id, request.signal);
19
+ return {
20
+ id: model.id,
21
+ ...info.context === void 0 ? {} : { contextWindow: info.context.contextWindow },
22
+ ...info.inputModalities === void 0 ? {} : { inputModalities: info.inputModalities }
23
+ };
24
+ }))).flatMap((result) => result.status === "fulfilled" ? [result.value] : []);
25
+ return Response.json(rows, { headers: { "Cache-Control": "no-store" } });
26
+ } catch {
27
+ return new Response(null, { status: 503 });
28
+ }
29
+ }
30
+ });
31
+ });
32
+ }
3
33
  //#endregion
4
34
  export { apply };
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Model picker",
4
- "description": "Open the quick list from the model row, or use its right arrow to browse all models. Adjust reasoning effort with a colored slider.",
4
+ "description": "Click the model row for the current model and favorites, or use its right arrow to search and star models across providers. Set the level in DSH’s Reasoning effort menu. The picker restores each model’s last-used level when you switch.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "模型选择",
4
- "description": "点击模型行切换当前或收藏的模型,点击右侧箭头浏览全部模型。推理等级可用带配色的滑块调整。",
4
+ "description": "点击模型行打开当前模型和收藏的快捷列表,点击右侧箭头搜索或收藏全部供应商的模型。用 DSH 的「推理等级」选择档位,切换模型时恢复它上次使用的档位。",
5
5
  "detail": "docs/DETAIL.zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lynn123411/dsh-model-submenu",
3
- "version": "0.3.19",
4
- "description": "点击模型行切换当前或收藏的模型,点击右侧箭头浏览全部模型。推理等级可用带配色的滑块调整。",
3
+ "version": "0.3.20",
4
+ "description": "点击模型行切换当前或收藏的模型,点击右侧箭头浏览全部模型。",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@11.7.0",
7
7
  "publishConfig": {
@@ -61,7 +61,7 @@
61
61
  "smoke": "node scripts/smoke-client.mjs",
62
62
  "assert:lib-untracked": "node scripts/assert-lib-untracked.mjs",
63
63
  "check": "pnpm typecheck && pnpm build && pnpm smoke && pnpm test && pnpm assert:lib-untracked",
64
- "test": "node scripts/test-favorites.mjs && node scripts/test-facts.mjs && node scripts/test-commit.mjs && node scripts/test-rows.mjs && node scripts/test-effort-memory.mjs && node scripts/test-slider.mjs && node scripts/test-render.mjs"
64
+ "test": "node scripts/test-favorites.mjs && node scripts/test-facts.mjs && node scripts/test-commit.mjs && node scripts/test-rows.mjs && node scripts/test-effort-memory.mjs && node scripts/test-render.mjs"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@deepseek-ai/cordis": "^4.2.0-alpha.2",
@@ -79,6 +79,7 @@
79
79
  "@deepseek-ai/cordis-plugin-include": "1.2.0-alpha.2",
80
80
  "@deepseek-ai/dsh-api-remotes": ">=0.2.3-alpha.3",
81
81
  "@deepseek-ai/dsh-api-session-controller": ">=0.2.3-alpha.3",
82
+ "@deepseek-ai/dsh-client-connection": ">=0.2.3-alpha.3",
82
83
  "@deepseek-ai/dsh-client-locale": ">=0.2.3-alpha.3",
83
84
  "@deepseek-ai/dsh-client-ui-conversation": ">=0.2.3-alpha.3",
84
85
  "@deepseek-ai/dsh-client-ui-model-selection": ">=0.2.3-alpha.3",
@@ -86,6 +87,7 @@
86
87
  "@deepseek-ai/dsh-client-ui-renderer": ">=0.2.3-alpha.3",
87
88
  "@deepseek-ai/dsh-client-ui-settings": ">=0.2.3-alpha.3",
88
89
  "@deepseek-ai/dsh-client-ui-slots": ">=0.2.3-alpha.3",
90
+ "@deepseek-ai/dsh-llm": ">=0.2.3-alpha.3",
89
91
  "@deepseek-ai/dsh-util-text-search": ">=0.2.3-alpha.3",
90
92
  "@types/node": "^22.20.0",
91
93
  "@types/react": "~19.3.0",
@@ -0,0 +1,8 @@
1
+ export const ACCOUNT_PROVIDER = 'deepseek-account'
2
+ export const ACCOUNT_FACTS_PATH = '/api/dsh-model-submenu/account-model-facts'
3
+
4
+ export interface AccountModelFacts {
5
+ readonly id: string
6
+ readonly contextWindow?: number
7
+ readonly inputModalities?: readonly string[]
8
+ }
@@ -1,74 +1,47 @@
1
- import { useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
1
+ import { useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { IconChevronRightOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives';
4
4
  import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
5
5
  import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
6
- import { EffortSlider } from './EffortSlider.tsx';
7
6
  import { QUICK_MODELS_PANE } from './QuickModels.tsx';
8
7
  import type { PickerStore } from './picker-state.ts';
9
- import { effortChoices, liveReasoning, planEffortCommit, selectionOf, type Selection } from './selection.ts';
10
8
  import css from './ModelOptions.module.css';
11
9
 
12
10
  const cellLabel = ':scope > span[class*="cellLabel"]';
13
11
  const cellValue = ':scope > span[class*="cellValue"]';
14
12
  const cellChevron = ':scope > svg[class*="cellChevron"]';
15
13
 
16
- function hostCell(surface: HTMLElement, index: number): HTMLButtonElement | null {
17
- const button = surface.querySelectorAll<HTMLButtonElement>(':scope > button[role="menuitem"]')[index];
14
+ function hostModelRow(surface: HTMLElement): HTMLButtonElement | null {
15
+ const button = surface.querySelector<HTMLButtonElement>(':scope > button[role="menuitem"]');
18
16
  if (!button?.querySelector(cellLabel) || !button.querySelector(cellValue) || !button.querySelector(cellChevron)) return null;
19
17
  return button;
20
18
  }
21
19
 
22
20
  export type ModelMenuBridgeProps = PropsRuntime<'conversation.input.model.options'>
23
21
  & PropsLocale<'modelSubmenu'>
24
- & Pick<ModelSelectInjected, 'available' | 'directory' | 'select'>
22
+ & Pick<ModelSelectInjected, 'available' | 'directory'>
25
23
  & {
26
24
  readonly sessionId: string;
27
25
  readonly picker: PickerStore;
28
26
  }
29
27
 
30
28
  export function ModelMenuBridge({
31
- sessionId, picker, locked, dismiss, openPane, reportFailure, available, directory, select, t,
29
+ sessionId, picker, locked, dismiss, openPane, available, directory, t,
32
30
  }: ModelMenuBridgeProps) {
33
31
  const markerRef = useRef<HTMLSpanElement | null>(null);
34
- const sliderRef = useRef<HTMLDivElement | null>(null);
35
- const [surface, setSurface] = useState<HTMLElement | null>(null);
36
32
  const [modelRow, setModelRow] = useState<HTMLButtonElement | null>(null);
37
33
  const [browseMount, setBrowseMount] = useState<HTMLElement | null>(null);
38
- const [effortRow, setEffortRow] = useState<HTMLElement | null>(null);
39
- const [rowLabel, setRowLabel] = useState<string | null>(null);
40
34
 
41
35
  const state = useSyncExternalStore(
42
36
  (listener) => directory.subscribe(listener),
43
37
  () => directory.getSnapshot(),
44
38
  );
45
- const current = state.current;
46
- const reasoning = liveReasoning(state);
47
- const levels = useMemo(() => effortChoices(reasoning), [reasoning]);
48
- const declared = levels.findIndex((level) => level.effort === reasoning?.defaultEffort);
49
- const chosen = current?.reasoningEffort === undefined
50
- ? -1
51
- : levels.findIndex((level) => level.effort === current.reasoningEffort);
52
- const defaultActive = current !== null && current.reasoningEffort === undefined;
53
- const currentIndex = chosen >= 0 ? chosen : declared >= 0 ? declared : 0;
54
- const defaultIndex = declared >= 0 ? declared : 0;
55
39
  const busy = locked || state.pending !== null;
56
- const canDefault = !busy && !defaultActive;
57
40
  const showQuickModels = available && modelRow !== null && browseMount !== null;
58
- const showSlider = available && levels.length >= 2 && effortRow !== null;
59
-
60
- useLayoutEffect(() => {
61
- const nextSurface = markerRef.current?.closest<HTMLElement>('[data-model-menu][role="menu"]') ?? null;
62
- if (nextSurface !== surface) setSurface(nextSurface);
63
- const nextRow = nextSurface === null ? null : hostCell(nextSurface, 1);
64
- if (nextRow !== effortRow) setEffortRow(nextRow);
65
- const nextLabel = nextRow?.querySelector(cellLabel)?.textContent?.trim() ?? '';
66
- if (nextLabel !== (rowLabel ?? '')) setRowLabel(nextLabel);
67
- });
68
41
 
69
42
  useLayoutEffect(() => {
70
43
  const menu = markerRef.current?.closest<HTMLElement>('[data-model-menu][role="menu"]');
71
- const row = available && menu ? hostCell(menu, 0) : null;
44
+ const row = available && menu ? hostModelRow(menu) : null;
72
45
  if (row === null) {
73
46
  setModelRow(null);
74
47
  setBrowseMount(null);
@@ -94,89 +67,17 @@ export function ModelMenuBridge({
94
67
  };
95
68
  }, [available]);
96
69
 
97
- const submit = (selection: Selection | null): void => {
98
- if (selection === null || busy || directory.getSnapshot().pending !== null) return;
99
- void select(selection).then((result) => {
100
- if (result === undefined || result.ok) return;
101
- reportFailure(result.error.code === 'session/writer-held'
102
- ? t('error.sessionInUse')
103
- : t('error.action', { message: `${result.error.code}: ${result.error.message}` }));
104
- });
105
- };
106
- const commit = (index: number): void => {
107
- const live = selectionOf(state);
108
- const level = levels[index];
109
- if (live === null || level === undefined) return;
110
- submit(planEffortCommit(live, level.effort));
111
- };
112
- const commitDefault = (): void => {
113
- const live = selectionOf(state);
114
- if (live === null) return;
115
- submit(planEffortCommit(live, undefined));
116
- };
117
-
118
- const openQuickModels = () => openPane({ key: QUICK_MODELS_PANE, title: t('picker.quick') });
119
- const latest = useRef({ modelRow, showQuickModels, openQuickModels, busy, showSlider, effortRow, canDefault, commitDefault });
120
70
  useLayoutEffect(() => {
121
- latest.current = { modelRow, showQuickModels, openQuickModels, busy, showSlider, effortRow, canDefault, commitDefault };
122
- });
123
-
124
- useLayoutEffect(() => {
125
- if (surface === null) return;
71
+ if (!showQuickModels) return;
126
72
  const redirect = (event: MouseEvent): void => {
127
- const target = event.target;
128
- const request = latest.current;
129
- if (!(target instanceof Node) || event.defaultPrevented) return;
130
- if (request.showQuickModels && request.modelRow?.contains(target)) {
131
- event.preventDefault();
132
- event.stopPropagation();
133
- if (!request.busy) request.openQuickModels();
134
- return;
135
- }
136
- const row = request.effortRow;
137
- if (row === null || !surface.contains(row) || !row.contains(target) || !request.showSlider) return;
73
+ if (event.defaultPrevented) return;
138
74
  event.preventDefault();
139
75
  event.stopPropagation();
140
- if (request.busy || sliderRef.current?.contains(target)) return;
141
- if (request.canDefault && row.querySelector(cellLabel)?.contains(target)) {
142
- request.commitDefault();
143
- return;
144
- }
145
- sliderRef.current?.querySelector<HTMLElement>('[role="slider"]')?.focus();
146
- };
147
- surface.addEventListener('click', redirect, true);
148
- return () => {
149
- surface.removeEventListener('click', redirect, true);
76
+ if (!busy) openPane({ key: QUICK_MODELS_PANE, title: t('picker.quick') });
150
77
  };
151
- }, [surface]);
152
-
153
- useLayoutEffect(() => {
154
- if (effortRow === null || !showSlider) return;
155
- const label = effortRow.querySelector<HTMLElement>(cellLabel);
156
- const value = effortRow.querySelector<HTMLElement>(cellValue);
157
- const chevron = effortRow.querySelector<SVGElement>(cellChevron);
158
- const saved = {
159
- value: value?.style.display ?? '',
160
- chevron: chevron?.style.display ?? '',
161
- cursor: label?.style.cursor ?? '',
162
- title: label?.getAttribute('title') ?? null,
163
- };
164
- if (value !== null) value.style.display = 'none';
165
- if (chevron !== null) chevron.style.display = 'none';
166
- if (label !== null && canDefault) {
167
- label.style.cursor = 'pointer';
168
- label.title = t('effort.useDefault');
169
- }
170
- return () => {
171
- if (value !== null) value.style.display = saved.value;
172
- if (chevron !== null) chevron.style.display = saved.chevron;
173
- if (label !== null) {
174
- label.style.cursor = saved.cursor;
175
- if (saved.title === null) label.removeAttribute('title');
176
- else label.title = saved.title;
177
- }
178
- };
179
- }, [effortRow, showSlider, canDefault, t]);
78
+ modelRow.addEventListener('click', redirect, true);
79
+ return () => modelRow.removeEventListener('click', redirect, true);
80
+ }, [modelRow, showQuickModels, busy, openPane, t]);
180
81
 
181
82
  return <>
182
83
  <span ref={markerRef} hidden />
@@ -200,21 +101,5 @@ export function ModelMenuBridge({
200
101
  </Tooltip>,
201
102
  browseMount,
202
103
  )}
203
- {showSlider && effortRow !== null && createPortal(
204
- <div ref={sliderRef} className={css.sliderCell}>
205
- <EffortSlider
206
- key={JSON.stringify([current?.provider, current?.model])}
207
- steps={levels}
208
- current={currentIndex}
209
- defaultActive={defaultActive}
210
- defaultIndex={defaultIndex}
211
- defaultLabel={t('effort.providerDefault')}
212
- busy={busy}
213
- label={rowLabel !== null && rowLabel !== '' ? rowLabel : t('effort.label')}
214
- onCommit={commit}
215
- />
216
- </div>,
217
- effortRow,
218
- )}
219
104
  </>;
220
105
  }
@@ -95,110 +95,6 @@
95
95
  border-block-start: .5px solid var(--dsw-alias-border-l2);
96
96
  }
97
97
 
98
- .sliderCell {
99
- display: flex;
100
- flex: 1 1 auto;
101
- align-items: center;
102
- align-self: stretch;
103
- min-width: 96px;
104
- }
105
-
106
- .slider {
107
- display: flex;
108
- flex: 1;
109
- align-items: center;
110
- height: 100%;
111
- min-width: 0;
112
- outline: none;
113
- cursor: pointer;
114
- touch-action: none;
115
- user-select: none;
116
- -webkit-user-select: none;
117
- }
118
-
119
- .slider[data-busy] {
120
- cursor: default;
121
- }
122
-
123
- .sliderTrack {
124
- position: relative;
125
- width: 100%;
126
- height: 16px;
127
- border-radius: 999px;
128
- corner-shape: round;
129
- background: var(--dsw-alias-border-l3);
130
- }
131
-
132
- .sliderFill {
133
- position: absolute;
134
- top: 0;
135
- bottom: 0;
136
- left: 0;
137
- border-radius: 999px;
138
- corner-shape: round;
139
- pointer-events: none;
140
- transition: width 160ms cubic-bezier(0.2, 0, 0, 1);
141
- }
142
-
143
- .sliderTick {
144
- position: absolute;
145
- top: 50%;
146
- width: 4px;
147
- height: 4px;
148
- margin: -2px 0 0 -2px;
149
- border-radius: 50%;
150
- corner-shape: round;
151
- background: var(--dsw-alias-label-tertiary);
152
- pointer-events: none;
153
- }
154
-
155
- .sliderTick[data-on] {
156
- background: rgba(0, 0, 0, 0.28);
157
- }
158
-
159
- .sliderKnob {
160
- position: absolute;
161
- top: 50%;
162
- box-sizing: border-box;
163
- width: 20px;
164
- height: 20px;
165
- margin: -10px 0 0 -10px;
166
- border-radius: 50%;
167
- corner-shape: round;
168
- background: var(--dsw-alias-label-primary-foreground);
169
- box-shadow: var(--dsw-elevation-soft);
170
- pointer-events: none;
171
- transition: left 160ms cubic-bezier(0.2, 0, 0, 1);
172
- }
173
-
174
- .slider[data-dragging] .sliderKnob,
175
- .slider[data-dragging] .sliderFill {
176
- transition: none;
177
- }
178
-
179
- @media (prefers-reduced-motion: reduce) {
180
- .sliderKnob,
181
- .sliderFill {
182
- transition: none;
183
- }
184
- }
185
-
186
- .slider[data-default] .sliderKnob {
187
- background: var(--dsw-alias-bg-layer-1);
188
- border: 1.5px solid var(--dsw-alias-label-tertiary);
189
- box-shadow: none;
190
- }
191
-
192
- .slider[data-busy] .sliderKnob {
193
- opacity: 0.6;
194
- }
195
-
196
- .slider:focus-visible .sliderTrack {
197
- outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
198
- outline-offset: 3px;
199
- }
200
-
201
-
202
98
  .rowBadge {
203
99
  flex: none;
204
100
  margin-inline-start: 6px;
@@ -340,22 +236,24 @@
340
236
  .pickerDialog.pickerDialog {
341
237
  width: min(680px, 100%);
342
238
  height: min(640px, 80vh);
239
+ max-height: 100%;
343
240
  gap: 0;
344
241
  padding: 0;
345
242
  }
346
243
 
347
- .pickerContent {
244
+ .pickerContent,
245
+ .pickerContent :has(.pickerBody),
246
+ .pickerBody {
348
247
  min-height: 0;
349
248
  flex: 1;
350
249
  display: flex;
351
250
  flex-direction: column;
352
251
  }
353
252
 
354
- .pickerContent > :last-child {
355
- min-height: 0;
356
- flex: 1;
357
- display: flex;
358
- flex-direction: column;
253
+ .pickerSearch,
254
+ .pickerTabs,
255
+ .pickerFooter {
256
+ flex: none;
359
257
  }
360
258
 
361
259
  .pickerSearch {
@@ -91,88 +91,90 @@ export function ModelPicker({
91
91
  className={css.pickerDialog ?? ''}
92
92
  contentClassName={css.pickerContent ?? ''}
93
93
  >
94
- <div className={css.pickerSearch}>
95
- <Input
96
- className={css.pickerSearchInput ?? ''}
97
- type="text"
98
- role="searchbox"
99
- aria-label={t('picker.search')}
100
- aria-controls={`${id}-list`}
101
- placeholder={t('picker.search')}
102
- icon={<IconSearchOutlineRegular size={14} />}
103
- value={query}
104
- readOnly={busy}
105
- onChange={(event) => { setQuery(event.target.value) }}
106
- data-modal-autofocus={isMobileDevice() ? undefined : ''}
107
- />
108
- </div>
109
- <div className={css.pickerTabs} role="tablist" aria-label={t('picker.title')}>
110
- {tabs.map((entry) => (
111
- <button
112
- key={entry.id}
113
- type="button"
114
- role="tab"
115
- id={`${id}-tab-${entry.id}`}
116
- aria-selected={entry.id === tab}
94
+ <div className={css.pickerBody}>
95
+ <div className={css.pickerSearch}>
96
+ <Input
97
+ className={css.pickerSearchInput ?? ''}
98
+ type="text"
99
+ role="searchbox"
100
+ aria-label={t('picker.search')}
117
101
  aria-controls={`${id}-list`}
118
- tabIndex={0}
119
- className={css.pickerTab}
120
- onClick={() => { setTab(entry.id) }}
121
- >
122
- {entry.label}
123
- </button>
124
- ))}
125
- </div>
126
- <div ref={listRef} id={`${id}-list`} className={css.pickerList}>
127
- {loading && <div className={css.notice}>{t('status.loading')}</div>}
128
- {failed && (
129
- <div className={css.notice}>
130
- <span>{t('status.failed', { message: state.error ?? '' })}</span>
131
- <button type="button" className={css.retry} onClick={onReload}>{t('action.reload')}</button>
132
- </div>
133
- )}
134
- {failures.map((failure) => (
135
- <div className={css.notice} key={failure.id}>
136
- <span>{t('status.providerFailed', { name: failure.name, message: failure.message })}</span>
137
- <button type="button" className={css.retry} onClick={onReload}>{t('action.reload')}</button>
138
- </div>
139
- ))}
140
- {visible.length === 0 && !loading && !failed && (
141
- <div className={css.notice}>{state.groups.length === 0 ? t('status.empty') : t('picker.searchEmpty')}</div>
142
- )}
143
- {visible.map((row) => (
144
- <div key={`${row.provider}/${row.model}`}>
145
- <ModelRow
146
- name={row.entry.name}
147
- badge={row.entry.badge === undefined
148
- ? undefined
149
- : <Tag tone={row.entry.badge.tone} className={css.rowBadge}>{resolveText(row.entry.badge.text)}</Tag>}
150
- selected={live?.provider === row.provider && live.model === row.model}
151
- busy={busy}
152
- favorited={isFavorite(favorites, row.provider, row.model)}
153
- meta={metaLine({
154
- row,
155
- facts: facts(row.provider, row.model),
156
- providerName: tab === ALL_TAB ? row.providerName : undefined,
157
- thinks: row.entry.reasoning !== undefined,
158
- effortLabel: t('meta.effort'),
159
- imageLabel: t('meta.images'),
160
- })}
161
- starLabel={isFavorite(favorites, row.provider, row.model)
162
- ? t('picker.unfavorite', { model: row.entry.name })
163
- : t('picker.favorite', { model: row.entry.name })}
164
- onPick={() => { pick(row) }}
165
- onToggleFavorite={() => { onToggleFavorite(row.provider, row.model) }}
166
- />
167
- </div>
168
- ))}
169
- </div>
170
- <div className={css.pickerFooter}>
171
- <span className={css.footerHint}>
172
- <ShortcutKeys keys={['Esc']} />
173
- <span>{t('picker.hintClose')}</span>
174
- </span>
175
- <span className={css.footerFavorites}>{t('picker.hintFavorites')}</span>
102
+ placeholder={t('picker.search')}
103
+ icon={<IconSearchOutlineRegular size={14} />}
104
+ value={query}
105
+ readOnly={busy}
106
+ onChange={(event) => { setQuery(event.target.value) }}
107
+ data-modal-autofocus={isMobileDevice() ? undefined : ''}
108
+ />
109
+ </div>
110
+ <div className={css.pickerTabs} role="tablist" aria-label={t('picker.title')}>
111
+ {tabs.map((entry) => (
112
+ <button
113
+ key={entry.id}
114
+ type="button"
115
+ role="tab"
116
+ id={`${id}-tab-${entry.id}`}
117
+ aria-selected={entry.id === tab}
118
+ aria-controls={`${id}-list`}
119
+ tabIndex={0}
120
+ className={css.pickerTab}
121
+ onClick={() => { setTab(entry.id) }}
122
+ >
123
+ {entry.label}
124
+ </button>
125
+ ))}
126
+ </div>
127
+ <div ref={listRef} id={`${id}-list`} className={css.pickerList}>
128
+ {loading && <div className={css.notice}>{t('status.loading')}</div>}
129
+ {failed && (
130
+ <div className={css.notice}>
131
+ <span>{t('status.failed', { message: state.error ?? '' })}</span>
132
+ <button type="button" className={css.retry} onClick={onReload}>{t('action.reload')}</button>
133
+ </div>
134
+ )}
135
+ {failures.map((failure) => (
136
+ <div className={css.notice} key={failure.id}>
137
+ <span>{t('status.providerFailed', { name: failure.name, message: failure.message })}</span>
138
+ <button type="button" className={css.retry} onClick={onReload}>{t('action.reload')}</button>
139
+ </div>
140
+ ))}
141
+ {visible.length === 0 && !loading && !failed && (
142
+ <div className={css.notice}>{state.groups.length === 0 ? t('status.empty') : t('picker.searchEmpty')}</div>
143
+ )}
144
+ {visible.map((row) => (
145
+ <div key={`${row.provider}/${row.model}`}>
146
+ <ModelRow
147
+ name={row.entry.name}
148
+ badge={row.entry.badge === undefined
149
+ ? undefined
150
+ : <Tag tone={row.entry.badge.tone} className={css.rowBadge}>{resolveText(row.entry.badge.text)}</Tag>}
151
+ selected={live?.provider === row.provider && live.model === row.model}
152
+ busy={busy}
153
+ favorited={isFavorite(favorites, row.provider, row.model)}
154
+ meta={metaLine({
155
+ row,
156
+ facts: facts(row.provider, row.model),
157
+ providerName: tab === ALL_TAB ? row.providerName : undefined,
158
+ thinks: row.entry.reasoning !== undefined,
159
+ effortLabel: t('meta.effort'),
160
+ imageLabel: t('meta.images'),
161
+ })}
162
+ starLabel={isFavorite(favorites, row.provider, row.model)
163
+ ? t('picker.unfavorite', { model: row.entry.name })
164
+ : t('picker.favorite', { model: row.entry.name })}
165
+ onPick={() => { pick(row) }}
166
+ onToggleFavorite={() => { onToggleFavorite(row.provider, row.model) }}
167
+ />
168
+ </div>
169
+ ))}
170
+ </div>
171
+ <div className={css.pickerFooter}>
172
+ <span className={css.footerHint}>
173
+ <ShortcutKeys keys={['Esc']} />
174
+ <span>{t('picker.hintClose')}</span>
175
+ </span>
176
+ <span className={css.footerFavorites}>{t('picker.hintFavorites')}</span>
177
+ </div>
176
178
  </div>
177
179
  </Modal>
178
180
  )
@@ -194,4 +196,3 @@ function metaLine(input: {
194
196
  imageLabel: input.imageLabel,
195
197
  }).join(' · ')
196
198
  }
197
-