@lynn123411/dsh-model-submenu 0.3.18 → 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/README.md +26 -71
- package/cordis.patch.yml +0 -1
- package/lib/client.js +385 -1000
- package/lib/client.js.map +1 -1
- package/lib/index.js +31 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +5 -3
- package/src/account-model-facts.ts +8 -0
- package/src/client/ModelMenuBridge.tsx +30 -182
- package/src/client/ModelOptions.module.css +21 -162
- package/src/client/ModelPicker.tsx +83 -113
- package/src/client/ModelPickerHost.tsx +0 -26
- package/src/client/ModelRow.tsx +0 -23
- package/src/client/QuickModels.tsx +34 -10
- package/src/client/effort-memory.ts +0 -32
- package/src/client/facts-source.ts +91 -46
- package/src/client/favorites.ts +0 -40
- package/src/client/icons.tsx +0 -14
- package/src/client/index.ts +13 -44
- package/src/client/locales.ts +3 -15
- package/src/client/model-facts.ts +16 -94
- package/src/client/picker-state.ts +0 -20
- package/src/client/rows.ts +0 -37
- package/src/client/selection.ts +0 -91
- package/src/index.ts +35 -2
- package/src/client/EffortSlider.tsx +0 -191
- package/src/client/EffortTint.tsx +0 -61
- package/src/client/level-color.ts +0 -51
- package/src/client/slider.ts +0 -98
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The model picker: the centered dialog opened from the menu's model row.
|
|
3
|
-
*
|
|
4
|
-
* It is the one place every provider is visible at once — a search field, a tab
|
|
5
|
-
* per provider with a model, and one flat list with each model's metadata line.
|
|
6
|
-
* Favorites lead the list and can be toggled from a row's star without
|
|
7
|
-
* selecting that row. A click commits at once; a rejected commit keeps the
|
|
8
|
-
* dialog open so the user can retry or pick another model.
|
|
9
|
-
*/
|
|
10
1
|
|
|
11
2
|
import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
12
3
|
import {
|
|
@@ -37,44 +28,21 @@ import type { Selection } from './selection.ts'
|
|
|
37
28
|
import { planModelCommit } from './selection.ts'
|
|
38
29
|
import css from './ModelOptions.module.css'
|
|
39
30
|
|
|
40
|
-
/** Props the seat hands the picker. */
|
|
41
31
|
export interface ModelPickerProps {
|
|
42
|
-
/** Whether the dialog is showing. */
|
|
43
32
|
readonly open: boolean
|
|
44
|
-
/** Resolve a catalog badge's localized text for the active language. */
|
|
45
33
|
readonly resolveText: (text: NonNullable<CatalogModel['badge']>['text']) => string
|
|
46
|
-
/** The shared directory snapshot. */
|
|
47
34
|
readonly state: ModelDirectoryState
|
|
48
|
-
/** The selection in force, null before a first selection resolves. */
|
|
49
35
|
readonly live: Selection | null
|
|
50
|
-
/** The metadata lookup for the current settings answer. */
|
|
51
36
|
readonly facts: ModelFactsLookup
|
|
52
|
-
/** The favorite table right now. */
|
|
53
37
|
readonly favorites: readonly { readonly provider: string; readonly model: string }[]
|
|
54
|
-
/** Whether a selection is in flight. */
|
|
55
38
|
readonly busy: boolean
|
|
56
|
-
/**
|
|
57
|
-
* The reasoning level this browser last used for one model, if any.
|
|
58
|
-
* @param provider - the provider route key.
|
|
59
|
-
* @param model - the model id inside that provider.
|
|
60
|
-
* @returns the remembered level, or undefined when none is remembered.
|
|
61
|
-
*/
|
|
62
39
|
readonly rememberedOf?: (provider: string, model: string) => string | undefined
|
|
63
|
-
/** Submit one selection. */
|
|
64
40
|
readonly onPick: (selection: Selection) => void
|
|
65
|
-
/** Toggle one model's favorite. */
|
|
66
41
|
readonly onToggleFavorite: (provider: string, model: string) => void
|
|
67
|
-
/** Reload the catalog after a failure. */
|
|
68
42
|
readonly onReload: () => void
|
|
69
|
-
/** Close the dialog, optionally returning focus. */
|
|
70
43
|
readonly onClose: () => void
|
|
71
44
|
}
|
|
72
45
|
|
|
73
|
-
/**
|
|
74
|
-
* Render the picker.
|
|
75
|
-
* @param props - the catalog, the live selection, and the picker's verbs.
|
|
76
|
-
* @returns the dialog; nothing while closed.
|
|
77
|
-
*/
|
|
78
46
|
export function ModelPicker({
|
|
79
47
|
open, resolveText, state, live, facts, favorites, busy, rememberedOf, onPick, onToggleFavorite, onReload, onClose, t,
|
|
80
48
|
}: ModelPickerProps & PropsLocale<'modelSubmenu'>) {
|
|
@@ -123,87 +91,90 @@ export function ModelPicker({
|
|
|
123
91
|
className={css.pickerDialog ?? ''}
|
|
124
92
|
contentClassName={css.pickerContent ?? ''}
|
|
125
93
|
>
|
|
126
|
-
<div className={css.
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
placeholder={t('picker.search')}
|
|
134
|
-
icon={<IconSearchOutlineRegular size={14} />}
|
|
135
|
-
value={query}
|
|
136
|
-
readOnly={busy}
|
|
137
|
-
onChange={(event) => { setQuery(event.target.value) }}
|
|
138
|
-
data-modal-autofocus={isMobileDevice() ? undefined : ''}
|
|
139
|
-
/>
|
|
140
|
-
</div>
|
|
141
|
-
<div className={css.pickerTabs} role="tablist" aria-label={t('picker.title')}>
|
|
142
|
-
{tabs.map((entry) => (
|
|
143
|
-
<button
|
|
144
|
-
key={entry.id}
|
|
145
|
-
type="button"
|
|
146
|
-
role="tab"
|
|
147
|
-
id={`${id}-tab-${entry.id}`}
|
|
148
|
-
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')}
|
|
149
101
|
aria-controls={`${id}-list`}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{
|
|
176
|
-
<div
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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>
|
|
207
178
|
</div>
|
|
208
179
|
</Modal>
|
|
209
180
|
)
|
|
@@ -225,4 +196,3 @@ function metaLine(input: {
|
|
|
225
196
|
imageLabel: input.imageLabel,
|
|
226
197
|
}).join(' · ')
|
|
227
198
|
}
|
|
228
|
-
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The composer overlay's picker view: the dialog, its catalog, and its verbs.
|
|
3
|
-
*
|
|
4
|
-
* It lives in `conversation.input.overlay` so it can open after the Host's menu
|
|
5
|
-
* closes or from the toolbar when the current model is missing. Its data comes
|
|
6
|
-
* from the slot entry's injected face.
|
|
7
|
-
*/
|
|
8
1
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
9
2
|
import { Button, IconWarningOutlineRegular, Toast } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
10
3
|
import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
|
|
@@ -27,23 +20,14 @@ import { currentCatalogModel, selectionOf, type Selection } from './selection.ts
|
|
|
27
20
|
import type { PickerStore } from './picker-state.ts';
|
|
28
21
|
import css from './ModelOptions.module.css';
|
|
29
22
|
|
|
30
|
-
/** Props of the overlay view: the session, the store, and the seat's injected face. */
|
|
31
23
|
export type ModelPickerHostProps = PropsLocale<'modelSubmenu'>
|
|
32
24
|
& ModelSelectInjected
|
|
33
25
|
& {
|
|
34
|
-
/** Session whose catalog this view renders. */
|
|
35
26
|
readonly sessionId: string;
|
|
36
|
-
/** The request written by the menu row. */
|
|
37
27
|
readonly picker: PickerStore;
|
|
38
|
-
/** The settings-derived metadata the picker's line reads. */
|
|
39
28
|
readonly factsSource: FactsSource;
|
|
40
29
|
}
|
|
41
30
|
|
|
42
|
-
/**
|
|
43
|
-
* Render the picker for this session.
|
|
44
|
-
* @param props - session, store, catalog face, and localized copy.
|
|
45
|
-
* @returns the dialog while the store names this session; otherwise nothing.
|
|
46
|
-
*/
|
|
47
31
|
export function ModelPickerHost({
|
|
48
32
|
sessionId, picker, available, directory, load, select, resolveText, factsSource, t,
|
|
49
33
|
}: ModelPickerHostProps) {
|
|
@@ -68,22 +52,13 @@ export function ModelPickerHost({
|
|
|
68
52
|
}
|
|
69
53
|
};
|
|
70
54
|
}, [open, picker, request]);
|
|
71
|
-
// The injected face is cached per entry and session, but the read goes through
|
|
72
|
-
// a ref anyway: a catalog load writes the store, so an unstable `load` in the
|
|
73
|
-
// dependency list would reload on every render it caused.
|
|
74
55
|
const loadRef = useRef(load);
|
|
75
56
|
loadRef.current = load;
|
|
76
57
|
|
|
77
|
-
// Opening reads the catalog again: another client may have changed it, and a
|
|
78
|
-
// failed load has to be retryable from the same gesture.
|
|
79
58
|
useEffect(() => {
|
|
80
59
|
if (open) loadRef.current();
|
|
81
60
|
}, [open]);
|
|
82
61
|
|
|
83
|
-
// The Host's own menu changes the reasoning level without passing through this
|
|
84
|
-
// plugin, so the memory is written from the directory snapshot too — a picker
|
|
85
|
-
// click alone would only ever record levels chosen in the dialog. The key guard
|
|
86
|
-
// keeps one write per distinct selection instead of one per snapshot.
|
|
87
62
|
const current = state.current;
|
|
88
63
|
const rememberedRef = useRef<string | null>(null);
|
|
89
64
|
useEffect(() => {
|
|
@@ -147,7 +122,6 @@ export function ModelPickerHost({
|
|
|
147
122
|
</div>;
|
|
148
123
|
}
|
|
149
124
|
|
|
150
|
-
/** The Host skips the root menu when the current model is absent from its catalog. */
|
|
151
125
|
export function ModelPickerFallback({ sessionId, picker, available, directory, t }: Pick<
|
|
152
126
|
ModelPickerHostProps, 'sessionId' | 'picker' | 'available' | 'directory' | 't'
|
|
153
127
|
>) {
|
package/src/client/ModelRow.tsx
CHANGED
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One pickable model in the picker.
|
|
3
|
-
*
|
|
4
|
-
* The star is its own control, because favouriting there must not switch the
|
|
5
|
-
* model: the row button picks, the star toggles, and the check marks the model
|
|
6
|
-
* in use.
|
|
7
|
-
*/
|
|
8
1
|
|
|
9
2
|
import type { ReactNode } from 'react';
|
|
10
3
|
import { IconCheckOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
11
4
|
import { StarIcon } from './icons.tsx';
|
|
12
5
|
import css from './ModelOptions.module.css';
|
|
13
6
|
|
|
14
|
-
/** Props of one row. */
|
|
15
7
|
export interface ModelRowProps {
|
|
16
|
-
/** The model's catalog name. */
|
|
17
8
|
readonly name: string;
|
|
18
|
-
/** Optional catalog badge shown beside the name. */
|
|
19
9
|
readonly badge?: ReactNode | undefined;
|
|
20
|
-
/** Whether this row is the model in use. */
|
|
21
10
|
readonly selected: boolean;
|
|
22
|
-
/** Whether a selection is in flight, which locks the row. */
|
|
23
11
|
readonly busy: boolean;
|
|
24
|
-
/** Whether the model is favorited right now. */
|
|
25
12
|
readonly favorited: boolean;
|
|
26
|
-
/** The metadata line's text. */
|
|
27
13
|
readonly meta?: string | undefined;
|
|
28
|
-
/** Localized accessible name for the star control. */
|
|
29
14
|
readonly starLabel?: string | undefined;
|
|
30
|
-
/** Pick this row. */
|
|
31
15
|
readonly onPick: () => void;
|
|
32
|
-
/** Toggle this row's favorite. */
|
|
33
16
|
readonly onToggleFavorite: () => void;
|
|
34
|
-
/** Extra row content, such as the picker's disabled reason. */
|
|
35
17
|
readonly children?: ReactNode;
|
|
36
18
|
}
|
|
37
19
|
|
|
38
|
-
/**
|
|
39
|
-
* Render one model row.
|
|
40
|
-
* @param props - the row's content and behaviour.
|
|
41
|
-
* @returns the row element.
|
|
42
|
-
*/
|
|
43
20
|
export function ModelRow({
|
|
44
21
|
name, badge, selected, busy, favorited, meta, starLabel,
|
|
45
22
|
onPick, onToggleFavorite, children,
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import { useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'
|
|
2
|
-
import { IconCheckOutlineRegular, MenuGroup, StateDot, Tag } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
1
|
+
import { useLayoutEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent } from 'react'
|
|
2
|
+
import { IconCheckOutlineRegular, IconChevronRightOutlineRegular, MenuGroup, StateDot, Tag } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
3
3
|
import type { ModelDirectoryState, ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client'
|
|
4
4
|
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
5
|
import { effortFor, readEfforts } from './effort-memory.ts'
|
|
6
6
|
import { isFavorite, readFavorites, storageOf } from './favorites.ts'
|
|
7
|
+
import type { PickerStore } from './picker-state.ts'
|
|
7
8
|
import { planModelCommit, sameModel, selectionOf } from './selection.ts'
|
|
8
9
|
import type { CatalogModel } from './rows.ts'
|
|
9
10
|
import css from './ModelOptions.module.css'
|
|
10
11
|
|
|
11
12
|
export const QUICK_MODELS_PANE = 'lynn-quick-models'
|
|
12
13
|
|
|
14
|
+
function confirmOnTab(event: KeyboardEvent<HTMLButtonElement>): void {
|
|
15
|
+
if (event.key !== 'Tab' || event.shiftKey || event.nativeEvent.isComposing) return
|
|
16
|
+
event.preventDefault()
|
|
17
|
+
event.stopPropagation()
|
|
18
|
+
event.currentTarget.click()
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
type QuickModelsProps = PropsRuntime<'conversation.input.model.pane'>
|
|
14
22
|
& PropsLocale<'modelSubmenu'>
|
|
15
23
|
& Pick<ModelSelectInjected, 'directory' | 'resolveText' | 'select'>
|
|
24
|
+
& {
|
|
25
|
+
readonly sessionId: string
|
|
26
|
+
readonly picker: PickerStore
|
|
27
|
+
}
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
export function QuickModels({ locked, dismiss, reportFailure, directory, resolveText, select, t }: QuickModelsProps) {
|
|
29
|
+
export function QuickModels({ sessionId, picker, locked, dismiss, reportFailure, directory, resolveText, select, t }: QuickModelsProps) {
|
|
19
30
|
const state = useSyncExternalStore<ModelDirectoryState>((listener) => directory.subscribe(listener), () => directory.getSnapshot())
|
|
20
31
|
const [favorites] = useState(() => readFavorites(storageOf()))
|
|
21
32
|
const open = useRef(false)
|
|
@@ -69,12 +80,7 @@ export function QuickModels({ locked, dismiss, reportFailure, directory, resolve
|
|
|
69
80
|
className={css.quickOption}
|
|
70
81
|
title={model.name}
|
|
71
82
|
onClick={() => { void choose(group.id, model) }}
|
|
72
|
-
onKeyDown={
|
|
73
|
-
if (event.key !== 'Tab' || event.shiftKey || event.nativeEvent.isComposing) return
|
|
74
|
-
event.preventDefault()
|
|
75
|
-
event.stopPropagation()
|
|
76
|
-
void choose(group.id, model)
|
|
77
|
-
}}
|
|
83
|
+
onKeyDown={confirmOnTab}
|
|
78
84
|
>
|
|
79
85
|
<span className={css.quickCopy}>
|
|
80
86
|
<span className={css.quickName}>{model.name}</span>
|
|
@@ -86,5 +92,23 @@ export function QuickModels({ locked, dismiss, reportFailure, directory, resolve
|
|
|
86
92
|
</button>
|
|
87
93
|
})}
|
|
88
94
|
</MenuGroup>)}
|
|
95
|
+
<div className={css.quickFooter}>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
role="menuitem"
|
|
99
|
+
aria-haspopup="dialog"
|
|
100
|
+
className={css.quickOption}
|
|
101
|
+
disabled={busy}
|
|
102
|
+
onClick={() => {
|
|
103
|
+
if (busy || directory.getSnapshot().pending !== null) return
|
|
104
|
+
dismiss()
|
|
105
|
+
picker.open(sessionId)
|
|
106
|
+
}}
|
|
107
|
+
onKeyDown={confirmOnTab}
|
|
108
|
+
>
|
|
109
|
+
<span className={css.quickCopy}>{t('picker.browseAll')}</span>
|
|
110
|
+
<IconChevronRightOutlineRegular size={12} />
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
89
113
|
</div>
|
|
90
114
|
}
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The per-model reasoning level this browser last chose.
|
|
3
|
-
*
|
|
4
|
-
* The Host stores one level per session, so switching models away and back
|
|
5
|
-
* forgets what was picked for the first one. This module keeps that memory
|
|
6
|
-
* beside the favorite table, keyed the same way: provider route key plus model
|
|
7
|
-
* id. Remembering the provider default removes the row, so "follow the
|
|
8
|
-
* provider" stays distinguishable from "remembered a level".
|
|
9
|
-
*/
|
|
10
1
|
|
|
11
|
-
/** One remembered reasoning level. */
|
|
12
2
|
export interface RememberedEffort {
|
|
13
3
|
readonly provider: string
|
|
14
4
|
readonly model: string
|
|
15
5
|
readonly effort: string
|
|
16
6
|
}
|
|
17
7
|
|
|
18
|
-
/** The single browser-wide storage key holding the whole memory. */
|
|
19
8
|
export const EFFORTS_KEY = 'dsh-model-submenu.efforts'
|
|
20
9
|
|
|
21
|
-
/** The part of `Storage` this module uses; absent or throwing reads mean "none". */
|
|
22
10
|
export type EffortStorage = Pick<Storage, 'getItem' | 'setItem'>
|
|
23
11
|
|
|
24
|
-
/**
|
|
25
|
-
* Read the memory, keeping only rows naming both halves and a level.
|
|
26
|
-
* @param storage - browser storage, or undefined when the browser withholds it.
|
|
27
|
-
* @returns the remembered rows; empty when unreadable.
|
|
28
|
-
*/
|
|
29
12
|
export function readEfforts(storage: EffortStorage | undefined): RememberedEffort[] {
|
|
30
13
|
const raw = getItem(storage)
|
|
31
14
|
if (raw === null) return []
|
|
@@ -43,12 +26,6 @@ export function readEfforts(storage: EffortStorage | undefined): RememberedEffor
|
|
|
43
26
|
&& (row as RememberedEffort).effort !== '')
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
/**
|
|
47
|
-
* @param memory - the rows to search.
|
|
48
|
-
* @param provider - the provider route key.
|
|
49
|
-
* @param model - the model id inside that provider.
|
|
50
|
-
* @returns the level last chosen for that exact model, or undefined.
|
|
51
|
-
*/
|
|
52
29
|
export function effortFor(
|
|
53
30
|
memory: readonly RememberedEffort[],
|
|
54
31
|
provider: string,
|
|
@@ -57,14 +34,6 @@ export function effortFor(
|
|
|
57
34
|
return memory.find((row) => row.provider === provider && row.model === model)?.effort
|
|
58
35
|
}
|
|
59
36
|
|
|
60
|
-
/**
|
|
61
|
-
* Remember one model's level, or forget it when the choice is the provider default.
|
|
62
|
-
* @param storage - browser storage, or undefined when writes are unavailable.
|
|
63
|
-
* @param provider - the provider route key.
|
|
64
|
-
* @param model - the model id inside that provider.
|
|
65
|
-
* @param effort - the chosen level, undefined meaning the provider default.
|
|
66
|
-
* @returns the memory after the change, whether or not the write landed.
|
|
67
|
-
*/
|
|
68
37
|
export function rememberEffort(
|
|
69
38
|
storage: EffortStorage | undefined,
|
|
70
39
|
provider: string,
|
|
@@ -76,7 +45,6 @@ export function rememberEffort(
|
|
|
76
45
|
try {
|
|
77
46
|
storage?.setItem(EFFORTS_KEY, JSON.stringify(next))
|
|
78
47
|
} catch {
|
|
79
|
-
// A full quota or a locked-down browser loses the memory, not the menu.
|
|
80
48
|
}
|
|
81
49
|
return next
|
|
82
50
|
}
|