@lynn123411/dsh-model-submenu 0.3.17 → 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 +10 -9
- package/cordis.patch.yml +0 -1
- package/lib/client.js +310 -477
- package/lib/client.js.map +1 -1
- package/lib/index.js +0 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
- package/src/client/EffortSlider.tsx +0 -49
- package/src/client/EffortTint.tsx +0 -21
- package/src/client/ModelMenuBridge.tsx +60 -46
- package/src/client/ModelOptions.module.css +98 -51
- package/src/client/ModelPicker.tsx +1 -32
- package/src/client/ModelPickerHost.tsx +1 -36
- package/src/client/ModelRow.tsx +0 -23
- package/src/client/QuickModels.tsx +114 -0
- package/src/client/effort-memory.ts +0 -32
- package/src/client/facts-source.ts +2 -25
- package/src/client/favorites.ts +8 -39
- package/src/client/icons.tsx +0 -14
- package/src/client/index.ts +8 -34
- package/src/client/level-color.ts +0 -27
- package/src/client/locales.ts +9 -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/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Model picker",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Open the quick list from the model row, or use its right arrow to browse all models. Adjust reasoning effort with a colored slider.",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynn123411/dsh-model-submenu",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.19",
|
|
4
|
+
"description": "点击模型行切换当前或收藏的模型,点击右侧箭头浏览全部模型。推理等级可用带配色的滑块调整。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"packageManager": "pnpm@11.7.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -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,24 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge the Host's own model menu: the model cell opens the all-provider
|
|
3
|
-
* picker, and the effort cell carries the reasoning-level slider.
|
|
4
|
-
*
|
|
5
|
-
* The Host owns the root menu's model and effort cells and opens a submenu for each.
|
|
6
|
-
* While the root pane is open, this entry redirects the first cell to the model
|
|
7
|
-
* dialog and mounts the slider in the second cell.
|
|
8
|
-
*
|
|
9
|
-
* Only the model menu's own direct buttons with the expected label, value and
|
|
10
|
-
* chevron are recognized. The options slot output sits in its own wrapper,
|
|
11
|
-
* so other plugins' rows never join that list.
|
|
12
|
-
*
|
|
13
|
-
* Clicking the cell's label switches to the provider default, which is a state
|
|
14
|
-
* rather than a detent: the slider shows it as an empty track under a hollow
|
|
15
|
-
* knob, so it never reads as the weakest level.
|
|
16
|
-
*/
|
|
17
1
|
import { useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
18
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
import { IconChevronRightOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
19
4
|
import type { ModelSelectInjected } from '@deepseek-ai/dsh-client-ui-model-selection/client';
|
|
20
5
|
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
21
6
|
import { EffortSlider } from './EffortSlider.tsx';
|
|
7
|
+
import { QUICK_MODELS_PANE } from './QuickModels.tsx';
|
|
22
8
|
import type { PickerStore } from './picker-state.ts';
|
|
23
9
|
import { effortChoices, liveReasoning, planEffortCommit, selectionOf, type Selection } from './selection.ts';
|
|
24
10
|
import css from './ModelOptions.module.css';
|
|
@@ -27,35 +13,28 @@ const cellLabel = ':scope > span[class*="cellLabel"]';
|
|
|
27
13
|
const cellValue = ':scope > span[class*="cellValue"]';
|
|
28
14
|
const cellChevron = ':scope > svg[class*="cellChevron"]';
|
|
29
15
|
|
|
30
|
-
/** Match only the host-owned buttons in the root model menu. */
|
|
31
16
|
function hostCell(surface: HTMLElement, index: number): HTMLButtonElement | null {
|
|
32
17
|
const button = surface.querySelectorAll<HTMLButtonElement>(':scope > button[role="menuitem"]')[index];
|
|
33
18
|
if (!button?.querySelector(cellLabel) || !button.querySelector(cellValue) || !button.querySelector(cellChevron)) return null;
|
|
34
19
|
return button;
|
|
35
20
|
}
|
|
36
21
|
|
|
37
|
-
/** Props of the bridge: menu state, the owning session, and the seat's injected face. */
|
|
38
22
|
export type ModelMenuBridgeProps = PropsRuntime<'conversation.input.model.options'>
|
|
39
23
|
& PropsLocale<'modelSubmenu'>
|
|
40
24
|
& Pick<ModelSelectInjected, 'available' | 'directory' | 'select'>
|
|
41
25
|
& {
|
|
42
|
-
/** Session whose catalog and picker this menu drives. */
|
|
43
26
|
readonly sessionId: string;
|
|
44
|
-
/** Carries the open request to the overlay view. */
|
|
45
27
|
readonly picker: PickerStore;
|
|
46
28
|
}
|
|
47
29
|
|
|
48
|
-
/**
|
|
49
|
-
* Render the marker, redirect the model cell, and mount the effort slider.
|
|
50
|
-
* @param props - menu state, session, catalog face, and localized copy.
|
|
51
|
-
* @returns an inert marker plus the slider while the effort cell is present.
|
|
52
|
-
*/
|
|
53
30
|
export function ModelMenuBridge({
|
|
54
|
-
sessionId, picker, locked, dismiss, reportFailure, available, directory, select, t,
|
|
31
|
+
sessionId, picker, locked, dismiss, openPane, reportFailure, available, directory, select, t,
|
|
55
32
|
}: ModelMenuBridgeProps) {
|
|
56
33
|
const markerRef = useRef<HTMLSpanElement | null>(null);
|
|
57
34
|
const sliderRef = useRef<HTMLDivElement | null>(null);
|
|
58
35
|
const [surface, setSurface] = useState<HTMLElement | null>(null);
|
|
36
|
+
const [modelRow, setModelRow] = useState<HTMLButtonElement | null>(null);
|
|
37
|
+
const [browseMount, setBrowseMount] = useState<HTMLElement | null>(null);
|
|
59
38
|
const [effortRow, setEffortRow] = useState<HTMLElement | null>(null);
|
|
60
39
|
const [rowLabel, setRowLabel] = useState<string | null>(null);
|
|
61
40
|
|
|
@@ -70,18 +49,14 @@ export function ModelMenuBridge({
|
|
|
70
49
|
const chosen = current?.reasoningEffort === undefined
|
|
71
50
|
? -1
|
|
72
51
|
: levels.findIndex((level) => level.effort === current.reasoningEffort);
|
|
73
|
-
// The provider default is a state, not a detent: it is in force whenever the
|
|
74
|
-
// session carries no explicit level.
|
|
75
52
|
const defaultActive = current !== null && current.reasoningEffort === undefined;
|
|
76
53
|
const currentIndex = chosen >= 0 ? chosen : declared >= 0 ? declared : 0;
|
|
77
54
|
const defaultIndex = declared >= 0 ? declared : 0;
|
|
78
55
|
const busy = locked || state.pending !== null;
|
|
79
56
|
const canDefault = !busy && !defaultActive;
|
|
80
|
-
|
|
57
|
+
const showQuickModels = available && modelRow !== null && browseMount !== null;
|
|
81
58
|
const showSlider = available && levels.length >= 2 && effortRow !== null;
|
|
82
59
|
|
|
83
|
-
// The Host rebuilds its cells on every render, so the surface and the effort
|
|
84
|
-
// cell are re-read after each one; the identity guards keep that from looping.
|
|
85
60
|
useLayoutEffect(() => {
|
|
86
61
|
const nextSurface = markerRef.current?.closest<HTMLElement>('[data-model-menu][role="menu"]') ?? null;
|
|
87
62
|
if (nextSurface !== surface) setSurface(nextSurface);
|
|
@@ -91,6 +66,34 @@ export function ModelMenuBridge({
|
|
|
91
66
|
if (nextLabel !== (rowLabel ?? '')) setRowLabel(nextLabel);
|
|
92
67
|
});
|
|
93
68
|
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
const menu = markerRef.current?.closest<HTMLElement>('[data-model-menu][role="menu"]');
|
|
71
|
+
const row = available && menu ? hostCell(menu, 0) : null;
|
|
72
|
+
if (row === null) {
|
|
73
|
+
setModelRow(null);
|
|
74
|
+
setBrowseMount(null);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const mount = row.ownerDocument.createElement('span');
|
|
78
|
+
mount.style.display = 'contents';
|
|
79
|
+
row.after(mount);
|
|
80
|
+
const previousPane = row.dataset.modelMenuPane;
|
|
81
|
+
const previousPopup = row.getAttribute('aria-haspopup');
|
|
82
|
+
row.dataset.modelMenuPane = QUICK_MODELS_PANE;
|
|
83
|
+
row.setAttribute('aria-haspopup', 'menu');
|
|
84
|
+
row.classList.add(css.modelCell!);
|
|
85
|
+
setModelRow(row);
|
|
86
|
+
setBrowseMount(mount);
|
|
87
|
+
return () => {
|
|
88
|
+
mount.remove();
|
|
89
|
+
row.classList.remove(css.modelCell!);
|
|
90
|
+
if (previousPane === undefined) delete row.dataset.modelMenuPane;
|
|
91
|
+
else row.dataset.modelMenuPane = previousPane;
|
|
92
|
+
if (previousPopup === null) row.removeAttribute('aria-haspopup');
|
|
93
|
+
else row.setAttribute('aria-haspopup', previousPopup);
|
|
94
|
+
};
|
|
95
|
+
}, [available]);
|
|
96
|
+
|
|
94
97
|
const submit = (selection: Selection | null): void => {
|
|
95
98
|
if (selection === null || busy || directory.getSnapshot().pending !== null) return;
|
|
96
99
|
void select(selection).then((result) => {
|
|
@@ -112,11 +115,10 @@ export function ModelMenuBridge({
|
|
|
112
115
|
submit(planEffortCommit(live, undefined));
|
|
113
116
|
};
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const latest = useRef({ sessionId, picker, dismiss, available, busy, showSlider, effortRow, canDefault, commitDefault });
|
|
118
|
+
const openQuickModels = () => openPane({ key: QUICK_MODELS_PANE, title: t('picker.quick') });
|
|
119
|
+
const latest = useRef({ modelRow, showQuickModels, openQuickModels, busy, showSlider, effortRow, canDefault, commitDefault });
|
|
118
120
|
useLayoutEffect(() => {
|
|
119
|
-
latest.current = {
|
|
121
|
+
latest.current = { modelRow, showQuickModels, openQuickModels, busy, showSlider, effortRow, canDefault, commitDefault };
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
useLayoutEffect(() => {
|
|
@@ -124,16 +126,11 @@ export function ModelMenuBridge({
|
|
|
124
126
|
const redirect = (event: MouseEvent): void => {
|
|
125
127
|
const target = event.target;
|
|
126
128
|
const request = latest.current;
|
|
127
|
-
if (!(target instanceof Node) || event.defaultPrevented
|
|
128
|
-
|
|
129
|
-
if (modelCell?.contains(target)) {
|
|
130
|
-
// Capture on the surface runs before the React root's bubble listener, so
|
|
131
|
-
// stopping here keeps the cell's own drill handler from ever running.
|
|
129
|
+
if (!(target instanceof Node) || event.defaultPrevented) return;
|
|
130
|
+
if (request.showQuickModels && request.modelRow?.contains(target)) {
|
|
132
131
|
event.preventDefault();
|
|
133
132
|
event.stopPropagation();
|
|
134
|
-
if (request.busy)
|
|
135
|
-
request.dismiss();
|
|
136
|
-
request.picker.open(request.sessionId);
|
|
133
|
+
if (!request.busy) request.openQuickModels();
|
|
137
134
|
return;
|
|
138
135
|
}
|
|
139
136
|
const row = request.effortRow;
|
|
@@ -153,9 +150,6 @@ export function ModelMenuBridge({
|
|
|
153
150
|
};
|
|
154
151
|
}, [surface]);
|
|
155
152
|
|
|
156
|
-
// The slider takes the whole slack beside the label: the value and the
|
|
157
|
-
// chevron go, because the level is already written under the composer and the
|
|
158
|
-
// row no longer drills anywhere. Every write is recorded and put back.
|
|
159
153
|
useLayoutEffect(() => {
|
|
160
154
|
if (effortRow === null || !showSlider) return;
|
|
161
155
|
const label = effortRow.querySelector<HTMLElement>(cellLabel);
|
|
@@ -186,6 +180,26 @@ export function ModelMenuBridge({
|
|
|
186
180
|
|
|
187
181
|
return <>
|
|
188
182
|
<span ref={markerRef} hidden />
|
|
183
|
+
{showQuickModels && createPortal(
|
|
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>,
|
|
201
|
+
browseMount,
|
|
202
|
+
)}
|
|
189
203
|
{showSlider && effortRow !== null && createPortal(
|
|
190
204
|
<div ref={sliderRef} className={css.sliderCell}>
|
|
191
205
|
<EffortSlider
|
|
@@ -1,21 +1,100 @@
|
|
|
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
|
-
|
|
6
|
+
.modelCell.modelCell {
|
|
7
|
+
anchor-name: --dsh-quick-model-row;
|
|
8
|
+
padding-inline-end: 14px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.modelCell > svg:last-child {
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.modelBrowse {
|
|
16
|
+
position: absolute;
|
|
17
|
+
position-anchor: --dsh-quick-model-row;
|
|
18
|
+
top: anchor(top);
|
|
19
|
+
bottom: anchor(bottom);
|
|
20
|
+
inset-inline-end: anchor(end);
|
|
21
|
+
width: 32px;
|
|
22
|
+
display: grid;
|
|
23
|
+
place-items: center;
|
|
24
|
+
padding: 0;
|
|
25
|
+
border: 0;
|
|
26
|
+
border-radius: var(--dsw-radius-md);
|
|
27
|
+
background: transparent;
|
|
28
|
+
color: var(--dsw-alias-label-tertiary);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.modelBrowse:hover:not(:disabled),
|
|
33
|
+
.modelBrowse:focus-visible {
|
|
34
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
35
|
+
color: var(--dsw-alias-label-primary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.quickOption {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 6px;
|
|
42
|
+
width: 100%;
|
|
43
|
+
min-height: 34px;
|
|
44
|
+
padding: 5px 7px;
|
|
45
|
+
border: 0;
|
|
46
|
+
border-radius: var(--dsw-radius-md);
|
|
47
|
+
outline: none;
|
|
48
|
+
background: transparent;
|
|
49
|
+
color: inherit;
|
|
50
|
+
text-align: start;
|
|
51
|
+
font-size: 13px;
|
|
52
|
+
font-weight: 400;
|
|
53
|
+
line-height: 18px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.quickOption:hover:not(:disabled, [aria-disabled='true']),
|
|
58
|
+
.quickOption:focus-visible {
|
|
59
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.quickOption:disabled,
|
|
63
|
+
.quickOption[aria-disabled='true'] {
|
|
64
|
+
color: var(--dsw-alias-label-dimmed);
|
|
65
|
+
cursor: default;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.quickCopy {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
flex: 1;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.quickName {
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
white-space: nowrap;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.quickBadge {
|
|
83
|
+
flex: none;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.quickCheck {
|
|
87
|
+
display: grid;
|
|
88
|
+
place-items: center;
|
|
89
|
+
flex: 0 0 14px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.quickFooter {
|
|
93
|
+
margin-block-start: 4px;
|
|
94
|
+
padding-block-start: 4px;
|
|
95
|
+
border-block-start: .5px solid var(--dsw-alias-border-l2);
|
|
96
|
+
}
|
|
15
97
|
|
|
16
|
-
/* The Host's effort cell is a flex row: label, value, chevron. The slider takes
|
|
17
|
-
* the slack between the label and the value, so the cell keeps the Host's own
|
|
18
|
-
* metrics and the menu does not grow. */
|
|
19
98
|
.sliderCell {
|
|
20
99
|
display: flex;
|
|
21
100
|
flex: 1 1 auto;
|
|
@@ -41,9 +120,6 @@
|
|
|
41
120
|
cursor: default;
|
|
42
121
|
}
|
|
43
122
|
|
|
44
|
-
/* The track is a capsule and the knob a larger circle riding on it: the knob
|
|
45
|
-
* overhangs at both ends, so it reads as a knob rather than as the track's own
|
|
46
|
-
* end cap. */
|
|
47
123
|
.sliderTrack {
|
|
48
124
|
position: relative;
|
|
49
125
|
width: 100%;
|
|
@@ -53,10 +129,6 @@
|
|
|
53
129
|
background: var(--dsw-alias-border-l3);
|
|
54
130
|
}
|
|
55
131
|
|
|
56
|
-
/* The fill is the track's own shape cut at the knob: its right cap carries the
|
|
57
|
-
* track's radius and ends under the knob, so the color runs into the knob
|
|
58
|
-
* instead of stopping at a straight edge, and the last detent reaches the
|
|
59
|
-
* track's end. */
|
|
60
132
|
.sliderFill {
|
|
61
133
|
position: absolute;
|
|
62
134
|
top: 0;
|
|
@@ -65,13 +137,9 @@
|
|
|
65
137
|
border-radius: 999px;
|
|
66
138
|
corner-shape: round;
|
|
67
139
|
pointer-events: none;
|
|
68
|
-
/* A level change eases the color to its new width; the drag turns this off so
|
|
69
|
-
* the edge stays under the pointer. */
|
|
70
140
|
transition: width 160ms cubic-bezier(0.2, 0, 0, 1);
|
|
71
141
|
}
|
|
72
142
|
|
|
73
|
-
/* One detent per level: the dot is the only thing that says the levels are
|
|
74
|
-
* discrete, so it stays visible on both sides of the knob. */
|
|
75
143
|
.sliderTick {
|
|
76
144
|
position: absolute;
|
|
77
145
|
top: 50%;
|
|
@@ -84,8 +152,6 @@
|
|
|
84
152
|
pointer-events: none;
|
|
85
153
|
}
|
|
86
154
|
|
|
87
|
-
/* On the filled part the detent goes dark: white would read as one more grain
|
|
88
|
-
* of stardust, and the dot has to stay the thing that says "levels". */
|
|
89
155
|
.sliderTick[data-on] {
|
|
90
156
|
background: rgba(0, 0, 0, 0.28);
|
|
91
157
|
}
|
|
@@ -93,8 +159,6 @@
|
|
|
93
159
|
.sliderKnob {
|
|
94
160
|
position: absolute;
|
|
95
161
|
top: 50%;
|
|
96
|
-
/* The provider default draws a 1.5px ring; border-box keeps that ring inside
|
|
97
|
-
* the 20px circle the travel is computed for. */
|
|
98
162
|
box-sizing: border-box;
|
|
99
163
|
width: 20px;
|
|
100
164
|
height: 20px;
|
|
@@ -104,8 +168,6 @@
|
|
|
104
168
|
background: var(--dsw-alias-label-primary-foreground);
|
|
105
169
|
box-shadow: var(--dsw-elevation-soft);
|
|
106
170
|
pointer-events: none;
|
|
107
|
-
/* Letting go eases the knob onto the detent it settled on; the drag turns this
|
|
108
|
-
* off so the knob sits exactly under the pointer. */
|
|
109
171
|
transition: left 160ms cubic-bezier(0.2, 0, 0, 1);
|
|
110
172
|
}
|
|
111
173
|
|
|
@@ -121,8 +183,6 @@
|
|
|
121
183
|
}
|
|
122
184
|
}
|
|
123
185
|
|
|
124
|
-
/* Provider default: nothing is filled and the knob is a hollow ring, so the
|
|
125
|
-
* state never reads as the weakest level. */
|
|
126
186
|
.slider[data-default] .sliderKnob {
|
|
127
187
|
background: var(--dsw-alias-bg-layer-1);
|
|
128
188
|
border: 1.5px solid var(--dsw-alias-label-tertiary);
|
|
@@ -138,7 +198,6 @@
|
|
|
138
198
|
outline-offset: 3px;
|
|
139
199
|
}
|
|
140
200
|
|
|
141
|
-
/* ── the picker rows ─────────────────────────────────────────────────────── */
|
|
142
201
|
|
|
143
202
|
.rowBadge {
|
|
144
203
|
flex: none;
|
|
@@ -153,13 +212,7 @@
|
|
|
153
212
|
|
|
154
213
|
.rowPick {
|
|
155
214
|
box-sizing: border-box;
|
|
156
|
-
/* A slightly tighter side padding buys the name a few more characters, which
|
|
157
|
-
* is what keeps a long provider suffix readable inside a narrow card. */
|
|
158
215
|
padding-inline: 6px;
|
|
159
|
-
/* The scroll list is a block container, so a flex item's `flex: 1` does
|
|
160
|
-
* nothing here: the row must claim the full width or a long model name pushes
|
|
161
|
-
* the favorite mark and the check past the card's edge, where overflow clips
|
|
162
|
-
* them. */
|
|
163
216
|
width: 100%;
|
|
164
217
|
flex: 1;
|
|
165
218
|
min-width: 0;
|
|
@@ -220,8 +273,6 @@
|
|
|
220
273
|
display: grid;
|
|
221
274
|
}
|
|
222
275
|
|
|
223
|
-
/* The picker's star is a real control: outline until hover or focus, solid and
|
|
224
|
-
* gold once favorited, and visible without hover on touch screens. */
|
|
225
276
|
.starButton {
|
|
226
277
|
color: var(--dsw-alias-label-tertiary);
|
|
227
278
|
cursor: pointer;
|
|
@@ -261,7 +312,6 @@
|
|
|
261
312
|
flex: none;
|
|
262
313
|
}
|
|
263
314
|
|
|
264
|
-
/* ── shared status lines ─────────────────────────────────────────────────── */
|
|
265
315
|
|
|
266
316
|
.notice {
|
|
267
317
|
color: var(--dsw-alias-label-tertiary);
|
|
@@ -286,9 +336,8 @@
|
|
|
286
336
|
text-decoration: underline;
|
|
287
337
|
}
|
|
288
338
|
|
|
289
|
-
/* ── the picker dialog ───────────────────────────────────────────────────── */
|
|
290
339
|
|
|
291
|
-
.pickerDialog {
|
|
340
|
+
.pickerDialog.pickerDialog {
|
|
292
341
|
width: min(680px, 100%);
|
|
293
342
|
height: min(640px, 80vh);
|
|
294
343
|
gap: 0;
|
|
@@ -302,9 +351,6 @@
|
|
|
302
351
|
flex-direction: column;
|
|
303
352
|
}
|
|
304
353
|
|
|
305
|
-
/* Modal wraps children in a body row of its own; that row — the content
|
|
306
|
-
* region's last child — is what has to carry the column and give the list its
|
|
307
|
-
* remaining height, so the footer stays put while the list scrolls. */
|
|
308
354
|
.pickerContent > :last-child {
|
|
309
355
|
min-height: 0;
|
|
310
356
|
flex: 1;
|
|
@@ -320,9 +366,6 @@
|
|
|
320
366
|
width: 100%;
|
|
321
367
|
}
|
|
322
368
|
|
|
323
|
-
/* The tabs scroll sideways rather than wrap: the dialog keeps one row of
|
|
324
|
-
* providers however many the catalog has, so the list below starts at the same
|
|
325
|
-
* height every time. The bar keeps its hairline and hides its scrollbar. */
|
|
326
369
|
.pickerTabs {
|
|
327
370
|
border-bottom: .5px solid var(--dsw-alias-border-l2);
|
|
328
371
|
gap: 2px;
|
|
@@ -378,7 +421,8 @@
|
|
|
378
421
|
border-top: .5px solid var(--dsw-alias-border-l2);
|
|
379
422
|
color: var(--dsw-alias-label-tertiary);
|
|
380
423
|
align-items: center;
|
|
381
|
-
|
|
424
|
+
justify-content: space-between;
|
|
425
|
+
gap: 12px;
|
|
382
426
|
padding: 10px 20px;
|
|
383
427
|
font-size: 12px;
|
|
384
428
|
line-height: 18px;
|
|
@@ -392,3 +436,6 @@
|
|
|
392
436
|
flex-wrap: wrap;
|
|
393
437
|
}
|
|
394
438
|
|
|
439
|
+
.footerFavorites {
|
|
440
|
+
text-align: end;
|
|
441
|
+
}
|