@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
package/lib/client.js
CHANGED
|
@@ -5,455 +5,11 @@ window.__ModuleLoader__.load({
|
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
7
|
let react = require("react");
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
8
|
let react_dom = require("react-dom");
|
|
10
9
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The accent one reasoning level carries.
|
|
14
|
-
*
|
|
15
|
-
* "Off" carries no accent at all — the fill and the caption stay neutral, so
|
|
16
|
-
* switching reasoning off reads as switching it off rather than as the first
|
|
17
|
-
* shade of a ramp. Every level above it walks a blue-to-violet ramp, and the
|
|
18
|
-
* highest level is the only one whose fill is a gradient.
|
|
19
|
-
*/
|
|
20
|
-
/** Off: the dimmed label tone, the same neutral the Host uses for quiet text. */
|
|
21
|
-
const NEUTRAL = "var(--dsw-alias-label-dimmed)";
|
|
22
|
-
/** Lowest lit level: the blue the composer already uses for accents. */
|
|
23
|
-
const LOW = [
|
|
24
|
-
77,
|
|
25
|
-
147,
|
|
26
|
-
248
|
|
27
|
-
];
|
|
28
|
-
/** Highest level: violet. */
|
|
29
|
-
const HIGH = [
|
|
30
|
-
147,
|
|
31
|
-
51,
|
|
32
|
-
234
|
|
33
|
-
];
|
|
34
|
-
/**
|
|
35
|
-
* @param t - a point on the ramp, 0 at the lowest lit level and 1 at the top.
|
|
36
|
-
* @returns the ramp color there.
|
|
37
|
-
*/
|
|
38
|
-
function ramp(t) {
|
|
39
|
-
const mix = (from, to) => Math.round(from + (to - from) * t);
|
|
40
|
-
return `rgb(${mix(LOW[0], HIGH[0])}, ${mix(LOW[1], HIGH[1])}, ${mix(LOW[2], HIGH[2])})`;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @param index - the level's detent, 0 being "off".
|
|
44
|
-
* @param count - number of detents.
|
|
45
|
-
* @returns the level's color as a CSS color string.
|
|
46
|
-
*/
|
|
47
|
-
function levelColor(index, count) {
|
|
48
|
-
if (index <= 0) return NEUTRAL;
|
|
49
|
-
if (isTopLevel(index, count)) return ramp(1);
|
|
50
|
-
const span = Math.max(1, count - 2);
|
|
51
|
-
return ramp(Math.min(Math.max((index - 1) / span, 0), 1));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @param index - the level's detent.
|
|
55
|
-
* @param count - number of detents.
|
|
56
|
-
* @returns whether this level is the only one painted with a gradient.
|
|
57
|
-
*/
|
|
58
|
-
function isTopLevel(index, count) {
|
|
59
|
-
return count > 1 && index === count - 1;
|
|
60
|
-
}
|
|
61
|
-
/** The top level's fill: the whole ramp, ending on the color its text takes. */
|
|
62
|
-
const LEVEL_GRADIENT = `linear-gradient(90deg, ${ramp(0)}, ${ramp(1)})`;
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/client/selection.ts
|
|
65
|
-
/**
|
|
66
|
-
* Build the slider's detents for one model.
|
|
67
|
-
*
|
|
68
|
-
* The provider default is deliberately absent: it is a state, not a level, and
|
|
69
|
-
* giving it a detent would read as the weakest reasoning instead of "let the
|
|
70
|
-
* provider decide". The label above the track switches to it.
|
|
71
|
-
* @param reasoning - the catalog's reasoning metadata, undefined when the model has none.
|
|
72
|
-
* @returns one detent per advertised level, in catalog order.
|
|
73
|
-
*/
|
|
74
|
-
function effortChoices(reasoning) {
|
|
75
|
-
if (reasoning === void 0) return [];
|
|
76
|
-
return reasoning.efforts.map((level) => ({
|
|
77
|
-
key: level.id,
|
|
78
|
-
effort: level.id,
|
|
79
|
-
label: level.name
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The selection a level click submits.
|
|
84
|
-
* @param live - the selection in force right now.
|
|
85
|
-
* @param effort - the clicked level, undefined meaning the provider default.
|
|
86
|
-
* @returns the selection to submit, or null when the level already is the live one.
|
|
87
|
-
*/
|
|
88
|
-
function planEffortCommit(live, effort) {
|
|
89
|
-
if (sameEffort(live.reasoningEffort, effort)) return null;
|
|
90
|
-
return {
|
|
91
|
-
provider: live.provider,
|
|
92
|
-
model: live.model,
|
|
93
|
-
...effort === void 0 ? {} : { reasoningEffort: effort }
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The selection a model click submits.
|
|
98
|
-
* @param live - the selection in force right now, null before a first selection resolves.
|
|
99
|
-
* @param provider - the clicked model's provider.
|
|
100
|
-
* @param model - the clicked model id.
|
|
101
|
-
* @param reasoningOf - the catalog's reasoning metadata for one provider and model.
|
|
102
|
-
* @param remembered - the level this browser last used for the target model, if any.
|
|
103
|
-
* @returns the selection to submit, or null when the click changes nothing.
|
|
104
|
-
*/
|
|
105
|
-
function planModelCommit(live, provider, model, reasoningOf, remembered) {
|
|
106
|
-
if (live !== null && sameModel(live, provider, model)) return null;
|
|
107
|
-
const offered = reasoningOf(provider, model);
|
|
108
|
-
return {
|
|
109
|
-
provider,
|
|
110
|
-
model,
|
|
111
|
-
...offered !== void 0 && remembered !== void 0 && offered.efforts.some((level) => level.id === remembered) ? { reasoningEffort: remembered } : {}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The reasoning metadata the catalog advertises for the model in force.
|
|
116
|
-
* @param state - the session's directory snapshot.
|
|
117
|
-
* @returns the metadata, or undefined when no model is live or it advertises none.
|
|
118
|
-
*/
|
|
119
|
-
function liveReasoning(state) {
|
|
120
|
-
return currentCatalogModel(state)?.reasoning;
|
|
121
|
-
}
|
|
122
|
-
/** Find the current model by its provider and model IDs. */
|
|
123
|
-
function currentCatalogModel(state) {
|
|
124
|
-
const current = state.current;
|
|
125
|
-
if (current === null) return void 0;
|
|
126
|
-
return state.groups.find((group) => group.id === current.provider)?.models.find((model) => model.id === current.model);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* The selection in force, or null while the Host has not resolved one.
|
|
130
|
-
* @param state - the session's directory snapshot.
|
|
131
|
-
* @returns the live selection, with the effort only when one is set.
|
|
132
|
-
*/
|
|
133
|
-
function selectionOf(state) {
|
|
134
|
-
if (state.current === null) return null;
|
|
135
|
-
return state.current.reasoningEffort === void 0 ? {
|
|
136
|
-
provider: state.current.provider,
|
|
137
|
-
model: state.current.model
|
|
138
|
-
} : {
|
|
139
|
-
provider: state.current.provider,
|
|
140
|
-
model: state.current.model,
|
|
141
|
-
reasoningEffort: state.current.reasoningEffort
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* @param live - one selection.
|
|
146
|
-
* @param provider - the provider to compare.
|
|
147
|
-
* @param model - the model id to compare.
|
|
148
|
-
* @returns whether both name the same model.
|
|
149
|
-
*/
|
|
150
|
-
function sameModel(live, provider, model) {
|
|
151
|
-
return live.provider === provider && live.model === model;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* @param liveEffort - the level in force, undefined meaning the provider default.
|
|
155
|
-
* @param effort - the level in question.
|
|
156
|
-
* @returns whether they name the same level.
|
|
157
|
-
*/
|
|
158
|
-
function sameEffort(liveEffort, effort) {
|
|
159
|
-
return liveEffort === effort;
|
|
160
|
-
}
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/client/EffortTint.tsx
|
|
163
|
-
/**
|
|
164
|
-
* Tint the composer's effort caption with the level's color.
|
|
165
|
-
*
|
|
166
|
-
* The slider's fill and the menu's value already carry the level's color; the
|
|
167
|
-
* caption on the collapsed trigger is the third place the level shows, and it
|
|
168
|
-
* lives outside the menu. This entry stays mounted for the whole session and
|
|
169
|
-
* writes that one color, so all three read as one signal.
|
|
170
|
-
*
|
|
171
|
-
* The caption is recognized as the trigger's `span[class*='triggerEffort']`
|
|
172
|
-
* child — the same class-substring contract the menu row uses. When the model
|
|
173
|
-
* declares no levels the span does not exist and nothing is written.
|
|
174
|
-
*/
|
|
175
|
-
/**
|
|
176
|
-
* Render nothing and keep the trigger caption colored.
|
|
177
|
-
* @param props - the session's catalog face.
|
|
178
|
-
* @returns an inert marker.
|
|
179
|
-
*/
|
|
180
|
-
function EffortTint({ available, directory }) {
|
|
181
|
-
const markerRef = (0, react.useRef)(null);
|
|
182
|
-
const [caption, setCaption] = (0, react.useState)(null);
|
|
183
|
-
const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
|
|
184
|
-
const levels = effortChoices(liveReasoning(state));
|
|
185
|
-
const effort = state.current?.reasoningEffort;
|
|
186
|
-
const chosen = effort === void 0 ? -1 : levels.findIndex((level) => level.effort === effort);
|
|
187
|
-
const color = available && chosen >= 0 && levels.length >= 2 ? levelColor(chosen, levels.length) : null;
|
|
188
|
-
(0, react.useLayoutEffect)(() => {
|
|
189
|
-
const next = (markerRef.current?.closest("[data-composer-card]"))?.querySelector("[data-slot=\"conversation.input.model\"] button[aria-haspopup=\"menu\"] span[class*=\"triggerEffort\"]") ?? null;
|
|
190
|
-
if (next !== caption) setCaption(next);
|
|
191
|
-
});
|
|
192
|
-
(0, react.useLayoutEffect)(() => {
|
|
193
|
-
if (caption === null || color === null) return;
|
|
194
|
-
const saved = caption.style.color;
|
|
195
|
-
caption.style.color = color;
|
|
196
|
-
return () => {
|
|
197
|
-
caption.style.color = saved;
|
|
198
|
-
};
|
|
199
|
-
}, [caption, color]);
|
|
200
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
201
|
-
ref: markerRef,
|
|
202
|
-
hidden: true
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
/** The knob's centre keeps its own radius away from either end of the track. */
|
|
206
|
-
const KNOB_RADIUS = 10;
|
|
207
|
-
/**
|
|
208
|
-
* @param index - detent index.
|
|
209
|
-
* @param count - number of detents.
|
|
210
|
-
* @returns the knob centre as a fraction of the track, 0 at the first detent and 1 at the last.
|
|
211
|
-
*/
|
|
212
|
-
function offsetOf(index, count) {
|
|
213
|
-
if (count <= 1) return 0;
|
|
214
|
-
return Math.min(Math.max(index, 0), count - 1) / (count - 1);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Where a pointer sits along the knob's travel. The drag reads this rather than a
|
|
218
|
-
* detent, so the knob follows the pointer instead of jumping a level at a time.
|
|
219
|
-
* @param clientX - pointer position in viewport coordinates.
|
|
220
|
-
* @param left - the track's left edge in viewport coordinates.
|
|
221
|
-
* @param width - the track's width in pixels.
|
|
222
|
-
* @returns the position as a fraction of the travel, clamped to 0 and 1.
|
|
223
|
-
*/
|
|
224
|
-
function fractionAt(clientX, left, width) {
|
|
225
|
-
const usable = width - 20;
|
|
226
|
-
if (usable <= 0) return 0;
|
|
227
|
-
const fraction = (clientX - left - KNOB_RADIUS) / usable;
|
|
228
|
-
return Math.min(Math.max(fraction, 0), 1);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* @param fraction - a knob position between 0 and 1.
|
|
232
|
-
* @param count - number of detents.
|
|
233
|
-
* @returns the detent nearest that position.
|
|
234
|
-
*/
|
|
235
|
-
function detentAt(fraction, count) {
|
|
236
|
-
if (count <= 1) return 0;
|
|
237
|
-
return Math.round(Math.min(Math.max(fraction, 0), 1) * (count - 1));
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* @param fraction - a knob position between 0 and 1.
|
|
241
|
-
* @returns the CSS length that puts the knob centre there, inset at both ends.
|
|
242
|
-
*/
|
|
243
|
-
function knobOffset(fraction) {
|
|
244
|
-
return `calc(${KNOB_RADIUS}px + ${Math.min(Math.max(fraction, 0), 1)} * (100% - 20px))`;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Width of the colored fill for a knob position.
|
|
248
|
-
*
|
|
249
|
-
* The fill is the track's own shape cut at the knob: its right cap carries the
|
|
250
|
-
* track's radius and ends under the knob, so the color runs into the knob
|
|
251
|
-
* instead of stopping at a straight edge, and the last detent reaches the track's
|
|
252
|
-
* end rather than the knob's centre.
|
|
253
|
-
* @param fraction - a knob position between 0 and 1.
|
|
254
|
-
* @returns the CSS width of the fill.
|
|
255
|
-
*/
|
|
256
|
-
function fillWidth(fraction) {
|
|
257
|
-
return `calc(16px + ${Math.min(Math.max(fraction, 0), 1)} * (100% - 16px))`;
|
|
258
|
-
}
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region \0dsh-css:/home/runner/work/my-dsh/my-dsh/plugins/dsh-model-submenu/src/client/ModelOptions.module.css.mjs
|
|
261
|
-
const stylesheet = ".TcCbqa_pickerHost{display:contents}.TcCbqa_modelCell.TcCbqa_modelCell{anchor-name:--dsh-quick-model-row;padding-inline-end:14px}.TcCbqa_modelCell>svg:last-child{visibility:hidden}.TcCbqa_modelBrowse{position-anchor:--dsh-quick-model-row;top:anchor(top);bottom:anchor(bottom);border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;place-items:center;padding:0;display:grid;position:absolute;inset-inline-end:anchor(end)}.TcCbqa_modelBrowse:hover:not(:disabled),.TcCbqa_modelBrowse:focus-visible{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.TcCbqa_quickOption{border-radius:var(--dsw-radius-md);width:100%;min-height:34px;color:inherit;text-align:start;cursor:pointer;background:0 0;border:0;outline:none;align-items:center;gap:6px;padding:5px 7px;font-size:13px;font-weight:400;line-height:18px;display:flex}.TcCbqa_quickOption:hover:not([aria-disabled=true]),.TcCbqa_quickOption:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_quickOption[aria-disabled=true]{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_quickCopy{flex:1;align-items:center;gap:4px;min-width:0;display:flex}.TcCbqa_quickName{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.TcCbqa_quickBadge{flex:none}.TcCbqa_quickCheck{flex:0 0 14px;place-items:center;display:grid}.TcCbqa_sliderCell{flex:auto;align-self:stretch;align-items:center;min-width:96px;display:flex}.TcCbqa_slider{cursor:pointer;touch-action:none;-webkit-user-select:none;user-select:none;outline:none;flex:1;align-items:center;min-width:0;height:100%;display:flex}.TcCbqa_slider[data-busy]{cursor:default}.TcCbqa_sliderTrack{corner-shape:round;background:var(--dsw-alias-border-l3);border-radius:999px;width:100%;height:16px;position:relative}.TcCbqa_sliderFill{corner-shape:round;pointer-events:none;border-radius:999px;transition:width .16s cubic-bezier(.2,0,0,1);position:absolute;top:0;bottom:0;left:0}.TcCbqa_sliderTick{corner-shape:round;background:var(--dsw-alias-label-tertiary);pointer-events:none;border-radius:50%;width:4px;height:4px;margin:-2px 0 0 -2px;position:absolute;top:50%}.TcCbqa_sliderTick[data-on]{background:#00000047}.TcCbqa_sliderKnob{box-sizing:border-box;corner-shape:round;background:var(--dsw-alias-label-primary-foreground);width:20px;height:20px;box-shadow:var(--dsw-elevation-soft);pointer-events:none;border-radius:50%;margin:-10px 0 0 -10px;transition:left .16s cubic-bezier(.2,0,0,1);position:absolute;top:50%}.TcCbqa_slider[data-dragging] .TcCbqa_sliderKnob,.TcCbqa_slider[data-dragging] .TcCbqa_sliderFill{transition:none}@media (prefers-reduced-motion:reduce){.TcCbqa_sliderKnob,.TcCbqa_sliderFill{transition:none}}.TcCbqa_slider[data-default] .TcCbqa_sliderKnob{background:var(--dsw-alias-bg-layer-1);border:1.5px solid var(--dsw-alias-label-tertiary);box-shadow:none}.TcCbqa_slider[data-busy] .TcCbqa_sliderKnob{opacity:.6}.TcCbqa_slider:focus-visible .TcCbqa_sliderTrack{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:3px}.TcCbqa_rowBadge{flex:none;margin-inline-start:6px}.TcCbqa_row{align-items:center;gap:2px;display:flex}.TcCbqa_rowPick{box-sizing:border-box;width:100%;min-width:0;min-height:34px;color:inherit;text-align:left;cursor:pointer;border-radius:var(--dsw-radius-md);padding-inline:6px;background:0 0;border:none;outline:none;flex:1;align-items:center;gap:4px;padding:5px 7px;display:flex}.TcCbqa_rowPick:hover:not(:disabled),.TcCbqa_rowPick:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_rowPick:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_rowCopy{flex-direction:column;flex:1;min-width:0;display:flex}.TcCbqa_rowName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;font-weight:400;line-height:17px;overflow:hidden}.TcCbqa_rowMeta{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.TcCbqa_check{color:var(--dsw-alias-label-primary);flex:0 0 15px;place-items:center;display:grid}.TcCbqa_starButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;border-radius:var(--dsw-radius-sm);opacity:0;background:0 0;border:none;outline:none;flex:none;place-items:center;width:26px;height:26px;display:grid}.TcCbqa_starButton:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_row:hover .TcCbqa_starButton,.TcCbqa_row:focus-within .TcCbqa_starButton{opacity:1}.TcCbqa_starButton[aria-pressed=true]{color:var(--dsw-alias-state-warn-primary);opacity:1}@media (hover:none){.TcCbqa_starButton{opacity:1}}.TcCbqa_star{flex:none}.TcCbqa_notice{color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:flex-start;gap:8px;padding:6px 10px;font-size:12px;line-height:18px;display:flex}.TcCbqa_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600;text-decoration:underline}.TcCbqa_pickerDialog.TcCbqa_pickerDialog{gap:0;width:min(680px,100%);height:min(640px,80vh);padding:0}.TcCbqa_pickerContent,.TcCbqa_pickerContent>:last-child{flex-direction:column;flex:1;min-height:0;display:flex}.TcCbqa_pickerSearch{padding:0 20px 12px}.TcCbqa_pickerSearchInput{width:100%}.TcCbqa_pickerTabs{border-bottom:.5px solid var(--dsw-alias-border-l2);overscroll-behavior-x:contain;scrollbar-width:none;flex-wrap:nowrap;gap:2px;padding:0 16px;display:flex;overflow-x:auto}.TcCbqa_pickerTabs::-webkit-scrollbar{display:none}.TcCbqa_pickerTab{color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:var(--dsw-radius-sm);white-space:nowrap;background:0 0;border:none;outline:none;flex:none;padding:6px 10px;font-size:13px;line-height:18px}.TcCbqa_pickerTab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_pickerTab[aria-selected=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);font-weight:600}.TcCbqa_pickerTab:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_pickerList{flex:1;min-height:0;padding:8px 12px;overflow-y:auto}.TcCbqa_pickerFooter{border-top:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);align-items:center;gap:6px;padding:10px 20px;font-size:12px;line-height:18px;display:flex}.TcCbqa_footerHint{flex-wrap:wrap;align-items:center;gap:6px;display:flex}";
|
|
262
|
-
var ModelOptions_module_css_default = {
|
|
263
|
-
"check": "TcCbqa_check",
|
|
264
|
-
"footerHint": "TcCbqa_footerHint",
|
|
265
|
-
"modelBrowse": "TcCbqa_modelBrowse",
|
|
266
|
-
"modelCell": "TcCbqa_modelCell",
|
|
267
|
-
"notice": "TcCbqa_notice",
|
|
268
|
-
"pickerContent": "TcCbqa_pickerContent",
|
|
269
|
-
"pickerDialog": "TcCbqa_pickerDialog",
|
|
270
|
-
"pickerFooter": "TcCbqa_pickerFooter",
|
|
271
|
-
"pickerHost": "TcCbqa_pickerHost",
|
|
272
|
-
"pickerList": "TcCbqa_pickerList",
|
|
273
|
-
"pickerSearch": "TcCbqa_pickerSearch",
|
|
274
|
-
"pickerSearchInput": "TcCbqa_pickerSearchInput",
|
|
275
|
-
"pickerTab": "TcCbqa_pickerTab",
|
|
276
|
-
"pickerTabs": "TcCbqa_pickerTabs",
|
|
277
|
-
"quickBadge": "TcCbqa_quickBadge",
|
|
278
|
-
"quickCheck": "TcCbqa_quickCheck",
|
|
279
|
-
"quickCopy": "TcCbqa_quickCopy",
|
|
280
|
-
"quickName": "TcCbqa_quickName",
|
|
281
|
-
"quickOption": "TcCbqa_quickOption",
|
|
282
|
-
"retry": "TcCbqa_retry",
|
|
283
|
-
"row": "TcCbqa_row",
|
|
284
|
-
"rowBadge": "TcCbqa_rowBadge",
|
|
285
|
-
"rowCopy": "TcCbqa_rowCopy",
|
|
286
|
-
"rowMeta": "TcCbqa_rowMeta",
|
|
287
|
-
"rowName": "TcCbqa_rowName",
|
|
288
|
-
"rowPick": "TcCbqa_rowPick",
|
|
289
|
-
"slider": "TcCbqa_slider",
|
|
290
|
-
"sliderCell": "TcCbqa_sliderCell",
|
|
291
|
-
"sliderFill": "TcCbqa_sliderFill",
|
|
292
|
-
"sliderKnob": "TcCbqa_sliderKnob",
|
|
293
|
-
"sliderTick": "TcCbqa_sliderTick",
|
|
294
|
-
"sliderTrack": "TcCbqa_sliderTrack",
|
|
295
|
-
"star": "TcCbqa_star",
|
|
296
|
-
"starButton": "TcCbqa_starButton"
|
|
297
|
-
};
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/client/EffortSlider.tsx
|
|
300
|
-
/**
|
|
301
|
-
* The reasoning-level slider that replaces the Host's effort drill.
|
|
302
|
-
*
|
|
303
|
-
* The Host's second menu cell is a button that drills into a list of levels.
|
|
304
|
-
* This slider sits inside that same cell, between the Host's label and value, so
|
|
305
|
-
* the levels are reachable without leaving the menu. The levels are discrete but
|
|
306
|
-
* the drag is not: the knob follows the pointer continuously, the level it
|
|
307
|
-
* reports is the detent nearest that position, and letting go eases the knob onto
|
|
308
|
-
* that detent and commits once. Keyboard arrows step and commit immediately.
|
|
309
|
-
*
|
|
310
|
-
* The fill takes the level's color, so the track and the two captions read as
|
|
311
|
-
* one signal: "off" is neutral, the levels above it walk a blue-to-violet ramp,
|
|
312
|
-
* and only the top level fills with the whole gradient.
|
|
313
|
-
*
|
|
314
|
-
* "Provider default" is not a detent: it is a state, drawn as an empty track
|
|
315
|
-
* with a hollow knob, so it never reads as the lowest level.
|
|
316
|
-
*/
|
|
317
|
-
/**
|
|
318
|
-
* Render the slider.
|
|
319
|
-
* @param props - levels, the level in force, and the commit path.
|
|
320
|
-
* @returns one focusable slider over the discrete levels.
|
|
321
|
-
*/
|
|
322
|
-
function EffortSlider({ steps, current, defaultActive, defaultIndex, defaultLabel, busy, label, onCommit }) {
|
|
323
|
-
const trackRef = (0, react.useRef)(null);
|
|
324
|
-
const dragRef = (0, react.useRef)(null);
|
|
325
|
-
const pointerRef = (0, react.useRef)(null);
|
|
326
|
-
const [drag, setDrag] = (0, react.useState)(null);
|
|
327
|
-
const [hold, setHold] = (0, react.useState)(null);
|
|
328
|
-
const dragging = drag !== null;
|
|
329
|
-
const resting = defaultActive ? defaultIndex : current;
|
|
330
|
-
const active = dragging ? detentAt(drag, steps.length) : resting;
|
|
331
|
-
const knobFraction = drag ?? hold ?? offsetOf(resting, steps.length);
|
|
332
|
-
const shown = dragging || hold !== null ? detentAt(knobFraction, steps.length) : resting;
|
|
333
|
-
const beginDrag = (fraction) => {
|
|
334
|
-
dragRef.current = fraction;
|
|
335
|
-
setDrag(fraction);
|
|
336
|
-
};
|
|
337
|
-
(0, react.useEffect)(() => {
|
|
338
|
-
if (!busy) {
|
|
339
|
-
setHold(null);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
pointerRef.current = null;
|
|
343
|
-
dragRef.current = null;
|
|
344
|
-
setDrag(null);
|
|
345
|
-
}, [busy]);
|
|
346
|
-
(0, react.useEffect)(() => {
|
|
347
|
-
setHold(null);
|
|
348
|
-
}, [current, defaultActive]);
|
|
349
|
-
const fractionAtPointer = (clientX) => {
|
|
350
|
-
const track = trackRef.current;
|
|
351
|
-
if (track === null) return dragRef.current ?? knobFraction;
|
|
352
|
-
const rect = track.getBoundingClientRect();
|
|
353
|
-
return fractionAt(clientX, rect.left, rect.width);
|
|
354
|
-
};
|
|
355
|
-
const onPointerDown = (event) => {
|
|
356
|
-
if (busy || event.button !== 0 || pointerRef.current !== null) return;
|
|
357
|
-
event.preventDefault();
|
|
358
|
-
event.stopPropagation();
|
|
359
|
-
setHold(null);
|
|
360
|
-
pointerRef.current = event.pointerId;
|
|
361
|
-
beginDrag(fractionAtPointer(event.clientX));
|
|
362
|
-
try {
|
|
363
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
364
|
-
} catch {}
|
|
365
|
-
event.currentTarget.focus();
|
|
366
|
-
};
|
|
367
|
-
const onPointerMove = (event) => {
|
|
368
|
-
if (pointerRef.current !== event.pointerId || busy) return;
|
|
369
|
-
beginDrag(fractionAtPointer(event.clientX));
|
|
370
|
-
};
|
|
371
|
-
const settle = (event, commit) => {
|
|
372
|
-
if (pointerRef.current !== event.pointerId) return;
|
|
373
|
-
pointerRef.current = null;
|
|
374
|
-
beginDrag(null);
|
|
375
|
-
if (!commit || busy) return;
|
|
376
|
-
const next = detentAt(fractionAtPointer(event.clientX), steps.length);
|
|
377
|
-
if (next !== current || defaultActive) {
|
|
378
|
-
setHold(offsetOf(next, steps.length));
|
|
379
|
-
onCommit(next);
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
const onKeyDown = (event) => {
|
|
383
|
-
if (event.nativeEvent.isComposing) return;
|
|
384
|
-
const last = steps.length - 1;
|
|
385
|
-
const next = event.key === "ArrowRight" || event.key === "ArrowUp" ? Math.min(active + 1, last) : event.key === "ArrowLeft" || event.key === "ArrowDown" ? Math.max(active - 1, 0) : event.key === "Home" ? 0 : event.key === "End" ? last : null;
|
|
386
|
-
if (next === null) return;
|
|
387
|
-
event.preventDefault();
|
|
388
|
-
event.stopPropagation();
|
|
389
|
-
if (!busy && (next !== current || defaultActive)) onCommit(next);
|
|
390
|
-
};
|
|
391
|
-
const offset = knobOffset(knobFraction);
|
|
392
|
-
const idle = defaultActive && !dragging && hold === null;
|
|
393
|
-
const filled = idle ? 0 : knobFraction;
|
|
394
|
-
const fill = isTopLevel(shown, steps.length) ? LEVEL_GRADIENT : levelColor(shown, steps.length);
|
|
395
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
396
|
-
ref: trackRef,
|
|
397
|
-
className: ModelOptions_module_css_default.slider,
|
|
398
|
-
role: "slider",
|
|
399
|
-
tabIndex: 0,
|
|
400
|
-
"aria-label": label,
|
|
401
|
-
"aria-valuemin": 0,
|
|
402
|
-
"aria-valuemax": Math.max(0, steps.length - 1),
|
|
403
|
-
"aria-valuenow": active,
|
|
404
|
-
"aria-valuetext": defaultActive && !dragging ? defaultLabel : steps[active]?.label,
|
|
405
|
-
"aria-disabled": busy || void 0,
|
|
406
|
-
"data-busy": busy ? "" : void 0,
|
|
407
|
-
"data-dragging": dragging ? "" : void 0,
|
|
408
|
-
"data-default": idle ? "" : void 0,
|
|
409
|
-
onPointerDown,
|
|
410
|
-
onPointerMove,
|
|
411
|
-
onPointerUp: (event) => {
|
|
412
|
-
settle(event, true);
|
|
413
|
-
},
|
|
414
|
-
onPointerCancel: (event) => {
|
|
415
|
-
settle(event, false);
|
|
416
|
-
},
|
|
417
|
-
onLostPointerCapture: (event) => {
|
|
418
|
-
settle(event, false);
|
|
419
|
-
},
|
|
420
|
-
onKeyDown,
|
|
421
|
-
onClick: (event) => {
|
|
422
|
-
event.stopPropagation();
|
|
423
|
-
},
|
|
424
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
425
|
-
className: ModelOptions_module_css_default.sliderTrack,
|
|
426
|
-
"aria-hidden": "true",
|
|
427
|
-
children: [
|
|
428
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
429
|
-
className: ModelOptions_module_css_default.sliderFill,
|
|
430
|
-
style: {
|
|
431
|
-
width: fillWidth(filled),
|
|
432
|
-
background: fill
|
|
433
|
-
}
|
|
434
|
-
}),
|
|
435
|
-
steps.map((step, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
436
|
-
className: ModelOptions_module_css_default.sliderTick,
|
|
437
|
-
"data-on": index <= shown && !idle ? "" : void 0,
|
|
438
|
-
style: { left: knobOffset(offsetOf(index, steps.length)) }
|
|
439
|
-
}, step.key)),
|
|
440
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
441
|
-
className: ModelOptions_module_css_default.sliderKnob,
|
|
442
|
-
style: { left: offset }
|
|
443
|
-
})
|
|
444
|
-
]
|
|
445
|
-
})
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
//#endregion
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
449
11
|
//#region src/client/effort-memory.ts
|
|
450
|
-
/** The single browser-wide storage key holding the whole memory. */
|
|
451
12
|
const EFFORTS_KEY = "dsh-model-submenu.efforts";
|
|
452
|
-
/**
|
|
453
|
-
* Read the memory, keeping only rows naming both halves and a level.
|
|
454
|
-
* @param storage - browser storage, or undefined when the browser withholds it.
|
|
455
|
-
* @returns the remembered rows; empty when unreadable.
|
|
456
|
-
*/
|
|
457
13
|
function readEfforts(storage) {
|
|
458
14
|
const raw = getItem$1(storage);
|
|
459
15
|
if (raw === null) return [];
|
|
@@ -466,23 +22,9 @@ window.__ModuleLoader__.load({
|
|
|
466
22
|
if (!Array.isArray(parsed)) return [];
|
|
467
23
|
return parsed.filter((row) => typeof row === "object" && row !== null && typeof row.provider === "string" && typeof row.model === "string" && typeof row.effort === "string" && row.effort !== "");
|
|
468
24
|
}
|
|
469
|
-
/**
|
|
470
|
-
* @param memory - the rows to search.
|
|
471
|
-
* @param provider - the provider route key.
|
|
472
|
-
* @param model - the model id inside that provider.
|
|
473
|
-
* @returns the level last chosen for that exact model, or undefined.
|
|
474
|
-
*/
|
|
475
25
|
function effortFor(memory, provider, model) {
|
|
476
26
|
return memory.find((row) => row.provider === provider && row.model === model)?.effort;
|
|
477
27
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Remember one model's level, or forget it when the choice is the provider default.
|
|
480
|
-
* @param storage - browser storage, or undefined when writes are unavailable.
|
|
481
|
-
* @param provider - the provider route key.
|
|
482
|
-
* @param model - the model id inside that provider.
|
|
483
|
-
* @param effort - the chosen level, undefined meaning the provider default.
|
|
484
|
-
* @returns the memory after the change, whether or not the write landed.
|
|
485
|
-
*/
|
|
486
28
|
function rememberEffort(storage, provider, model, effort) {
|
|
487
29
|
const rest = readEfforts(storage).filter((row) => row.provider !== provider || row.model !== model);
|
|
488
30
|
const next = effort === void 0 ? rest : [...rest, {
|
|
@@ -504,9 +46,7 @@ window.__ModuleLoader__.load({
|
|
|
504
46
|
}
|
|
505
47
|
//#endregion
|
|
506
48
|
//#region src/client/favorites.ts
|
|
507
|
-
/** The single browser-wide storage key holding the whole table. */
|
|
508
49
|
const FAVORITES_KEY = "dsh-model-submenu.favorites";
|
|
509
|
-
/** A browser can withhold access to localStorage itself. */
|
|
510
50
|
function storageOf() {
|
|
511
51
|
try {
|
|
512
52
|
return globalThis.localStorage;
|
|
@@ -514,11 +54,6 @@ window.__ModuleLoader__.load({
|
|
|
514
54
|
return;
|
|
515
55
|
}
|
|
516
56
|
}
|
|
517
|
-
/**
|
|
518
|
-
* Read the table, keeping only rows that name both halves.
|
|
519
|
-
* @param storage - browser storage, or undefined when the browser withholds it.
|
|
520
|
-
* @returns the stored favorites in stored order; empty when unreadable.
|
|
521
|
-
*/
|
|
522
57
|
function readFavorites(storage) {
|
|
523
58
|
const raw = getItem(storage);
|
|
524
59
|
if (raw === null) return [];
|
|
@@ -531,13 +66,6 @@ window.__ModuleLoader__.load({
|
|
|
531
66
|
if (!Array.isArray(parsed)) return [];
|
|
532
67
|
return parsed.filter((row) => typeof row === "object" && row !== null && typeof row.provider === "string" && typeof row.model === "string");
|
|
533
68
|
}
|
|
534
|
-
/**
|
|
535
|
-
* Add or remove one model, writing the whole table back.
|
|
536
|
-
* @param storage - browser storage, or undefined when writes are unavailable.
|
|
537
|
-
* @param provider - the provider route key.
|
|
538
|
-
* @param model - the model id inside that provider.
|
|
539
|
-
* @returns the table after the change, whether or not the write landed.
|
|
540
|
-
*/
|
|
541
69
|
function toggleFavorite(storage, provider, model) {
|
|
542
70
|
const current = readFavorites(storage);
|
|
543
71
|
const next = isFavorite(current, provider, model) ? current.filter((row) => row.provider !== provider || row.model !== model) : [...current, {
|
|
@@ -549,22 +77,9 @@ window.__ModuleLoader__.load({
|
|
|
549
77
|
} catch {}
|
|
550
78
|
return next;
|
|
551
79
|
}
|
|
552
|
-
/**
|
|
553
|
-
* @param favorites - the table to search.
|
|
554
|
-
* @param provider - the provider route key.
|
|
555
|
-
* @param model - the model id inside that provider.
|
|
556
|
-
* @returns whether that exact pair is favorited.
|
|
557
|
-
*/
|
|
558
80
|
function isFavorite(favorites, provider, model) {
|
|
559
81
|
return favorites.some((row) => row.provider === provider && row.model === model);
|
|
560
82
|
}
|
|
561
|
-
/**
|
|
562
|
-
* Stable-partition a catalog so favorited rows lead, each part keeping the
|
|
563
|
-
* catalog's own order.
|
|
564
|
-
* @param rows - the catalog in its display order.
|
|
565
|
-
* @param favorited - predicate answering whether one row is favorited.
|
|
566
|
-
* @returns a new list; the input order when nothing is favorited.
|
|
567
|
-
*/
|
|
568
83
|
function orderWithFavorites(rows, favorited) {
|
|
569
84
|
const starred = rows.filter(favorited);
|
|
570
85
|
if (starred.length === 0) return rows;
|
|
@@ -578,10 +93,81 @@ window.__ModuleLoader__.load({
|
|
|
578
93
|
}
|
|
579
94
|
}
|
|
580
95
|
//#endregion
|
|
96
|
+
//#region src/client/selection.ts
|
|
97
|
+
function planModelCommit(live, provider, model, reasoningOf, remembered) {
|
|
98
|
+
if (live !== null && sameModel(live, provider, model)) return null;
|
|
99
|
+
const offered = reasoningOf(provider, model);
|
|
100
|
+
return {
|
|
101
|
+
provider,
|
|
102
|
+
model,
|
|
103
|
+
...offered !== void 0 && remembered !== void 0 && offered.efforts.some((level) => level.id === remembered) ? { reasoningEffort: remembered } : {}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function currentCatalogModel(state) {
|
|
107
|
+
const current = state.current;
|
|
108
|
+
if (current === null) return void 0;
|
|
109
|
+
return state.groups.find((group) => group.id === current.provider)?.models.find((model) => model.id === current.model);
|
|
110
|
+
}
|
|
111
|
+
function selectionOf(state) {
|
|
112
|
+
if (state.current === null) return null;
|
|
113
|
+
return state.current.reasoningEffort === void 0 ? {
|
|
114
|
+
provider: state.current.provider,
|
|
115
|
+
model: state.current.model
|
|
116
|
+
} : {
|
|
117
|
+
provider: state.current.provider,
|
|
118
|
+
model: state.current.model,
|
|
119
|
+
reasoningEffort: state.current.reasoningEffort
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function sameModel(live, provider, model) {
|
|
123
|
+
return live.provider === provider && live.model === model;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region \0dsh-css:/home/runner/work/my-dsh/my-dsh/plugins/dsh-model-submenu/src/client/ModelOptions.module.css.mjs
|
|
127
|
+
const stylesheet = ".TcCbqa_pickerHost{display:contents}.TcCbqa_modelCell.TcCbqa_modelCell{anchor-name:--dsh-quick-model-row;padding-inline-end:14px}.TcCbqa_modelCell>svg:last-child{visibility:hidden}.TcCbqa_modelBrowse{position-anchor:--dsh-quick-model-row;top:anchor(top);bottom:anchor(bottom);border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;place-items:center;padding:0;display:grid;position:absolute;inset-inline-end:anchor(end)}.TcCbqa_modelBrowse:hover:not(:disabled),.TcCbqa_modelBrowse:focus-visible{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.TcCbqa_quickOption{border-radius:var(--dsw-radius-md);width:100%;min-height:34px;color:inherit;text-align:start;cursor:pointer;background:0 0;border:0;outline:none;align-items:center;gap:6px;padding:5px 7px;font-size:13px;font-weight:400;line-height:18px;display:flex}.TcCbqa_quickOption:hover:not(:disabled,[aria-disabled=true]),.TcCbqa_quickOption:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_quickOption:disabled,.TcCbqa_quickOption[aria-disabled=true]{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_quickCopy{flex:1;align-items:center;gap:4px;min-width:0;display:flex}.TcCbqa_quickName{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.TcCbqa_quickBadge{flex:none}.TcCbqa_quickCheck{flex:0 0 14px;place-items:center;display:grid}.TcCbqa_quickFooter{border-block-start:.5px solid var(--dsw-alias-border-l2);margin-block-start:4px;padding-block-start:4px}.TcCbqa_rowBadge{flex:none;margin-inline-start:6px}.TcCbqa_row{align-items:center;gap:2px;display:flex}.TcCbqa_rowPick{box-sizing:border-box;width:100%;min-width:0;min-height:34px;color:inherit;text-align:left;cursor:pointer;border-radius:var(--dsw-radius-md);padding-inline:6px;background:0 0;border:none;outline:none;flex:1;align-items:center;gap:4px;padding:5px 7px;display:flex}.TcCbqa_rowPick:hover:not(:disabled),.TcCbqa_rowPick:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_rowPick:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_rowCopy{flex-direction:column;flex:1;min-width:0;display:flex}.TcCbqa_rowName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;font-weight:400;line-height:17px;overflow:hidden}.TcCbqa_rowMeta{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.TcCbqa_check{color:var(--dsw-alias-label-primary);flex:0 0 15px;place-items:center;display:grid}.TcCbqa_starButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;border-radius:var(--dsw-radius-sm);opacity:0;background:0 0;border:none;outline:none;flex:none;place-items:center;width:26px;height:26px;display:grid}.TcCbqa_starButton:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_row:hover .TcCbqa_starButton,.TcCbqa_row:focus-within .TcCbqa_starButton{opacity:1}.TcCbqa_starButton[aria-pressed=true]{color:var(--dsw-alias-state-warn-primary);opacity:1}@media (hover:none){.TcCbqa_starButton{opacity:1}}.TcCbqa_star{flex:none}.TcCbqa_notice{color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:flex-start;gap:8px;padding:6px 10px;font-size:12px;line-height:18px;display:flex}.TcCbqa_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600;text-decoration:underline}.TcCbqa_pickerDialog.TcCbqa_pickerDialog{gap:0;width:min(680px,100%);height:min(640px,80vh);max-height:100%;padding:0}.TcCbqa_pickerContent,.TcCbqa_pickerContent :has(.TcCbqa_pickerBody),.TcCbqa_pickerBody{flex-direction:column;flex:1;min-height:0;display:flex}.TcCbqa_pickerSearch,.TcCbqa_pickerTabs,.TcCbqa_pickerFooter{flex:none}.TcCbqa_pickerSearch{padding:0 20px 12px}.TcCbqa_pickerSearchInput{width:100%}.TcCbqa_pickerTabs{border-bottom:.5px solid var(--dsw-alias-border-l2);overscroll-behavior-x:contain;scrollbar-width:none;flex-wrap:nowrap;gap:2px;padding:0 16px;display:flex;overflow-x:auto}.TcCbqa_pickerTabs::-webkit-scrollbar{display:none}.TcCbqa_pickerTab{color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:var(--dsw-radius-sm);white-space:nowrap;background:0 0;border:none;outline:none;flex:none;padding:6px 10px;font-size:13px;line-height:18px}.TcCbqa_pickerTab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_pickerTab[aria-selected=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);font-weight:600}.TcCbqa_pickerTab:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_pickerList{flex:1;min-height:0;padding:8px 12px;overflow-y:auto}.TcCbqa_pickerFooter{border-top:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:center;gap:12px;padding:10px 20px;font-size:12px;line-height:18px;display:flex}.TcCbqa_footerHint{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.TcCbqa_footerFavorites{text-align:end}";
|
|
128
|
+
var ModelOptions_module_css_default = {
|
|
129
|
+
"check": "TcCbqa_check",
|
|
130
|
+
"footerFavorites": "TcCbqa_footerFavorites",
|
|
131
|
+
"footerHint": "TcCbqa_footerHint",
|
|
132
|
+
"modelBrowse": "TcCbqa_modelBrowse",
|
|
133
|
+
"modelCell": "TcCbqa_modelCell",
|
|
134
|
+
"notice": "TcCbqa_notice",
|
|
135
|
+
"pickerBody": "TcCbqa_pickerBody",
|
|
136
|
+
"pickerContent": "TcCbqa_pickerContent",
|
|
137
|
+
"pickerDialog": "TcCbqa_pickerDialog",
|
|
138
|
+
"pickerFooter": "TcCbqa_pickerFooter",
|
|
139
|
+
"pickerHost": "TcCbqa_pickerHost",
|
|
140
|
+
"pickerList": "TcCbqa_pickerList",
|
|
141
|
+
"pickerSearch": "TcCbqa_pickerSearch",
|
|
142
|
+
"pickerSearchInput": "TcCbqa_pickerSearchInput",
|
|
143
|
+
"pickerTab": "TcCbqa_pickerTab",
|
|
144
|
+
"pickerTabs": "TcCbqa_pickerTabs",
|
|
145
|
+
"quickBadge": "TcCbqa_quickBadge",
|
|
146
|
+
"quickCheck": "TcCbqa_quickCheck",
|
|
147
|
+
"quickCopy": "TcCbqa_quickCopy",
|
|
148
|
+
"quickFooter": "TcCbqa_quickFooter",
|
|
149
|
+
"quickName": "TcCbqa_quickName",
|
|
150
|
+
"quickOption": "TcCbqa_quickOption",
|
|
151
|
+
"retry": "TcCbqa_retry",
|
|
152
|
+
"row": "TcCbqa_row",
|
|
153
|
+
"rowBadge": "TcCbqa_rowBadge",
|
|
154
|
+
"rowCopy": "TcCbqa_rowCopy",
|
|
155
|
+
"rowMeta": "TcCbqa_rowMeta",
|
|
156
|
+
"rowName": "TcCbqa_rowName",
|
|
157
|
+
"rowPick": "TcCbqa_rowPick",
|
|
158
|
+
"star": "TcCbqa_star",
|
|
159
|
+
"starButton": "TcCbqa_starButton"
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
581
162
|
//#region src/client/QuickModels.tsx
|
|
582
163
|
const QUICK_MODELS_PANE = "lynn-quick-models";
|
|
583
|
-
|
|
584
|
-
|
|
164
|
+
function confirmOnTab(event) {
|
|
165
|
+
if (event.key !== "Tab" || event.shiftKey || event.nativeEvent.isComposing) return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
event.stopPropagation();
|
|
168
|
+
event.currentTarget.click();
|
|
169
|
+
}
|
|
170
|
+
function QuickModels({ sessionId, picker, locked, dismiss, reportFailure, directory, resolveText, select, t }) {
|
|
585
171
|
const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
|
|
586
172
|
const [favorites] = (0, react.useState)(() => readFavorites(storageOf()));
|
|
587
173
|
const open = (0, react.useRef)(false);
|
|
@@ -620,117 +206,90 @@ window.__ModuleLoader__.load({
|
|
|
620
206
|
role: "menu",
|
|
621
207
|
"aria-label": t("picker.quick"),
|
|
622
208
|
"aria-busy": busy,
|
|
623
|
-
children: [
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
209
|
+
children: [
|
|
210
|
+
groups.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
211
|
+
className: ModelOptions_module_css_default.notice,
|
|
212
|
+
role: "status",
|
|
213
|
+
children: t(state.status === "loading" ? "status.loading" : "status.empty")
|
|
214
|
+
}),
|
|
215
|
+
groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuGroup, {
|
|
216
|
+
label: group.name,
|
|
217
|
+
children: group.models.map((model) => {
|
|
218
|
+
const selected = live !== null && sameModel(live, group.id, model.id);
|
|
219
|
+
const pending = state.pending !== null && sameModel(state.pending, group.id, model.id);
|
|
220
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
221
|
+
type: "button",
|
|
222
|
+
role: "menuitemradio",
|
|
223
|
+
"aria-checked": selected,
|
|
224
|
+
"aria-disabled": busy,
|
|
225
|
+
autoFocus: selected,
|
|
226
|
+
className: ModelOptions_module_css_default.quickOption,
|
|
227
|
+
title: model.name,
|
|
228
|
+
onClick: () => {
|
|
229
|
+
choose(group.id, model);
|
|
230
|
+
},
|
|
231
|
+
onKeyDown: confirmOnTab,
|
|
232
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
233
|
+
className: ModelOptions_module_css_default.quickCopy,
|
|
234
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
235
|
+
className: ModelOptions_module_css_default.quickName,
|
|
236
|
+
children: model.name
|
|
237
|
+
}), model.badge !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
238
|
+
className: ModelOptions_module_css_default.quickBadge,
|
|
239
|
+
tone: model.badge.tone,
|
|
240
|
+
children: resolveText(model.badge.text)
|
|
241
|
+
})]
|
|
242
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
243
|
+
className: ModelOptions_module_css_default.quickCheck,
|
|
244
|
+
"aria-hidden": "true",
|
|
245
|
+
children: pending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" }) : selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, { size: 14 })
|
|
246
|
+
})]
|
|
247
|
+
}, model.id);
|
|
248
|
+
})
|
|
249
|
+
}, group.id)),
|
|
250
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
251
|
+
className: ModelOptions_module_css_default.quickFooter,
|
|
252
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
633
253
|
type: "button",
|
|
634
|
-
role: "
|
|
635
|
-
"aria-
|
|
636
|
-
"aria-disabled": busy,
|
|
637
|
-
autoFocus: selected,
|
|
254
|
+
role: "menuitem",
|
|
255
|
+
"aria-haspopup": "dialog",
|
|
638
256
|
className: ModelOptions_module_css_default.quickOption,
|
|
639
|
-
|
|
257
|
+
disabled: busy,
|
|
640
258
|
onClick: () => {
|
|
641
|
-
|
|
259
|
+
if (busy || directory.getSnapshot().pending !== null) return;
|
|
260
|
+
dismiss();
|
|
261
|
+
picker.open(sessionId);
|
|
642
262
|
},
|
|
643
|
-
onKeyDown:
|
|
644
|
-
|
|
645
|
-
event.preventDefault();
|
|
646
|
-
event.stopPropagation();
|
|
647
|
-
choose(group.id, model);
|
|
648
|
-
},
|
|
649
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
263
|
+
onKeyDown: confirmOnTab,
|
|
264
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
650
265
|
className: ModelOptions_module_css_default.quickCopy,
|
|
651
|
-
children:
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}), model.badge !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
655
|
-
className: ModelOptions_module_css_default.quickBadge,
|
|
656
|
-
tone: model.badge.tone,
|
|
657
|
-
children: resolveText(model.badge.text)
|
|
658
|
-
})]
|
|
659
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
660
|
-
className: ModelOptions_module_css_default.quickCheck,
|
|
661
|
-
"aria-hidden": "true",
|
|
662
|
-
children: pending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" }) : selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, { size: 14 })
|
|
663
|
-
})]
|
|
664
|
-
}, model.id);
|
|
266
|
+
children: t("picker.browseAll")
|
|
267
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })]
|
|
268
|
+
})
|
|
665
269
|
})
|
|
666
|
-
|
|
270
|
+
]
|
|
667
271
|
});
|
|
668
272
|
}
|
|
669
273
|
//#endregion
|
|
670
274
|
//#region src/client/ModelMenuBridge.tsx
|
|
671
|
-
/**
|
|
672
|
-
* Bridge the Host's own model menu: the model cell opens a short list, its
|
|
673
|
-
* trailing button opens the all-provider picker, and the effort cell carries
|
|
674
|
-
* the reasoning-level slider.
|
|
675
|
-
*
|
|
676
|
-
* The Host owns the root menu's model and effort cells and opens a submenu for each.
|
|
677
|
-
* While the root pane is open, this entry redirects the first cell to a detail
|
|
678
|
-
* pane and mounts the slider in the second cell.
|
|
679
|
-
*
|
|
680
|
-
* Only the model menu's own direct buttons with the expected label, value and
|
|
681
|
-
* chevron are recognized. The options slot output sits in its own wrapper,
|
|
682
|
-
* so other plugins' rows never join that list.
|
|
683
|
-
*
|
|
684
|
-
* Clicking the cell's label switches to the provider default, which is a state
|
|
685
|
-
* rather than a detent: the slider shows it as an empty track under a hollow
|
|
686
|
-
* knob, so it never reads as the weakest level.
|
|
687
|
-
*/
|
|
688
275
|
const cellLabel = ":scope > span[class*=\"cellLabel\"]";
|
|
689
276
|
const cellValue = ":scope > span[class*=\"cellValue\"]";
|
|
690
277
|
const cellChevron = ":scope > svg[class*=\"cellChevron\"]";
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const button = surface.querySelectorAll(":scope > button[role=\"menuitem\"]")[index];
|
|
278
|
+
function hostModelRow(surface) {
|
|
279
|
+
const button = surface.querySelector(":scope > button[role=\"menuitem\"]");
|
|
694
280
|
if (!button?.querySelector(cellLabel) || !button.querySelector(cellValue) || !button.querySelector(cellChevron)) return null;
|
|
695
281
|
return button;
|
|
696
282
|
}
|
|
697
|
-
|
|
698
|
-
* Render the marker, redirect the model cell, and mount the effort slider.
|
|
699
|
-
* @param props - menu state, session, catalog face, and localized copy.
|
|
700
|
-
* @returns an inert marker plus the slider while the effort cell is present.
|
|
701
|
-
*/
|
|
702
|
-
function ModelMenuBridge({ sessionId, picker, locked, dismiss, openPane, reportFailure, available, directory, select, t }) {
|
|
283
|
+
function ModelMenuBridge({ sessionId, picker, locked, dismiss, openPane, available, directory, t }) {
|
|
703
284
|
const markerRef = (0, react.useRef)(null);
|
|
704
|
-
const sliderRef = (0, react.useRef)(null);
|
|
705
|
-
const [surface, setSurface] = (0, react.useState)(null);
|
|
706
285
|
const [modelRow, setModelRow] = (0, react.useState)(null);
|
|
707
286
|
const [browseMount, setBrowseMount] = (0, react.useState)(null);
|
|
708
|
-
const [effortRow, setEffortRow] = (0, react.useState)(null);
|
|
709
|
-
const [rowLabel, setRowLabel] = (0, react.useState)(null);
|
|
710
287
|
const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
|
|
711
|
-
const current = state.current;
|
|
712
|
-
const reasoning = liveReasoning(state);
|
|
713
|
-
const levels = (0, react.useMemo)(() => effortChoices(reasoning), [reasoning]);
|
|
714
|
-
const declared = levels.findIndex((level) => level.effort === reasoning?.defaultEffort);
|
|
715
|
-
const chosen = current?.reasoningEffort === void 0 ? -1 : levels.findIndex((level) => level.effort === current.reasoningEffort);
|
|
716
|
-
const defaultActive = current !== null && current.reasoningEffort === void 0;
|
|
717
|
-
const currentIndex = chosen >= 0 ? chosen : declared >= 0 ? declared : 0;
|
|
718
|
-
const defaultIndex = declared >= 0 ? declared : 0;
|
|
719
288
|
const busy = locked || state.pending !== null;
|
|
720
|
-
const canDefault = !busy && !defaultActive;
|
|
721
289
|
const showQuickModels = available && modelRow !== null && browseMount !== null;
|
|
722
|
-
const showSlider = available && levels.length >= 2 && effortRow !== null;
|
|
723
|
-
(0, react.useLayoutEffect)(() => {
|
|
724
|
-
const nextSurface = markerRef.current?.closest("[data-model-menu][role=\"menu\"]") ?? null;
|
|
725
|
-
if (nextSurface !== surface) setSurface(nextSurface);
|
|
726
|
-
const nextRow = nextSurface === null ? null : hostCell(nextSurface, 1);
|
|
727
|
-
if (nextRow !== effortRow) setEffortRow(nextRow);
|
|
728
|
-
const nextLabel = nextRow?.querySelector(cellLabel)?.textContent?.trim() ?? "";
|
|
729
|
-
if (nextLabel !== (rowLabel ?? "")) setRowLabel(nextLabel);
|
|
730
|
-
});
|
|
731
290
|
(0, react.useLayoutEffect)(() => {
|
|
732
291
|
const menu = markerRef.current?.closest("[data-model-menu][role=\"menu\"]");
|
|
733
|
-
const row = available && menu ?
|
|
292
|
+
const row = available && menu ? hostModelRow(menu) : null;
|
|
734
293
|
if (row === null) {
|
|
735
294
|
setModelRow(null);
|
|
736
295
|
setBrowseMount(null);
|
|
@@ -755,122 +314,40 @@ window.__ModuleLoader__.load({
|
|
|
755
314
|
else row.setAttribute("aria-haspopup", previousPopup);
|
|
756
315
|
};
|
|
757
316
|
}, [available]);
|
|
758
|
-
const submit = (selection) => {
|
|
759
|
-
if (selection === null || busy || directory.getSnapshot().pending !== null) return;
|
|
760
|
-
select(selection).then((result) => {
|
|
761
|
-
if (result === void 0 || result.ok) return;
|
|
762
|
-
reportFailure(result.error.code === "session/writer-held" ? t("error.sessionInUse") : t("error.action", { message: `${result.error.code}: ${result.error.message}` }));
|
|
763
|
-
});
|
|
764
|
-
};
|
|
765
|
-
const commit = (index) => {
|
|
766
|
-
const live = selectionOf(state);
|
|
767
|
-
const level = levels[index];
|
|
768
|
-
if (live === null || level === void 0) return;
|
|
769
|
-
submit(planEffortCommit(live, level.effort));
|
|
770
|
-
};
|
|
771
|
-
const commitDefault = () => {
|
|
772
|
-
const live = selectionOf(state);
|
|
773
|
-
if (live === null) return;
|
|
774
|
-
submit(planEffortCommit(live, void 0));
|
|
775
|
-
};
|
|
776
|
-
const openQuickModels = () => openPane({
|
|
777
|
-
key: QUICK_MODELS_PANE,
|
|
778
|
-
title: t("picker.quick")
|
|
779
|
-
});
|
|
780
|
-
const latest = (0, react.useRef)({
|
|
781
|
-
modelRow,
|
|
782
|
-
showQuickModels,
|
|
783
|
-
openQuickModels,
|
|
784
|
-
busy,
|
|
785
|
-
showSlider,
|
|
786
|
-
effortRow,
|
|
787
|
-
canDefault,
|
|
788
|
-
commitDefault
|
|
789
|
-
});
|
|
790
317
|
(0, react.useLayoutEffect)(() => {
|
|
791
|
-
|
|
792
|
-
modelRow,
|
|
793
|
-
showQuickModels,
|
|
794
|
-
openQuickModels,
|
|
795
|
-
busy,
|
|
796
|
-
showSlider,
|
|
797
|
-
effortRow,
|
|
798
|
-
canDefault,
|
|
799
|
-
commitDefault
|
|
800
|
-
};
|
|
801
|
-
});
|
|
802
|
-
(0, react.useLayoutEffect)(() => {
|
|
803
|
-
if (surface === null) return;
|
|
318
|
+
if (!showQuickModels) return;
|
|
804
319
|
const redirect = (event) => {
|
|
805
|
-
|
|
806
|
-
const request = latest.current;
|
|
807
|
-
if (!(target instanceof Node) || event.defaultPrevented) return;
|
|
808
|
-
if (request.showQuickModels && request.modelRow?.contains(target)) {
|
|
809
|
-
event.preventDefault();
|
|
810
|
-
event.stopPropagation();
|
|
811
|
-
if (!request.busy) request.openQuickModels();
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
const row = request.effortRow;
|
|
815
|
-
if (row === null || !surface.contains(row) || !row.contains(target) || !request.showSlider) return;
|
|
320
|
+
if (event.defaultPrevented) return;
|
|
816
321
|
event.preventDefault();
|
|
817
322
|
event.stopPropagation();
|
|
818
|
-
if (
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
sliderRef.current?.querySelector("[role=\"slider\"]")?.focus();
|
|
824
|
-
};
|
|
825
|
-
surface.addEventListener("click", redirect, true);
|
|
826
|
-
return () => {
|
|
827
|
-
surface.removeEventListener("click", redirect, true);
|
|
828
|
-
};
|
|
829
|
-
}, [surface]);
|
|
830
|
-
(0, react.useLayoutEffect)(() => {
|
|
831
|
-
if (effortRow === null || !showSlider) return;
|
|
832
|
-
const label = effortRow.querySelector(cellLabel);
|
|
833
|
-
const value = effortRow.querySelector(cellValue);
|
|
834
|
-
const chevron = effortRow.querySelector(cellChevron);
|
|
835
|
-
const saved = {
|
|
836
|
-
value: value?.style.display ?? "",
|
|
837
|
-
chevron: chevron?.style.display ?? "",
|
|
838
|
-
cursor: label?.style.cursor ?? "",
|
|
839
|
-
title: label?.getAttribute("title") ?? null
|
|
840
|
-
};
|
|
841
|
-
if (value !== null) value.style.display = "none";
|
|
842
|
-
if (chevron !== null) chevron.style.display = "none";
|
|
843
|
-
if (label !== null && canDefault) {
|
|
844
|
-
label.style.cursor = "pointer";
|
|
845
|
-
label.title = t("effort.useDefault");
|
|
846
|
-
}
|
|
847
|
-
return () => {
|
|
848
|
-
if (value !== null) value.style.display = saved.value;
|
|
849
|
-
if (chevron !== null) chevron.style.display = saved.chevron;
|
|
850
|
-
if (label !== null) {
|
|
851
|
-
label.style.cursor = saved.cursor;
|
|
852
|
-
if (saved.title === null) label.removeAttribute("title");
|
|
853
|
-
else label.title = saved.title;
|
|
854
|
-
}
|
|
323
|
+
if (!busy) openPane({
|
|
324
|
+
key: QUICK_MODELS_PANE,
|
|
325
|
+
title: t("picker.quick")
|
|
326
|
+
});
|
|
855
327
|
};
|
|
328
|
+
modelRow.addEventListener("click", redirect, true);
|
|
329
|
+
return () => modelRow.removeEventListener("click", redirect, true);
|
|
856
330
|
}, [
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
331
|
+
modelRow,
|
|
332
|
+
showQuickModels,
|
|
333
|
+
busy,
|
|
334
|
+
openPane,
|
|
860
335
|
t
|
|
861
336
|
]);
|
|
862
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
337
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
338
|
+
ref: markerRef,
|
|
339
|
+
hidden: true
|
|
340
|
+
}), showQuickModels && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
341
|
+
label: t("picker.browseAll"),
|
|
342
|
+
delayMs: 300,
|
|
343
|
+
disabled: busy,
|
|
344
|
+
portal: true,
|
|
345
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
868
346
|
className: ModelOptions_module_css_default.modelBrowse,
|
|
869
347
|
type: "button",
|
|
870
348
|
role: "menuitem",
|
|
871
349
|
"aria-haspopup": "dialog",
|
|
872
350
|
"aria-label": t("picker.browseAll"),
|
|
873
|
-
title: t("picker.browseAll"),
|
|
874
351
|
disabled: busy,
|
|
875
352
|
onClick: () => {
|
|
876
353
|
if (directory.getSnapshot().pending !== null) return;
|
|
@@ -878,39 +355,11 @@ window.__ModuleLoader__.load({
|
|
|
878
355
|
picker.open(sessionId);
|
|
879
356
|
},
|
|
880
357
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })
|
|
881
|
-
})
|
|
882
|
-
|
|
883
|
-
ref: sliderRef,
|
|
884
|
-
className: ModelOptions_module_css_default.sliderCell,
|
|
885
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EffortSlider, {
|
|
886
|
-
steps: levels,
|
|
887
|
-
current: currentIndex,
|
|
888
|
-
defaultActive,
|
|
889
|
-
defaultIndex,
|
|
890
|
-
defaultLabel: t("effort.providerDefault"),
|
|
891
|
-
busy,
|
|
892
|
-
label: rowLabel !== null && rowLabel !== "" ? rowLabel : t("effort.label"),
|
|
893
|
-
onCommit: commit
|
|
894
|
-
}, JSON.stringify([current?.provider, current?.model]))
|
|
895
|
-
}), effortRow)
|
|
896
|
-
] });
|
|
358
|
+
})
|
|
359
|
+
}), browseMount)] });
|
|
897
360
|
}
|
|
898
361
|
//#endregion
|
|
899
362
|
//#region src/client/icons.tsx
|
|
900
|
-
/**
|
|
901
|
-
* The one glyph this plugin draws itself.
|
|
902
|
-
*
|
|
903
|
-
* The shared icon library carries no star, so the favorite mark is defined here:
|
|
904
|
-
* a five-point star whose outline and fill use the same path, which keeps the
|
|
905
|
-
* hover-only outline and the standing filled state identical in geometry.
|
|
906
|
-
*/
|
|
907
|
-
/**
|
|
908
|
-
* Render the favorite star.
|
|
909
|
-
* @param props.filled - draw the solid star; otherwise the outline.
|
|
910
|
-
* @param props.size - square edge in pixels, matching the shared icon set's default.
|
|
911
|
-
* @param props.className - extra class for colour and placement.
|
|
912
|
-
* @returns the inline SVG.
|
|
913
|
-
*/
|
|
914
363
|
function StarIcon({ filled, size = 14, className }) {
|
|
915
364
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
916
365
|
width: size,
|
|
@@ -927,11 +376,6 @@ window.__ModuleLoader__.load({
|
|
|
927
376
|
}
|
|
928
377
|
//#endregion
|
|
929
378
|
//#region src/client/ModelRow.tsx
|
|
930
|
-
/**
|
|
931
|
-
* Render one model row.
|
|
932
|
-
* @param props - the row's content and behaviour.
|
|
933
|
-
* @returns the row element.
|
|
934
|
-
*/
|
|
935
379
|
function ModelRow({ name, badge, selected, busy, favorited, meta, starLabel, onPick, onToggleFavorite, children }) {
|
|
936
380
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
937
381
|
className: ModelOptions_module_css_default.row,
|
|
@@ -981,34 +425,12 @@ window.__ModuleLoader__.load({
|
|
|
981
425
|
]
|
|
982
426
|
});
|
|
983
427
|
}
|
|
428
|
+
const ACCOUNT_FACTS_PATH = "/api/dsh-model-submenu/account-model-facts";
|
|
984
429
|
//#endregion
|
|
985
430
|
//#region src/client/model-facts.ts
|
|
986
|
-
|
|
987
|
-
* The model knowledge a shipped adapter carries for its own account route.
|
|
988
|
-
*
|
|
989
|
-
* The account route has no `models` list on purpose: the account listing
|
|
990
|
-
* supplies the catalog and settings only carry per-model overrides. The same
|
|
991
|
-
* adapter family ships a default catalog for its API-key route, and the account
|
|
992
|
-
* route serves the same models, so those entries answer what the account
|
|
993
|
-
* profile cannot. Ids and facts mirror the adapter's own table.
|
|
994
|
-
*/
|
|
995
|
-
const FAMILY_DEFAULTS = { "deepseek-account": [{
|
|
996
|
-
id: "deepseek-flash",
|
|
997
|
-
contextWindow: 1e6,
|
|
998
|
-
images: true
|
|
999
|
-
}, {
|
|
1000
|
-
id: "deepseek-v4-pro",
|
|
1001
|
-
contextWindow: 1e6,
|
|
1002
|
-
images: false
|
|
1003
|
-
}] };
|
|
1004
|
-
/**
|
|
1005
|
-
* Build the fact lookup from the settings answer.
|
|
1006
|
-
* @param providers - provider directory rows giving each route's settings address.
|
|
1007
|
-
* @param namespaces - the describe answer's namespace views.
|
|
1008
|
-
* @returns a lookup answering both fields for one provider and model.
|
|
1009
|
-
*/
|
|
1010
|
-
function buildModelFacts(providers, namespaces) {
|
|
431
|
+
function buildModelFacts(providers, namespaces, accountModels = []) {
|
|
1011
432
|
const byName = new Map(namespaces.map((row) => [row.ns, row.value]));
|
|
433
|
+
const accountById = new Map(accountModels.map((model) => [model.id, model]));
|
|
1012
434
|
const profiles = /* @__PURE__ */ new Map();
|
|
1013
435
|
for (const row of providers) {
|
|
1014
436
|
const profile = readPath(byName.get(row.settingsNs), row.settingsPath);
|
|
@@ -1016,34 +438,25 @@ window.__ModuleLoader__.load({
|
|
|
1016
438
|
}
|
|
1017
439
|
return (provider, model) => {
|
|
1018
440
|
const profile = profiles.get(provider);
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
441
|
+
if (profile !== void 0 && Array.isArray(profile.models)) {
|
|
442
|
+
const entry = profile.models.find((candidate) => isRecord(candidate) && candidate.id === model);
|
|
443
|
+
if (entry !== void 0) return {
|
|
444
|
+
contextWindow: contextWindow(entry.contextWindow),
|
|
445
|
+
images: imageAnswer(entry, profile)
|
|
446
|
+
};
|
|
447
|
+
}
|
|
1024
448
|
const override = readOverride(profile, model);
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
return family === void 0 ? {
|
|
1031
|
-
contextWindow: void 0,
|
|
1032
|
-
images: "unknown"
|
|
1033
|
-
} : {
|
|
1034
|
-
contextWindow: family.contextWindow,
|
|
1035
|
-
images: family.images ? "yes" : "no"
|
|
449
|
+
const account = provider === "deepseek-account" ? accountById.get(model) : void 0;
|
|
450
|
+
const modalities = Array.isArray(override?.inputModalities) ? override.inputModalities : account?.inputModalities;
|
|
451
|
+
return {
|
|
452
|
+
contextWindow: contextWindow(override?.contextWindow) ?? contextWindow(account?.contextWindow),
|
|
453
|
+
images: modalities === void 0 ? "unknown" : containsImage(modalities)
|
|
1036
454
|
};
|
|
1037
455
|
};
|
|
1038
456
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
* The two adapter families disagree about an omission. The Messages family
|
|
1043
|
-
* names the field `inputModalities`, and leaving it out means text only. The
|
|
1044
|
-
* pi-ai family names it `input`, and an empty or absent list defers to the
|
|
1045
|
-
* route's `defaultInput`; with no route default the answer stays unknown.
|
|
1046
|
-
*/
|
|
457
|
+
function contextWindow(value) {
|
|
458
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
459
|
+
}
|
|
1047
460
|
function imageAnswer(entry, profile) {
|
|
1048
461
|
if (Array.isArray(entry.inputModalities)) return containsImage(entry.inputModalities);
|
|
1049
462
|
const defaultInput = Array.isArray(profile.defaultInput) ? profile.defaultInput : void 0;
|
|
@@ -1053,7 +466,6 @@ window.__ModuleLoader__.load({
|
|
|
1053
466
|
}
|
|
1054
467
|
return defaultInput === void 0 ? "no" : containsImage(defaultInput);
|
|
1055
468
|
}
|
|
1056
|
-
/** One model's declared override, when the route keeps a `modelOverrides` table. */
|
|
1057
469
|
function readOverride(profile, model) {
|
|
1058
470
|
const overrides = profile?.modelOverrides;
|
|
1059
471
|
if (!isRecord(overrides)) return void 0;
|
|
@@ -1063,25 +475,11 @@ window.__ModuleLoader__.load({
|
|
|
1063
475
|
function containsImage(modalities) {
|
|
1064
476
|
return modalities.includes("image") ? "yes" : "no";
|
|
1065
477
|
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Abbreviate one capacity the way the metadata line shows it.
|
|
1068
|
-
* @param tokens - exact advertised capacity in tokens.
|
|
1069
|
-
* @returns e.g. `1M ctx`, `1.5M ctx`, `272k ctx`, or `512 ctx` below a thousand.
|
|
1070
|
-
*/
|
|
1071
478
|
function formatContextWindow(tokens) {
|
|
1072
479
|
if (tokens >= 1e6) return `${trimNumber(tokens / 1e6)}M ctx`;
|
|
1073
480
|
if (tokens >= 1e3) return `${Math.round(tokens / 1e3)}k ctx`;
|
|
1074
481
|
return `${tokens} ctx`;
|
|
1075
482
|
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Build the metadata line's segments.
|
|
1078
|
-
* @param input.providerName - the provider's display name, omitted inside that provider's own tab.
|
|
1079
|
-
* @param input.facts - what the settings document answered.
|
|
1080
|
-
* @param input.thinks - whether the catalog advertises reasoning levels for this model.
|
|
1081
|
-
* @param input.effortLabel - the localized word for the reasoning segment.
|
|
1082
|
-
* @param input.imageLabel - the localized word for the image segment.
|
|
1083
|
-
* @returns the segments to join; an empty list means show no line.
|
|
1084
|
-
*/
|
|
1085
483
|
function metaSegments(input) {
|
|
1086
484
|
const segments = [];
|
|
1087
485
|
if (input.providerName !== void 0) segments.push(input.providerName);
|
|
@@ -2704,11 +2102,6 @@ window.__ModuleLoader__.load({
|
|
|
2704
2102
|
return ranked.map((entry) => this.#items[entry.index]);
|
|
2705
2103
|
}
|
|
2706
2104
|
};
|
|
2707
|
-
/**
|
|
2708
|
-
* Flatten the catalog to one row per model.
|
|
2709
|
-
* @param groups - the shared directory's provider groups, in display order.
|
|
2710
|
-
* @returns the rows in catalog order.
|
|
2711
|
-
*/
|
|
2712
2105
|
function flattenGroups(groups) {
|
|
2713
2106
|
return groups.flatMap((group) => group.models.map((model) => ({
|
|
2714
2107
|
provider: group.id,
|
|
@@ -2717,12 +2110,6 @@ window.__ModuleLoader__.load({
|
|
|
2717
2110
|
entry: model
|
|
2718
2111
|
})));
|
|
2719
2112
|
}
|
|
2720
|
-
/**
|
|
2721
|
-
* Build the picker's tabs: the all-tab, then one per provider that has a model.
|
|
2722
|
-
* @param groups - the shared directory's provider groups.
|
|
2723
|
-
* @param allLabel - localized label for the all-tab.
|
|
2724
|
-
* @returns the tabs in catalog order.
|
|
2725
|
-
*/
|
|
2726
2113
|
function pickerTabs(groups, allLabel = "All") {
|
|
2727
2114
|
return [{
|
|
2728
2115
|
id: "*",
|
|
@@ -2732,15 +2119,9 @@ window.__ModuleLoader__.load({
|
|
|
2732
2119
|
label: group.name
|
|
2733
2120
|
}))];
|
|
2734
2121
|
}
|
|
2735
|
-
/**
|
|
2736
|
-
* @param rows - the flat catalog.
|
|
2737
|
-
* @param tab - the tab id; the all-tab keeps every row.
|
|
2738
|
-
* @returns the rows the tab shows, in their current order.
|
|
2739
|
-
*/
|
|
2740
2122
|
function rowsForTab(rows, tab) {
|
|
2741
2123
|
return tab === "*" ? rows : rows.filter((row) => row.provider === tab);
|
|
2742
2124
|
}
|
|
2743
|
-
/** Build a reusable search index for the rows in the current provider tab. */
|
|
2744
2125
|
function createModelSearch(rows) {
|
|
2745
2126
|
return new TextSearchIndex(rows, (row) => ({ fuzzy: [
|
|
2746
2127
|
row.entry.name,
|
|
@@ -2749,30 +2130,11 @@ window.__ModuleLoader__.load({
|
|
|
2749
2130
|
row.provider
|
|
2750
2131
|
] }));
|
|
2751
2132
|
}
|
|
2752
|
-
/**
|
|
2753
|
-
* Read the reasoning metadata the catalog advertises for one model.
|
|
2754
|
-
* @param groups - the shared directory's provider groups.
|
|
2755
|
-
* @returns the metadata, or undefined when that model advertises none.
|
|
2756
|
-
*/
|
|
2757
2133
|
function reasoningOf(groups) {
|
|
2758
2134
|
return (provider, model) => groups.find((group) => group.id === provider)?.models.find((candidate) => candidate.id === model)?.reasoning;
|
|
2759
2135
|
}
|
|
2760
2136
|
//#endregion
|
|
2761
2137
|
//#region src/client/ModelPicker.tsx
|
|
2762
|
-
/**
|
|
2763
|
-
* The model picker: the centered dialog opened from the menu's model row.
|
|
2764
|
-
*
|
|
2765
|
-
* It is the one place every provider is visible at once — a search field, a tab
|
|
2766
|
-
* per provider with a model, and one flat list with each model's metadata line.
|
|
2767
|
-
* Favorites lead the list and can be toggled from a row's star without
|
|
2768
|
-
* selecting that row. A click commits at once; a rejected commit keeps the
|
|
2769
|
-
* dialog open so the user can retry or pick another model.
|
|
2770
|
-
*/
|
|
2771
|
-
/**
|
|
2772
|
-
* Render the picker.
|
|
2773
|
-
* @param props - the catalog, the live selection, and the picker's verbs.
|
|
2774
|
-
* @returns the dialog; nothing while closed.
|
|
2775
|
-
*/
|
|
2776
2138
|
function ModelPicker({ open, resolveText, state, live, facts, favorites, busy, rememberedOf, onPick, onToggleFavorite, onReload, onClose, t }) {
|
|
2777
2139
|
const id = (0, react.useId)();
|
|
2778
2140
|
const listRef = (0, react.useRef)(null);
|
|
@@ -2804,120 +2166,126 @@ window.__ModuleLoader__.load({
|
|
|
2804
2166
|
const failures = state.failures.filter((failure) => tab === "*" || failure.id === tab);
|
|
2805
2167
|
const failed = state.error !== null && state.status === "error";
|
|
2806
2168
|
const loading = state.status === "loading";
|
|
2807
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2169
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2808
2170
|
open,
|
|
2809
2171
|
onClose,
|
|
2810
2172
|
title: t("picker.title"),
|
|
2811
2173
|
closeLabel: t("picker.close"),
|
|
2812
2174
|
className: ModelOptions_module_css_default.pickerDialog ?? "",
|
|
2813
2175
|
contentClassName: ModelOptions_module_css_default.pickerContent ?? "",
|
|
2814
|
-
children:
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
className: ModelOptions_module_css_default.
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
className: ModelOptions_module_css_default.notice,
|
|
2862
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.failed", { message: state.error ?? "" }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2863
|
-
type: "button",
|
|
2864
|
-
className: ModelOptions_module_css_default.retry,
|
|
2865
|
-
onClick: onReload,
|
|
2866
|
-
children: t("action.reload")
|
|
2867
|
-
})]
|
|
2868
|
-
}),
|
|
2869
|
-
failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2870
|
-
className: ModelOptions_module_css_default.notice,
|
|
2871
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.providerFailed", {
|
|
2872
|
-
name: failure.name,
|
|
2873
|
-
message: failure.message
|
|
2874
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2875
|
-
type: "button",
|
|
2876
|
-
className: ModelOptions_module_css_default.retry,
|
|
2877
|
-
onClick: onReload,
|
|
2878
|
-
children: t("action.reload")
|
|
2879
|
-
})]
|
|
2880
|
-
}, failure.id)),
|
|
2881
|
-
visible.length === 0 && !loading && !failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2882
|
-
className: ModelOptions_module_css_default.notice,
|
|
2883
|
-
children: state.groups.length === 0 ? t("status.empty") : t("picker.searchEmpty")
|
|
2884
|
-
}),
|
|
2885
|
-
visible.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
|
|
2886
|
-
name: row.entry.name,
|
|
2887
|
-
badge: row.entry.badge === void 0 ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
2888
|
-
tone: row.entry.badge.tone,
|
|
2889
|
-
className: ModelOptions_module_css_default.rowBadge,
|
|
2890
|
-
children: resolveText(row.entry.badge.text)
|
|
2176
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2177
|
+
className: ModelOptions_module_css_default.pickerBody,
|
|
2178
|
+
children: [
|
|
2179
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2180
|
+
className: ModelOptions_module_css_default.pickerSearch,
|
|
2181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
2182
|
+
className: ModelOptions_module_css_default.pickerSearchInput ?? "",
|
|
2183
|
+
type: "text",
|
|
2184
|
+
role: "searchbox",
|
|
2185
|
+
"aria-label": t("picker.search"),
|
|
2186
|
+
"aria-controls": `${id}-list`,
|
|
2187
|
+
placeholder: t("picker.search"),
|
|
2188
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutlineRegular, { size: 14 }),
|
|
2189
|
+
value: query,
|
|
2190
|
+
readOnly: busy,
|
|
2191
|
+
onChange: (event) => {
|
|
2192
|
+
setQuery(event.target.value);
|
|
2193
|
+
},
|
|
2194
|
+
"data-modal-autofocus": (0, _deepseek_ai_dsh_client_ui_primitives.isMobileDevice)() ? void 0 : ""
|
|
2195
|
+
})
|
|
2196
|
+
}),
|
|
2197
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2198
|
+
className: ModelOptions_module_css_default.pickerTabs,
|
|
2199
|
+
role: "tablist",
|
|
2200
|
+
"aria-label": t("picker.title"),
|
|
2201
|
+
children: tabs.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2202
|
+
type: "button",
|
|
2203
|
+
role: "tab",
|
|
2204
|
+
id: `${id}-tab-${entry.id}`,
|
|
2205
|
+
"aria-selected": entry.id === tab,
|
|
2206
|
+
"aria-controls": `${id}-list`,
|
|
2207
|
+
tabIndex: 0,
|
|
2208
|
+
className: ModelOptions_module_css_default.pickerTab,
|
|
2209
|
+
onClick: () => {
|
|
2210
|
+
setTab(entry.id);
|
|
2211
|
+
},
|
|
2212
|
+
children: entry.label
|
|
2213
|
+
}, entry.id))
|
|
2214
|
+
}),
|
|
2215
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2216
|
+
ref: listRef,
|
|
2217
|
+
id: `${id}-list`,
|
|
2218
|
+
className: ModelOptions_module_css_default.pickerList,
|
|
2219
|
+
children: [
|
|
2220
|
+
loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2221
|
+
className: ModelOptions_module_css_default.notice,
|
|
2222
|
+
children: t("status.loading")
|
|
2891
2223
|
}),
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
effortLabel: t("meta.effort"),
|
|
2901
|
-
imageLabel: t("meta.images")
|
|
2224
|
+
failed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2225
|
+
className: ModelOptions_module_css_default.notice,
|
|
2226
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.failed", { message: state.error ?? "" }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2227
|
+
type: "button",
|
|
2228
|
+
className: ModelOptions_module_css_default.retry,
|
|
2229
|
+
onClick: onReload,
|
|
2230
|
+
children: t("action.reload")
|
|
2231
|
+
})]
|
|
2902
2232
|
}),
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2233
|
+
failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2234
|
+
className: ModelOptions_module_css_default.notice,
|
|
2235
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.providerFailed", {
|
|
2236
|
+
name: failure.name,
|
|
2237
|
+
message: failure.message
|
|
2238
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2239
|
+
type: "button",
|
|
2240
|
+
className: ModelOptions_module_css_default.retry,
|
|
2241
|
+
onClick: onReload,
|
|
2242
|
+
children: t("action.reload")
|
|
2243
|
+
})]
|
|
2244
|
+
}, failure.id)),
|
|
2245
|
+
visible.length === 0 && !loading && !failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2246
|
+
className: ModelOptions_module_css_default.notice,
|
|
2247
|
+
children: state.groups.length === 0 ? t("status.empty") : t("picker.searchEmpty")
|
|
2248
|
+
}),
|
|
2249
|
+
visible.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
|
|
2250
|
+
name: row.entry.name,
|
|
2251
|
+
badge: row.entry.badge === void 0 ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
2252
|
+
tone: row.entry.badge.tone,
|
|
2253
|
+
className: ModelOptions_module_css_default.rowBadge,
|
|
2254
|
+
children: resolveText(row.entry.badge.text)
|
|
2255
|
+
}),
|
|
2256
|
+
selected: live?.provider === row.provider && live.model === row.model,
|
|
2257
|
+
busy,
|
|
2258
|
+
favorited: isFavorite(favorites, row.provider, row.model),
|
|
2259
|
+
meta: metaLine({
|
|
2260
|
+
row,
|
|
2261
|
+
facts: facts(row.provider, row.model),
|
|
2262
|
+
providerName: tab === "*" ? row.providerName : void 0,
|
|
2263
|
+
thinks: row.entry.reasoning !== void 0,
|
|
2264
|
+
effortLabel: t("meta.effort"),
|
|
2265
|
+
imageLabel: t("meta.images")
|
|
2266
|
+
}),
|
|
2267
|
+
starLabel: isFavorite(favorites, row.provider, row.model) ? t("picker.unfavorite", { model: row.entry.name }) : t("picker.favorite", { model: row.entry.name }),
|
|
2268
|
+
onPick: () => {
|
|
2269
|
+
pick(row);
|
|
2270
|
+
},
|
|
2271
|
+
onToggleFavorite: () => {
|
|
2272
|
+
onToggleFavorite(row.provider, row.model);
|
|
2273
|
+
}
|
|
2274
|
+
}) }, `${row.provider}/${row.model}`))
|
|
2275
|
+
]
|
|
2276
|
+
}),
|
|
2277
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2278
|
+
className: ModelOptions_module_css_default.pickerFooter,
|
|
2279
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2280
|
+
className: ModelOptions_module_css_default.footerHint,
|
|
2281
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.ShortcutKeys, { keys: ["Esc"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("picker.hintClose") })]
|
|
2282
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2283
|
+
className: ModelOptions_module_css_default.footerFavorites,
|
|
2284
|
+
children: t("picker.hintFavorites")
|
|
2285
|
+
})]
|
|
2918
2286
|
})
|
|
2919
|
-
|
|
2920
|
-
|
|
2287
|
+
]
|
|
2288
|
+
})
|
|
2921
2289
|
});
|
|
2922
2290
|
}
|
|
2923
2291
|
function metaLine(input) {
|
|
@@ -2931,18 +2299,6 @@ window.__ModuleLoader__.load({
|
|
|
2931
2299
|
}
|
|
2932
2300
|
//#endregion
|
|
2933
2301
|
//#region src/client/ModelPickerHost.tsx
|
|
2934
|
-
/**
|
|
2935
|
-
* The composer overlay's picker view: the dialog, its catalog, and its verbs.
|
|
2936
|
-
*
|
|
2937
|
-
* It lives in `conversation.input.overlay` so it can open after the Host's menu
|
|
2938
|
-
* closes or from the toolbar when the current model is missing. Its data comes
|
|
2939
|
-
* from the slot entry's injected face.
|
|
2940
|
-
*/
|
|
2941
|
-
/**
|
|
2942
|
-
* Render the picker for this session.
|
|
2943
|
-
* @param props - session, store, catalog face, and localized copy.
|
|
2944
|
-
* @returns the dialog while the store names this session; otherwise nothing.
|
|
2945
|
-
*/
|
|
2946
2302
|
function ModelPickerHost({ sessionId, picker, available, directory, load, select, resolveText, factsSource, t }) {
|
|
2947
2303
|
const request = (0, react.useSyncExternalStore)(picker.subscribe, picker.getSnapshot);
|
|
2948
2304
|
const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
|
|
@@ -3031,7 +2387,6 @@ window.__ModuleLoader__.load({
|
|
|
3031
2387
|
}, toast.seq)]
|
|
3032
2388
|
});
|
|
3033
2389
|
}
|
|
3034
|
-
/** The Host skips the root menu when the current model is absent from its catalog. */
|
|
3035
2390
|
function ModelPickerFallback({ sessionId, picker, available, directory, t }) {
|
|
3036
2391
|
const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
|
|
3037
2392
|
if (!available || currentCatalogModel(state) !== void 0) return null;
|
|
@@ -3048,9 +2403,6 @@ window.__ModuleLoader__.load({
|
|
|
3048
2403
|
}
|
|
3049
2404
|
//#endregion
|
|
3050
2405
|
//#region src/client/picker-state.ts
|
|
3051
|
-
/**
|
|
3052
|
-
* @returns a store that starts closed.
|
|
3053
|
-
*/
|
|
3054
2406
|
function createPickerStore() {
|
|
3055
2407
|
let snapshot = { sessionId: null };
|
|
3056
2408
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -3084,21 +2436,11 @@ window.__ModuleLoader__.load({
|
|
|
3084
2436
|
contextWindow: void 0,
|
|
3085
2437
|
images: "unknown"
|
|
3086
2438
|
});
|
|
3087
|
-
/**
|
|
3088
|
-
* Join the settings mirror with the provider directory.
|
|
3089
|
-
* @param deps.describe - the settings mirror's describe face.
|
|
3090
|
-
* @param deps.listProviders - reads the LLM provider directory once.
|
|
3091
|
-
* @returns the source, plus `start` which wires both reads and returns its disposer.
|
|
3092
|
-
*/
|
|
3093
2439
|
function createFactsSource(deps) {
|
|
3094
2440
|
const listeners = /* @__PURE__ */ new Set();
|
|
3095
|
-
let providers = [];
|
|
3096
2441
|
let lookup = EMPTY;
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
lookup = providers.length === 0 || namespaces.length === 0 ? EMPTY : buildModelFacts(providers, namespaces);
|
|
3100
|
-
for (const listener of [...listeners]) listener();
|
|
3101
|
-
};
|
|
2442
|
+
let stop;
|
|
2443
|
+
let readOnDemand;
|
|
3102
2444
|
return {
|
|
3103
2445
|
source: {
|
|
3104
2446
|
getSnapshot: () => lookup,
|
|
@@ -3109,27 +2451,94 @@ window.__ModuleLoader__.load({
|
|
|
3109
2451
|
};
|
|
3110
2452
|
}
|
|
3111
2453
|
},
|
|
2454
|
+
refresh: () => readOnDemand?.(),
|
|
3112
2455
|
start: () => {
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
2456
|
+
stop?.();
|
|
2457
|
+
const lifetime = new AbortController();
|
|
2458
|
+
let providers = [];
|
|
2459
|
+
let accountModels = [];
|
|
2460
|
+
let view = deps.describe.getSnapshot().view;
|
|
2461
|
+
let accountRequested = false;
|
|
2462
|
+
const rebuild = () => {
|
|
2463
|
+
lookup = buildModelFacts(providers, view?.namespaces ?? [], accountModels);
|
|
2464
|
+
for (const listener of [...listeners]) listener();
|
|
2465
|
+
};
|
|
2466
|
+
const readDirectory = refreshReader(lifetime.signal, async () => {
|
|
2467
|
+
const answer = await deps.listProviders();
|
|
2468
|
+
return answer.ok ? answer.value : void 0;
|
|
2469
|
+
}, (rows) => {
|
|
2470
|
+
providers = rows;
|
|
3117
2471
|
rebuild();
|
|
3118
|
-
}
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
2472
|
+
});
|
|
2473
|
+
const readAccount = refreshReader(lifetime.signal, async () => deps.loadAccountModels?.(lifetime.signal), (rows) => {
|
|
2474
|
+
accountModels = rows;
|
|
2475
|
+
rebuild();
|
|
2476
|
+
});
|
|
2477
|
+
const refresh = () => {
|
|
2478
|
+
readDirectory();
|
|
2479
|
+
if (accountRequested) readAccount();
|
|
2480
|
+
};
|
|
2481
|
+
const offDescribe = deps.describe.subscribe(() => {
|
|
2482
|
+
const next = deps.describe.getSnapshot().view;
|
|
2483
|
+
if (next === view) return;
|
|
2484
|
+
view = next;
|
|
2485
|
+
rebuild();
|
|
2486
|
+
refresh();
|
|
2487
|
+
});
|
|
2488
|
+
const offInvalidation = deps.subscribeInvalidation?.(refresh);
|
|
2489
|
+
readOnDemand = () => {
|
|
2490
|
+
accountRequested = true;
|
|
2491
|
+
refresh();
|
|
2492
|
+
};
|
|
2493
|
+
stop = () => {
|
|
2494
|
+
if (lifetime.signal.aborted) return;
|
|
2495
|
+
lifetime.abort();
|
|
2496
|
+
offDescribe();
|
|
2497
|
+
offInvalidation?.();
|
|
3122
2498
|
listeners.clear();
|
|
2499
|
+
readOnDemand = void 0;
|
|
2500
|
+
stop = void 0;
|
|
3123
2501
|
};
|
|
2502
|
+
rebuild();
|
|
2503
|
+
refresh();
|
|
2504
|
+
deps.describe.ensure().catch(() => {});
|
|
2505
|
+
return stop;
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
function refreshReader(signal, read, publish) {
|
|
2510
|
+
let reading = false;
|
|
2511
|
+
let queued = false;
|
|
2512
|
+
return () => {
|
|
2513
|
+
if (signal.aborted) return;
|
|
2514
|
+
if (reading) {
|
|
2515
|
+
queued = true;
|
|
2516
|
+
return;
|
|
3124
2517
|
}
|
|
2518
|
+
reading = true;
|
|
2519
|
+
(async () => {
|
|
2520
|
+
try {
|
|
2521
|
+
do {
|
|
2522
|
+
queued = false;
|
|
2523
|
+
const value = await read().catch(() => void 0);
|
|
2524
|
+
if (!signal.aborted && !queued && value !== void 0) publish(value);
|
|
2525
|
+
} while (!signal.aborted && queued);
|
|
2526
|
+
} finally {
|
|
2527
|
+
reading = false;
|
|
2528
|
+
}
|
|
2529
|
+
})();
|
|
3125
2530
|
};
|
|
3126
2531
|
}
|
|
2532
|
+
async function readAccountModels(signal) {
|
|
2533
|
+
const response = await fetch(ACCOUNT_FACTS_PATH, { signal });
|
|
2534
|
+
if (!response.ok) throw new Error(`Account model metadata unavailable (${response.status})`);
|
|
2535
|
+
const rows = await response.json();
|
|
2536
|
+
if (!Array.isArray(rows)) throw new Error("Invalid account model metadata");
|
|
2537
|
+
return rows;
|
|
2538
|
+
}
|
|
3127
2539
|
//#endregion
|
|
3128
2540
|
//#region src/client/locales.ts
|
|
3129
|
-
/** Locale bundles for the all-provider model picker. */
|
|
3130
|
-
/** Dictionary namespace owned by this plugin. */
|
|
3131
2541
|
const NS = "modelSubmenu";
|
|
3132
|
-
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
3133
2542
|
const zh = {
|
|
3134
2543
|
"status.loading": "正在加载模型…",
|
|
3135
2544
|
"status.empty": "没有可用的模型。",
|
|
@@ -3149,13 +2558,10 @@ window.__ModuleLoader__.load({
|
|
|
3149
2558
|
"picker.favorite": "收藏 {model}",
|
|
3150
2559
|
"picker.unfavorite": "取消收藏 {model}",
|
|
3151
2560
|
"picker.hintClose": "关闭",
|
|
2561
|
+
"picker.hintFavorites": "收藏的模型置顶,并加入快捷菜单",
|
|
3152
2562
|
"meta.effort": "思考",
|
|
3153
|
-
"meta.images": "图片输入"
|
|
3154
|
-
"effort.label": "推理等级",
|
|
3155
|
-
"effort.providerDefault": "Default",
|
|
3156
|
-
"effort.useDefault": "切换为默认档位"
|
|
2563
|
+
"meta.images": "图片输入"
|
|
3157
2564
|
};
|
|
3158
|
-
/** English dictionary, checked complete against the zh key set. */
|
|
3159
2565
|
const en = {
|
|
3160
2566
|
"status.loading": "Loading models…",
|
|
3161
2567
|
"status.empty": "No models available.",
|
|
@@ -3175,25 +2581,12 @@ window.__ModuleLoader__.load({
|
|
|
3175
2581
|
"picker.favorite": "Favorite {model}",
|
|
3176
2582
|
"picker.unfavorite": "Remove {model} from favorites",
|
|
3177
2583
|
"picker.hintClose": "close",
|
|
2584
|
+
"picker.hintFavorites": "Favorites first, also in the quick menu",
|
|
3178
2585
|
"meta.effort": "Effort",
|
|
3179
|
-
"meta.images": "Images"
|
|
3180
|
-
"effort.label": "Reasoning effort",
|
|
3181
|
-
"effort.providerDefault": "Default",
|
|
3182
|
-
"effort.useDefault": "Switch to the provider default"
|
|
2586
|
+
"meta.images": "Images"
|
|
3183
2587
|
};
|
|
3184
2588
|
//#endregion
|
|
3185
2589
|
//#region src/client/index.ts
|
|
3186
|
-
/**
|
|
3187
|
-
* Cordis services required by the browser half. `slots` is the contribution
|
|
3188
|
-
* registry, `sessions` tells whether a session may select a model,
|
|
3189
|
-
* `modelDirectories` owns the per-session catalog snapshot both entries render
|
|
3190
|
-
* from, and `configForms` carries the settings provider's shared describe
|
|
3191
|
-
* mirror, which answers each model's context window and accepted modalities.
|
|
3192
|
-
* `remote`, `remote.llm`, and `remote.session` are declared because a service
|
|
3193
|
-
* method runs on the calling context: `directoryFor` reads
|
|
3194
|
-
* `this.ctx.remote.session`, and the provider directory that names each
|
|
3195
|
-
* settings address is read through `this.ctx.remote.llm`.
|
|
3196
|
-
*/
|
|
3197
2590
|
const inject = [
|
|
3198
2591
|
"configForms",
|
|
3199
2592
|
"locale",
|
|
@@ -3204,15 +2597,6 @@ window.__ModuleLoader__.load({
|
|
|
3204
2597
|
"sessions",
|
|
3205
2598
|
"slots"
|
|
3206
2599
|
];
|
|
3207
|
-
/**
|
|
3208
|
-
* Client plugin body: register this plugin's dictionaries, then contribute the
|
|
3209
|
-
* menu bridge, the toolbar entry for a missing current model, the picker
|
|
3210
|
-
* overlay, and the tint for the collapsed trigger's effort caption.
|
|
3211
|
-
*
|
|
3212
|
-
* The overlay stays mounted when the Host closes the model menu, allowing the
|
|
3213
|
-
* picker to open after the menu has been removed.
|
|
3214
|
-
* @param ctx - client root context.
|
|
3215
|
-
*/
|
|
3216
2600
|
function apply(ctx) {
|
|
3217
2601
|
if (typeof document !== "undefined") ctx.effect(() => {
|
|
3218
2602
|
const style = document.createElement("style");
|
|
@@ -3237,14 +2621,20 @@ window.__ModuleLoader__.load({
|
|
|
3237
2621
|
const picker = createPickerStore();
|
|
3238
2622
|
const facts = createFactsSource({
|
|
3239
2623
|
describe: scope.configForms.describe(),
|
|
3240
|
-
listProviders: () => scope.remote.llm.listConfigurableProviders()
|
|
2624
|
+
listProviders: () => scope.remote.llm.listConfigurableProviders(),
|
|
2625
|
+
loadAccountModels: readAccountModels,
|
|
2626
|
+
subscribeInvalidation: (listener) => {
|
|
2627
|
+
const off = [
|
|
2628
|
+
scope.on("connection/reset", listener),
|
|
2629
|
+
scope.remote.$on("llm/adapters-updated", listener),
|
|
2630
|
+
scope.remote.$on("llm/models-updated", listener)
|
|
2631
|
+
];
|
|
2632
|
+
return () => {
|
|
2633
|
+
for (const dispose of off) dispose();
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
3241
2636
|
});
|
|
3242
2637
|
scope.effect(() => facts.start(), "dsh-model-submenu: model metadata");
|
|
3243
|
-
/**
|
|
3244
|
-
* Build one entry's business face for a session.
|
|
3245
|
-
* @param sessionId - the slot's session scope.
|
|
3246
|
-
* @returns the catalog face plus the session and store both entries need.
|
|
3247
|
-
*/
|
|
3248
2638
|
const faceOf = (sessionId) => {
|
|
3249
2639
|
const key = sessionId;
|
|
3250
2640
|
const directory = models.directoryFor(key);
|
|
@@ -3256,7 +2646,9 @@ window.__ModuleLoader__.load({
|
|
|
3256
2646
|
directory: directory.store,
|
|
3257
2647
|
factsSource: facts.source,
|
|
3258
2648
|
load: () => {
|
|
3259
|
-
if (available)
|
|
2649
|
+
if (!available) return;
|
|
2650
|
+
facts.refresh();
|
|
2651
|
+
directory.load().catch(() => {});
|
|
3260
2652
|
},
|
|
3261
2653
|
resolveText: (text) => ctx.locale.resolveText(text),
|
|
3262
2654
|
select: (selection) => available ? directory.select(selection) : Promise.resolve(void 0)
|
|
@@ -3290,16 +2682,9 @@ window.__ModuleLoader__.load({
|
|
|
3290
2682
|
locale: NS,
|
|
3291
2683
|
inject: faceOf
|
|
3292
2684
|
}, ModelPickerFallback));
|
|
3293
|
-
scope.slots.inject("conversation.input.overlay", () => scope.slots.register({
|
|
3294
|
-
name: "conversation.input.overlay",
|
|
3295
|
-
id: "model-effort-tint",
|
|
3296
|
-
registrant: "@lynn123411/dsh-model-submenu",
|
|
3297
|
-
inject: faceOf
|
|
3298
|
-
}, EffortTint));
|
|
3299
2685
|
});
|
|
3300
2686
|
}
|
|
3301
2687
|
//#endregion
|
|
3302
|
-
exports.EffortTint = EffortTint;
|
|
3303
2688
|
exports.ModelMenuBridge = ModelMenuBridge;
|
|
3304
2689
|
exports.ModelPickerHost = ModelPickerHost;
|
|
3305
2690
|
exports.apply = apply;
|