@lynn123411/dsh-model-submenu 0.3.18 → 0.3.19
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 +5 -5
- package/cordis.patch.yml +0 -1
- package/lib/client.js +92 -415
- package/lib/client.js.map +1 -1
- package/lib/index.js +0 -1
- package/package.json +1 -1
- package/src/client/EffortSlider.tsx +0 -49
- package/src/client/EffortTint.tsx +0 -21
- package/src/client/ModelMenuBridge.tsx +18 -55
- package/src/client/ModelOptions.module.css +14 -53
- package/src/client/ModelPicker.tsx +1 -32
- 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 +2 -25
- package/src/client/favorites.ts +0 -40
- package/src/client/icons.tsx +0 -14
- package/src/client/index.ts +0 -34
- package/src/client/level-color.ts +0 -27
- package/src/client/locales.ts +3 -6
- package/src/client/model-facts.ts +1 -63
- package/src/client/picker-state.ts +0 -20
- package/src/client/rows.ts +0 -37
- package/src/client/selection.ts +0 -59
- package/src/client/slider.ts +0 -58
- package/src/index.ts +0 -1
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,79 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The reasoning-level slider that replaces the Host's effort drill.
|
|
3
|
-
*
|
|
4
|
-
* The Host's second menu cell is a button that drills into a list of levels.
|
|
5
|
-
* This slider sits inside that same cell, between the Host's label and value, so
|
|
6
|
-
* the levels are reachable without leaving the menu. The levels are discrete but
|
|
7
|
-
* the drag is not: the knob follows the pointer continuously, the level it
|
|
8
|
-
* reports is the detent nearest that position, and letting go eases the knob onto
|
|
9
|
-
* that detent and commits once. Keyboard arrows step and commit immediately.
|
|
10
|
-
*
|
|
11
|
-
* The fill takes the level's color, so the track and the two captions read as
|
|
12
|
-
* one signal: "off" is neutral, the levels above it walk a blue-to-violet ramp,
|
|
13
|
-
* and only the top level fills with the whole gradient.
|
|
14
|
-
*
|
|
15
|
-
* "Provider default" is not a detent: it is a state, drawn as an empty track
|
|
16
|
-
* with a hollow knob, so it never reads as the lowest level.
|
|
17
|
-
*/
|
|
18
1
|
import { useEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from 'react';
|
|
19
2
|
import type { EffortChoice } from './selection.ts';
|
|
20
3
|
import { LEVEL_GRADIENT, isTopLevel, levelColor } from './level-color.ts';
|
|
21
4
|
import { detentAt, fillWidth, fractionAt, knobOffset, offsetOf } from './slider.ts';
|
|
22
5
|
import css from './ModelOptions.module.css';
|
|
23
6
|
|
|
24
|
-
/** Props of the slider: the levels, the one in force, and the commit path. */
|
|
25
7
|
export interface EffortSliderProps {
|
|
26
|
-
/** The levels in catalog order, lowest first. */
|
|
27
8
|
readonly steps: readonly EffortChoice[];
|
|
28
|
-
/** Index of the level in force, already clamped into `steps`. */
|
|
29
9
|
readonly current: number;
|
|
30
|
-
/** Whether the provider default is in force instead of a level. */
|
|
31
10
|
readonly defaultActive: boolean;
|
|
32
|
-
/** Where the knob rests while the provider default is in force. */
|
|
33
11
|
readonly defaultIndex: number;
|
|
34
|
-
/** Localized name of the provider default, read while it is in force. */
|
|
35
12
|
readonly defaultLabel: string;
|
|
36
|
-
/** Whether a selection is in flight; input is ignored while it is. */
|
|
37
13
|
readonly busy: boolean;
|
|
38
|
-
/** Accessible name, taken from the Host's own row label. */
|
|
39
14
|
readonly label: string;
|
|
40
|
-
/** @param index - the level the user settled on. */
|
|
41
15
|
readonly onCommit: (index: number) => void;
|
|
42
16
|
}
|
|
43
17
|
|
|
44
|
-
/**
|
|
45
|
-
* Render the slider.
|
|
46
|
-
* @param props - levels, the level in force, and the commit path.
|
|
47
|
-
* @returns one focusable slider over the discrete levels.
|
|
48
|
-
*/
|
|
49
18
|
export function EffortSlider({
|
|
50
19
|
steps, current, defaultActive, defaultIndex, defaultLabel, busy, label, onCommit,
|
|
51
20
|
}: EffortSliderProps) {
|
|
52
21
|
const trackRef = useRef<HTMLDivElement | null>(null);
|
|
53
|
-
// The drag position lives in a ref as well as in state: a press and a release
|
|
54
|
-
// can arrive in one task, and the release must not read a render that never ran.
|
|
55
22
|
const dragRef = useRef<number | null>(null);
|
|
56
23
|
const pointerRef = useRef<number | null>(null);
|
|
57
|
-
// While dragging this is where the pointer is along the travel, not a level:
|
|
58
|
-
// the knob has to move with the pointer, or the drag reads as a series of jumps.
|
|
59
24
|
const [drag, setDrag] = useState<number | null>(null);
|
|
60
|
-
// After a release that submits, the knob waits on the detent it settled on
|
|
61
|
-
// instead of springing back to the old level while the write is in flight.
|
|
62
25
|
const [hold, setHold] = useState<number | null>(null);
|
|
63
26
|
const dragging = drag !== null;
|
|
64
27
|
const resting = defaultActive ? defaultIndex : current;
|
|
65
28
|
const active = dragging ? detentAt(drag, steps.length) : resting;
|
|
66
29
|
const knobFraction = drag ?? hold ?? offsetOf(resting, steps.length);
|
|
67
|
-
// The color and the ticks follow the knob, not the level in force: during a
|
|
68
|
-
// drag, and while a commit is in flight, the knob has already gone ahead.
|
|
69
30
|
const shown = dragging || hold !== null ? detentAt(knobFraction, steps.length) : resting;
|
|
70
31
|
const beginDrag = (fraction: number | null): void => {
|
|
71
32
|
dragRef.current = fraction;
|
|
72
33
|
setDrag(fraction);
|
|
73
34
|
};
|
|
74
35
|
|
|
75
|
-
// The hold ends as soon as the write does, whether it landed on the new level
|
|
76
|
-
// or was rejected: the displayed level is the truth again either way.
|
|
77
36
|
useEffect(() => {
|
|
78
37
|
if (!busy) {
|
|
79
38
|
setHold(null);
|
|
@@ -96,8 +55,6 @@ export function EffortSlider({
|
|
|
96
55
|
|
|
97
56
|
const onPointerDown = (event: PointerEvent<HTMLDivElement>): void => {
|
|
98
57
|
if (busy || event.button !== 0 || pointerRef.current !== null) return;
|
|
99
|
-
// The Host's menu cell owns this subtree; without these the press would
|
|
100
|
-
// also settle the cell and pull focus out of the slider.
|
|
101
58
|
event.preventDefault();
|
|
102
59
|
event.stopPropagation();
|
|
103
60
|
setHold(null);
|
|
@@ -106,7 +63,6 @@ export function EffortSlider({
|
|
|
106
63
|
try {
|
|
107
64
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
108
65
|
} catch {
|
|
109
|
-
// A synthetic pointer has no capture to take; the drag still tracks moves.
|
|
110
66
|
}
|
|
111
67
|
event.currentTarget.focus();
|
|
112
68
|
};
|
|
@@ -122,8 +78,6 @@ export function EffortSlider({
|
|
|
122
78
|
beginDrag(null);
|
|
123
79
|
if (!commit || busy) return;
|
|
124
80
|
const next = detentAt(fractionAtPointer(event.clientX), steps.length);
|
|
125
|
-
// Leaving the provider default is a change even when the knob lands where
|
|
126
|
-
// the default already pointed.
|
|
127
81
|
if (next !== current || defaultActive) {
|
|
128
82
|
setHold(offsetOf(next, steps.length));
|
|
129
83
|
onCommit(next);
|
|
@@ -143,15 +97,12 @@ export function EffortSlider({
|
|
|
143
97
|
? last
|
|
144
98
|
: null;
|
|
145
99
|
if (next === null) return;
|
|
146
|
-
// The menu walks rows with the arrow keys; a slider keeps them for itself.
|
|
147
100
|
event.preventDefault();
|
|
148
101
|
event.stopPropagation();
|
|
149
102
|
if (!busy && (next !== current || defaultActive)) onCommit(next);
|
|
150
103
|
};
|
|
151
104
|
|
|
152
105
|
const offset = knobOffset(knobFraction);
|
|
153
|
-
// The provider default fills nothing: the knob shows where it lands, the
|
|
154
|
-
// track stays empty so it never reads as a chosen level.
|
|
155
106
|
const idle = defaultActive && !dragging && hold === null;
|
|
156
107
|
const filled = idle ? 0 : knobFraction;
|
|
157
108
|
const fill = isTopLevel(shown, steps.length) ? LEVEL_GRADIENT : levelColor(shown, steps.length);
|
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tint the composer's effort caption with the level's color.
|
|
3
|
-
*
|
|
4
|
-
* The slider's fill and the menu's value already carry the level's color; the
|
|
5
|
-
* caption on the collapsed trigger is the third place the level shows, and it
|
|
6
|
-
* lives outside the menu. This entry stays mounted for the whole session and
|
|
7
|
-
* writes that one color, so all three read as one signal.
|
|
8
|
-
*
|
|
9
|
-
* The caption is recognized as the trigger's `span[class*='triggerEffort']`
|
|
10
|
-
* child — the same class-substring contract the menu row uses. When the model
|
|
11
|
-
* declares no levels the span does not exist and nothing is written.
|
|
12
|
-
*/
|
|
13
1
|
import { useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
14
2
|
import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
|
|
15
3
|
import { levelColor } from './level-color.ts';
|
|
16
4
|
import { effortChoices, liveReasoning } from './selection.ts';
|
|
17
5
|
|
|
18
|
-
/** Props of the tint: the shared catalog face. */
|
|
19
6
|
export type EffortTintProps = Pick<ModelSelectInjected, 'available' | 'directory'>;
|
|
20
7
|
|
|
21
|
-
/**
|
|
22
|
-
* Render nothing and keep the trigger caption colored.
|
|
23
|
-
* @param props - the session's catalog face.
|
|
24
|
-
* @returns an inert marker.
|
|
25
|
-
*/
|
|
26
8
|
export function EffortTint({ available, directory }: EffortTintProps) {
|
|
27
9
|
const markerRef = useRef<HTMLSpanElement | null>(null);
|
|
28
10
|
const [caption, setCaption] = useState<HTMLElement | null>(null);
|
|
@@ -33,13 +15,10 @@ export function EffortTint({ available, directory }: EffortTintProps) {
|
|
|
33
15
|
const levels = effortChoices(liveReasoning(state));
|
|
34
16
|
const effort = state.current?.reasoningEffort;
|
|
35
17
|
const chosen = effort === undefined ? -1 : levels.findIndex((level) => level.effort === effort);
|
|
36
|
-
// The provider default has no color of its own: the caption keeps the Host's.
|
|
37
18
|
const color = available && chosen >= 0 && levels.length >= 2
|
|
38
19
|
? levelColor(chosen, levels.length)
|
|
39
20
|
: null;
|
|
40
21
|
|
|
41
|
-
// The Host rebuilds the trigger on every model change, so the caption is
|
|
42
|
-
// re-read after each render; the identity guard keeps that from looping.
|
|
43
22
|
useLayoutEffect(() => {
|
|
44
23
|
const card = markerRef.current?.closest('[data-composer-card]');
|
|
45
24
|
const next = card?.querySelector<HTMLElement>(
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge the Host's own model menu: the model cell opens a short list, its
|
|
3
|
-
* trailing button opens the all-provider picker, and the effort cell carries
|
|
4
|
-
* the reasoning-level slider.
|
|
5
|
-
*
|
|
6
|
-
* The Host owns the root menu's model and effort cells and opens a submenu for each.
|
|
7
|
-
* While the root pane is open, this entry redirects the first cell to a detail
|
|
8
|
-
* pane and mounts the slider in the second cell.
|
|
9
|
-
*
|
|
10
|
-
* Only the model menu's own direct buttons with the expected label, value and
|
|
11
|
-
* chevron are recognized. The options slot output sits in its own wrapper,
|
|
12
|
-
* so other plugins' rows never join that list.
|
|
13
|
-
*
|
|
14
|
-
* Clicking the cell's label switches to the provider default, which is a state
|
|
15
|
-
* rather than a detent: the slider shows it as an empty track under a hollow
|
|
16
|
-
* knob, so it never reads as the weakest level.
|
|
17
|
-
*/
|
|
18
1
|
import { useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
19
2
|
import { createPortal } from 'react-dom';
|
|
20
|
-
import { IconChevronRightOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
3
|
+
import { IconChevronRightOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
21
4
|
import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
|
|
22
5
|
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
23
6
|
import { EffortSlider } from './EffortSlider.tsx';
|
|
@@ -30,29 +13,20 @@ const cellLabel = ':scope > span[class*="cellLabel"]';
|
|
|
30
13
|
const cellValue = ':scope > span[class*="cellValue"]';
|
|
31
14
|
const cellChevron = ':scope > svg[class*="cellChevron"]';
|
|
32
15
|
|
|
33
|
-
/** Match only the host-owned buttons in the root model menu. */
|
|
34
16
|
function hostCell(surface: HTMLElement, index: number): HTMLButtonElement | null {
|
|
35
17
|
const button = surface.querySelectorAll<HTMLButtonElement>(':scope > button[role="menuitem"]')[index];
|
|
36
18
|
if (!button?.querySelector(cellLabel) || !button.querySelector(cellValue) || !button.querySelector(cellChevron)) return null;
|
|
37
19
|
return button;
|
|
38
20
|
}
|
|
39
21
|
|
|
40
|
-
/** Props of the bridge: menu state, the owning session, and the seat's injected face. */
|
|
41
22
|
export type ModelMenuBridgeProps = PropsRuntime<'conversation.input.model.options'>
|
|
42
23
|
& PropsLocale<'modelSubmenu'>
|
|
43
24
|
& Pick<ModelSelectInjected, 'available' | 'directory' | 'select'>
|
|
44
25
|
& {
|
|
45
|
-
/** Session whose catalog and picker this menu drives. */
|
|
46
26
|
readonly sessionId: string;
|
|
47
|
-
/** Carries the open request to the overlay view. */
|
|
48
27
|
readonly picker: PickerStore;
|
|
49
28
|
}
|
|
50
29
|
|
|
51
|
-
/**
|
|
52
|
-
* Render the marker, redirect the model cell, and mount the effort slider.
|
|
53
|
-
* @param props - menu state, session, catalog face, and localized copy.
|
|
54
|
-
* @returns an inert marker plus the slider while the effort cell is present.
|
|
55
|
-
*/
|
|
56
30
|
export function ModelMenuBridge({
|
|
57
31
|
sessionId, picker, locked, dismiss, openPane, reportFailure, available, directory, select, t,
|
|
58
32
|
}: ModelMenuBridgeProps) {
|
|
@@ -75,19 +49,14 @@ export function ModelMenuBridge({
|
|
|
75
49
|
const chosen = current?.reasoningEffort === undefined
|
|
76
50
|
? -1
|
|
77
51
|
: levels.findIndex((level) => level.effort === current.reasoningEffort);
|
|
78
|
-
// The provider default is a state, not a detent: it is in force whenever the
|
|
79
|
-
// session carries no explicit level.
|
|
80
52
|
const defaultActive = current !== null && current.reasoningEffort === undefined;
|
|
81
53
|
const currentIndex = chosen >= 0 ? chosen : declared >= 0 ? declared : 0;
|
|
82
54
|
const defaultIndex = declared >= 0 ? declared : 0;
|
|
83
55
|
const busy = locked || state.pending !== null;
|
|
84
56
|
const canDefault = !busy && !defaultActive;
|
|
85
57
|
const showQuickModels = available && modelRow !== null && browseMount !== null;
|
|
86
|
-
// One detent is not a choice: leave the Host's row exactly as it is.
|
|
87
58
|
const showSlider = available && levels.length >= 2 && effortRow !== null;
|
|
88
59
|
|
|
89
|
-
// The Host rebuilds its cells on every render, so the surface and the effort
|
|
90
|
-
// cell are re-read after each one; the identity guards keep that from looping.
|
|
91
60
|
useLayoutEffect(() => {
|
|
92
61
|
const nextSurface = markerRef.current?.closest<HTMLElement>('[data-model-menu][role="menu"]') ?? null;
|
|
93
62
|
if (nextSurface !== surface) setSurface(nextSurface);
|
|
@@ -108,7 +77,6 @@ export function ModelMenuBridge({
|
|
|
108
77
|
const mount = row.ownerDocument.createElement('span');
|
|
109
78
|
mount.style.display = 'contents';
|
|
110
79
|
row.after(mount);
|
|
111
|
-
// Set this before the Host's return-focus effect runs on a pane switch.
|
|
112
80
|
const previousPane = row.dataset.modelMenuPane;
|
|
113
81
|
const previousPopup = row.getAttribute('aria-haspopup');
|
|
114
82
|
row.dataset.modelMenuPane = QUICK_MODELS_PANE;
|
|
@@ -147,7 +115,6 @@ export function ModelMenuBridge({
|
|
|
147
115
|
submit(planEffortCommit(live, undefined));
|
|
148
116
|
};
|
|
149
117
|
|
|
150
|
-
// The listener reads current controls without reinstalling on every render.
|
|
151
118
|
const openQuickModels = () => openPane({ key: QUICK_MODELS_PANE, title: t('picker.quick') });
|
|
152
119
|
const latest = useRef({ modelRow, showQuickModels, openQuickModels, busy, showSlider, effortRow, canDefault, commitDefault });
|
|
153
120
|
useLayoutEffect(() => {
|
|
@@ -161,8 +128,6 @@ export function ModelMenuBridge({
|
|
|
161
128
|
const request = latest.current;
|
|
162
129
|
if (!(target instanceof Node) || event.defaultPrevented) return;
|
|
163
130
|
if (request.showQuickModels && request.modelRow?.contains(target)) {
|
|
164
|
-
// Capture on the surface runs before the React root's bubble listener, so
|
|
165
|
-
// stopping here keeps the cell's own drill handler from ever running.
|
|
166
131
|
event.preventDefault();
|
|
167
132
|
event.stopPropagation();
|
|
168
133
|
if (!request.busy) request.openQuickModels();
|
|
@@ -185,9 +150,6 @@ export function ModelMenuBridge({
|
|
|
185
150
|
};
|
|
186
151
|
}, [surface]);
|
|
187
152
|
|
|
188
|
-
// The slider takes the whole slack beside the label: the value and the
|
|
189
|
-
// chevron go, because the level is already written under the composer and the
|
|
190
|
-
// row no longer drills anywhere. Every write is recorded and put back.
|
|
191
153
|
useLayoutEffect(() => {
|
|
192
154
|
if (effortRow === null || !showSlider) return;
|
|
193
155
|
const label = effortRow.querySelector<HTMLElement>(cellLabel);
|
|
@@ -219,22 +181,23 @@ export function ModelMenuBridge({
|
|
|
219
181
|
return <>
|
|
220
182
|
<span ref={markerRef} hidden />
|
|
221
183
|
{showQuickModels && createPortal(
|
|
222
|
-
<
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
184
|
+
<Tooltip label={t('picker.browseAll')} delayMs={300} disabled={busy} portal>
|
|
185
|
+
<button
|
|
186
|
+
className={css.modelBrowse}
|
|
187
|
+
type="button"
|
|
188
|
+
role="menuitem"
|
|
189
|
+
aria-haspopup="dialog"
|
|
190
|
+
aria-label={t('picker.browseAll')}
|
|
191
|
+
disabled={busy}
|
|
192
|
+
onClick={() => {
|
|
193
|
+
if (directory.getSnapshot().pending !== null) return;
|
|
194
|
+
dismiss();
|
|
195
|
+
picker.open(sessionId);
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
<IconChevronRightOutlineRegular size={12} />
|
|
199
|
+
</button>
|
|
200
|
+
</Tooltip>,
|
|
238
201
|
browseMount,
|
|
239
202
|
)}
|
|
240
203
|
{showSlider && effortRow !== null && createPortal(
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* The reasoning-level slider, the picker, and the composer overlay that hosts
|
|
3
|
-
* the picker. The dialog renders through the primitives' Modal, so this file
|
|
4
|
-
* paints no floating fill — it only places content on the surface that
|
|
5
|
-
* component owns.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/* The overlay entry is only a mount point for the dialog and its toast; it must
|
|
9
|
-
* not take space inside the composer card. */
|
|
1
|
+
|
|
10
2
|
.pickerHost {
|
|
11
3
|
display: contents;
|
|
12
4
|
}
|
|
13
5
|
|
|
14
|
-
/* Align the separate dialog button over the root model row's trailing edge. */
|
|
15
6
|
.modelCell.modelCell {
|
|
16
7
|
anchor-name: --dsh-quick-model-row;
|
|
17
8
|
padding-inline-end: 14px;
|
|
@@ -63,11 +54,12 @@
|
|
|
63
54
|
cursor: pointer;
|
|
64
55
|
}
|
|
65
56
|
|
|
66
|
-
.quickOption:hover:not([aria-disabled='true']),
|
|
57
|
+
.quickOption:hover:not(:disabled, [aria-disabled='true']),
|
|
67
58
|
.quickOption:focus-visible {
|
|
68
59
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
69
60
|
}
|
|
70
61
|
|
|
62
|
+
.quickOption:disabled,
|
|
71
63
|
.quickOption[aria-disabled='true'] {
|
|
72
64
|
color: var(--dsw-alias-label-dimmed);
|
|
73
65
|
cursor: default;
|
|
@@ -97,11 +89,12 @@
|
|
|
97
89
|
flex: 0 0 14px;
|
|
98
90
|
}
|
|
99
91
|
|
|
100
|
-
|
|
92
|
+
.quickFooter {
|
|
93
|
+
margin-block-start: 4px;
|
|
94
|
+
padding-block-start: 4px;
|
|
95
|
+
border-block-start: .5px solid var(--dsw-alias-border-l2);
|
|
96
|
+
}
|
|
101
97
|
|
|
102
|
-
/* The Host's effort cell is a flex row: label, value, chevron. The slider takes
|
|
103
|
-
* the slack between the label and the value, so the cell keeps the Host's own
|
|
104
|
-
* metrics and the menu does not grow. */
|
|
105
98
|
.sliderCell {
|
|
106
99
|
display: flex;
|
|
107
100
|
flex: 1 1 auto;
|
|
@@ -127,9 +120,6 @@
|
|
|
127
120
|
cursor: default;
|
|
128
121
|
}
|
|
129
122
|
|
|
130
|
-
/* The track is a capsule and the knob a larger circle riding on it: the knob
|
|
131
|
-
* overhangs at both ends, so it reads as a knob rather than as the track's own
|
|
132
|
-
* end cap. */
|
|
133
123
|
.sliderTrack {
|
|
134
124
|
position: relative;
|
|
135
125
|
width: 100%;
|
|
@@ -139,10 +129,6 @@
|
|
|
139
129
|
background: var(--dsw-alias-border-l3);
|
|
140
130
|
}
|
|
141
131
|
|
|
142
|
-
/* The fill is the track's own shape cut at the knob: its right cap carries the
|
|
143
|
-
* track's radius and ends under the knob, so the color runs into the knob
|
|
144
|
-
* instead of stopping at a straight edge, and the last detent reaches the
|
|
145
|
-
* track's end. */
|
|
146
132
|
.sliderFill {
|
|
147
133
|
position: absolute;
|
|
148
134
|
top: 0;
|
|
@@ -151,13 +137,9 @@
|
|
|
151
137
|
border-radius: 999px;
|
|
152
138
|
corner-shape: round;
|
|
153
139
|
pointer-events: none;
|
|
154
|
-
/* A level change eases the color to its new width; the drag turns this off so
|
|
155
|
-
* the edge stays under the pointer. */
|
|
156
140
|
transition: width 160ms cubic-bezier(0.2, 0, 0, 1);
|
|
157
141
|
}
|
|
158
142
|
|
|
159
|
-
/* One detent per level: the dot is the only thing that says the levels are
|
|
160
|
-
* discrete, so it stays visible on both sides of the knob. */
|
|
161
143
|
.sliderTick {
|
|
162
144
|
position: absolute;
|
|
163
145
|
top: 50%;
|
|
@@ -170,8 +152,6 @@
|
|
|
170
152
|
pointer-events: none;
|
|
171
153
|
}
|
|
172
154
|
|
|
173
|
-
/* On the filled part the detent goes dark: white would read as one more grain
|
|
174
|
-
* of stardust, and the dot has to stay the thing that says "levels". */
|
|
175
155
|
.sliderTick[data-on] {
|
|
176
156
|
background: rgba(0, 0, 0, 0.28);
|
|
177
157
|
}
|
|
@@ -179,8 +159,6 @@
|
|
|
179
159
|
.sliderKnob {
|
|
180
160
|
position: absolute;
|
|
181
161
|
top: 50%;
|
|
182
|
-
/* The provider default draws a 1.5px ring; border-box keeps that ring inside
|
|
183
|
-
* the 20px circle the travel is computed for. */
|
|
184
162
|
box-sizing: border-box;
|
|
185
163
|
width: 20px;
|
|
186
164
|
height: 20px;
|
|
@@ -190,8 +168,6 @@
|
|
|
190
168
|
background: var(--dsw-alias-label-primary-foreground);
|
|
191
169
|
box-shadow: var(--dsw-elevation-soft);
|
|
192
170
|
pointer-events: none;
|
|
193
|
-
/* Letting go eases the knob onto the detent it settled on; the drag turns this
|
|
194
|
-
* off so the knob sits exactly under the pointer. */
|
|
195
171
|
transition: left 160ms cubic-bezier(0.2, 0, 0, 1);
|
|
196
172
|
}
|
|
197
173
|
|
|
@@ -207,8 +183,6 @@
|
|
|
207
183
|
}
|
|
208
184
|
}
|
|
209
185
|
|
|
210
|
-
/* Provider default: nothing is filled and the knob is a hollow ring, so the
|
|
211
|
-
* state never reads as the weakest level. */
|
|
212
186
|
.slider[data-default] .sliderKnob {
|
|
213
187
|
background: var(--dsw-alias-bg-layer-1);
|
|
214
188
|
border: 1.5px solid var(--dsw-alias-label-tertiary);
|
|
@@ -224,7 +198,6 @@
|
|
|
224
198
|
outline-offset: 3px;
|
|
225
199
|
}
|
|
226
200
|
|
|
227
|
-
/* ── the picker rows ─────────────────────────────────────────────────────── */
|
|
228
201
|
|
|
229
202
|
.rowBadge {
|
|
230
203
|
flex: none;
|
|
@@ -239,13 +212,7 @@
|
|
|
239
212
|
|
|
240
213
|
.rowPick {
|
|
241
214
|
box-sizing: border-box;
|
|
242
|
-
/* A slightly tighter side padding buys the name a few more characters, which
|
|
243
|
-
* is what keeps a long provider suffix readable inside a narrow card. */
|
|
244
215
|
padding-inline: 6px;
|
|
245
|
-
/* The scroll list is a block container, so a flex item's `flex: 1` does
|
|
246
|
-
* nothing here: the row must claim the full width or a long model name pushes
|
|
247
|
-
* the favorite mark and the check past the card's edge, where overflow clips
|
|
248
|
-
* them. */
|
|
249
216
|
width: 100%;
|
|
250
217
|
flex: 1;
|
|
251
218
|
min-width: 0;
|
|
@@ -306,8 +273,6 @@
|
|
|
306
273
|
display: grid;
|
|
307
274
|
}
|
|
308
275
|
|
|
309
|
-
/* The picker's star is a real control: outline until hover or focus, solid and
|
|
310
|
-
* gold once favorited, and visible without hover on touch screens. */
|
|
311
276
|
.starButton {
|
|
312
277
|
color: var(--dsw-alias-label-tertiary);
|
|
313
278
|
cursor: pointer;
|
|
@@ -347,7 +312,6 @@
|
|
|
347
312
|
flex: none;
|
|
348
313
|
}
|
|
349
314
|
|
|
350
|
-
/* ── shared status lines ─────────────────────────────────────────────────── */
|
|
351
315
|
|
|
352
316
|
.notice {
|
|
353
317
|
color: var(--dsw-alias-label-tertiary);
|
|
@@ -372,9 +336,7 @@
|
|
|
372
336
|
text-decoration: underline;
|
|
373
337
|
}
|
|
374
338
|
|
|
375
|
-
/* ── the picker dialog ───────────────────────────────────────────────────── */
|
|
376
339
|
|
|
377
|
-
/* Keep the picker dimensions when the host Modal stylesheet loads later. */
|
|
378
340
|
.pickerDialog.pickerDialog {
|
|
379
341
|
width: min(680px, 100%);
|
|
380
342
|
height: min(640px, 80vh);
|
|
@@ -389,9 +351,6 @@
|
|
|
389
351
|
flex-direction: column;
|
|
390
352
|
}
|
|
391
353
|
|
|
392
|
-
/* Modal wraps children in a body row of its own; that row — the content
|
|
393
|
-
* region's last child — is what has to carry the column and give the list its
|
|
394
|
-
* remaining height, so the footer stays put while the list scrolls. */
|
|
395
354
|
.pickerContent > :last-child {
|
|
396
355
|
min-height: 0;
|
|
397
356
|
flex: 1;
|
|
@@ -407,9 +366,6 @@
|
|
|
407
366
|
width: 100%;
|
|
408
367
|
}
|
|
409
368
|
|
|
410
|
-
/* The tabs scroll sideways rather than wrap: the dialog keeps one row of
|
|
411
|
-
* providers however many the catalog has, so the list below starts at the same
|
|
412
|
-
* height every time. The bar keeps its hairline and hides its scrollbar. */
|
|
413
369
|
.pickerTabs {
|
|
414
370
|
border-bottom: .5px solid var(--dsw-alias-border-l2);
|
|
415
371
|
gap: 2px;
|
|
@@ -465,7 +421,8 @@
|
|
|
465
421
|
border-top: .5px solid var(--dsw-alias-border-l2);
|
|
466
422
|
color: var(--dsw-alias-label-tertiary);
|
|
467
423
|
align-items: center;
|
|
468
|
-
|
|
424
|
+
justify-content: space-between;
|
|
425
|
+
gap: 12px;
|
|
469
426
|
padding: 10px 20px;
|
|
470
427
|
font-size: 12px;
|
|
471
428
|
line-height: 18px;
|
|
@@ -478,3 +435,7 @@
|
|
|
478
435
|
display: flex;
|
|
479
436
|
flex-wrap: wrap;
|
|
480
437
|
}
|
|
438
|
+
|
|
439
|
+
.footerFavorites {
|
|
440
|
+
text-align: end;
|
|
441
|
+
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The model picker: the centered dialog opened from the menu's model row.
|
|
3
|
-
*
|
|
4
|
-
* It is the one place every provider is visible at once — a search field, a tab
|
|
5
|
-
* per provider with a model, and one flat list with each model's metadata line.
|
|
6
|
-
* Favorites lead the list and can be toggled from a row's star without
|
|
7
|
-
* selecting that row. A click commits at once; a rejected commit keeps the
|
|
8
|
-
* dialog open so the user can retry or pick another model.
|
|
9
|
-
*/
|
|
10
1
|
|
|
11
2
|
import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
12
3
|
import {
|
|
@@ -37,44 +28,21 @@ import type { Selection } from './selection.ts'
|
|
|
37
28
|
import { planModelCommit } from './selection.ts'
|
|
38
29
|
import css from './ModelOptions.module.css'
|
|
39
30
|
|
|
40
|
-
/** Props the seat hands the picker. */
|
|
41
31
|
export interface ModelPickerProps {
|
|
42
|
-
/** Whether the dialog is showing. */
|
|
43
32
|
readonly open: boolean
|
|
44
|
-
/** Resolve a catalog badge's localized text for the active language. */
|
|
45
33
|
readonly resolveText: (text: NonNullable<CatalogModel['badge']>['text']) => string
|
|
46
|
-
/** The shared directory snapshot. */
|
|
47
34
|
readonly state: ModelDirectoryState
|
|
48
|
-
/** The selection in force, null before a first selection resolves. */
|
|
49
35
|
readonly live: Selection | null
|
|
50
|
-
/** The metadata lookup for the current settings answer. */
|
|
51
36
|
readonly facts: ModelFactsLookup
|
|
52
|
-
/** The favorite table right now. */
|
|
53
37
|
readonly favorites: readonly { readonly provider: string; readonly model: string }[]
|
|
54
|
-
/** Whether a selection is in flight. */
|
|
55
38
|
readonly busy: boolean
|
|
56
|
-
/**
|
|
57
|
-
* The reasoning level this browser last used for one model, if any.
|
|
58
|
-
* @param provider - the provider route key.
|
|
59
|
-
* @param model - the model id inside that provider.
|
|
60
|
-
* @returns the remembered level, or undefined when none is remembered.
|
|
61
|
-
*/
|
|
62
39
|
readonly rememberedOf?: (provider: string, model: string) => string | undefined
|
|
63
|
-
/** Submit one selection. */
|
|
64
40
|
readonly onPick: (selection: Selection) => void
|
|
65
|
-
/** Toggle one model's favorite. */
|
|
66
41
|
readonly onToggleFavorite: (provider: string, model: string) => void
|
|
67
|
-
/** Reload the catalog after a failure. */
|
|
68
42
|
readonly onReload: () => void
|
|
69
|
-
/** Close the dialog, optionally returning focus. */
|
|
70
43
|
readonly onClose: () => void
|
|
71
44
|
}
|
|
72
45
|
|
|
73
|
-
/**
|
|
74
|
-
* Render the picker.
|
|
75
|
-
* @param props - the catalog, the live selection, and the picker's verbs.
|
|
76
|
-
* @returns the dialog; nothing while closed.
|
|
77
|
-
*/
|
|
78
46
|
export function ModelPicker({
|
|
79
47
|
open, resolveText, state, live, facts, favorites, busy, rememberedOf, onPick, onToggleFavorite, onReload, onClose, t,
|
|
80
48
|
}: ModelPickerProps & PropsLocale<'modelSubmenu'>) {
|
|
@@ -204,6 +172,7 @@ export function ModelPicker({
|
|
|
204
172
|
<ShortcutKeys keys={['Esc']} />
|
|
205
173
|
<span>{t('picker.hintClose')}</span>
|
|
206
174
|
</span>
|
|
175
|
+
<span className={css.footerFavorites}>{t('picker.hintFavorites')}</span>
|
|
207
176
|
</div>
|
|
208
177
|
</Modal>
|
|
209
178
|
)
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The composer overlay's picker view: the dialog, its catalog, and its verbs.
|
|
3
|
-
*
|
|
4
|
-
* It lives in `conversation.input.overlay` so it can open after the Host's menu
|
|
5
|
-
* closes or from the toolbar when the current model is missing. Its data comes
|
|
6
|
-
* from the slot entry's injected face.
|
|
7
|
-
*/
|
|
8
1
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
9
2
|
import { Button, IconWarningOutlineRegular, Toast } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
10
3
|
import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
|
|
@@ -27,23 +20,14 @@ import { currentCatalogModel, selectionOf, type Selection } from './selection.ts
|
|
|
27
20
|
import type { PickerStore } from './picker-state.ts';
|
|
28
21
|
import css from './ModelOptions.module.css';
|
|
29
22
|
|
|
30
|
-
/** Props of the overlay view: the session, the store, and the seat's injected face. */
|
|
31
23
|
export type ModelPickerHostProps = PropsLocale<'modelSubmenu'>
|
|
32
24
|
& ModelSelectInjected
|
|
33
25
|
& {
|
|
34
|
-
/** Session whose catalog this view renders. */
|
|
35
26
|
readonly sessionId: string;
|
|
36
|
-
/** The request written by the menu row. */
|
|
37
27
|
readonly picker: PickerStore;
|
|
38
|
-
/** The settings-derived metadata the picker's line reads. */
|
|
39
28
|
readonly factsSource: FactsSource;
|
|
40
29
|
}
|
|
41
30
|
|
|
42
|
-
/**
|
|
43
|
-
* Render the picker for this session.
|
|
44
|
-
* @param props - session, store, catalog face, and localized copy.
|
|
45
|
-
* @returns the dialog while the store names this session; otherwise nothing.
|
|
46
|
-
*/
|
|
47
31
|
export function ModelPickerHost({
|
|
48
32
|
sessionId, picker, available, directory, load, select, resolveText, factsSource, t,
|
|
49
33
|
}: ModelPickerHostProps) {
|
|
@@ -68,22 +52,13 @@ export function ModelPickerHost({
|
|
|
68
52
|
}
|
|
69
53
|
};
|
|
70
54
|
}, [open, picker, request]);
|
|
71
|
-
// The injected face is cached per entry and session, but the read goes through
|
|
72
|
-
// a ref anyway: a catalog load writes the store, so an unstable `load` in the
|
|
73
|
-
// dependency list would reload on every render it caused.
|
|
74
55
|
const loadRef = useRef(load);
|
|
75
56
|
loadRef.current = load;
|
|
76
57
|
|
|
77
|
-
// Opening reads the catalog again: another client may have changed it, and a
|
|
78
|
-
// failed load has to be retryable from the same gesture.
|
|
79
58
|
useEffect(() => {
|
|
80
59
|
if (open) loadRef.current();
|
|
81
60
|
}, [open]);
|
|
82
61
|
|
|
83
|
-
// The Host's own menu changes the reasoning level without passing through this
|
|
84
|
-
// plugin, so the memory is written from the directory snapshot too — a picker
|
|
85
|
-
// click alone would only ever record levels chosen in the dialog. The key guard
|
|
86
|
-
// keeps one write per distinct selection instead of one per snapshot.
|
|
87
62
|
const current = state.current;
|
|
88
63
|
const rememberedRef = useRef<string | null>(null);
|
|
89
64
|
useEffect(() => {
|
|
@@ -147,7 +122,6 @@ export function ModelPickerHost({
|
|
|
147
122
|
</div>;
|
|
148
123
|
}
|
|
149
124
|
|
|
150
|
-
/** The Host skips the root menu when the current model is absent from its catalog. */
|
|
151
125
|
export function ModelPickerFallback({ sessionId, picker, available, directory, t }: Pick<
|
|
152
126
|
ModelPickerHostProps, 'sessionId' | 'picker' | 'available' | 'directory' | 't'
|
|
153
127
|
>) {
|