dsh-model-select-plus 0.2.0 → 0.2.1
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 +9 -8
- package/lib/client.cjs +76 -49
- package/package.json +1 -1
- package/src/client.js +90 -63
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
## 特性
|
|
6
6
|
|
|
7
|
-
1. **单栏列表**:模型按 provider 分组全部展开,行高 34px(与 DSH 原生菜单一致),卡片
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
11
|
-
5.
|
|
12
|
-
6.
|
|
13
|
-
7.
|
|
14
|
-
8.
|
|
7
|
+
1. **单栏列表**:模型按 provider 分组全部展开,行高 34px(与 DSH 原生菜单一致),卡片 420×440(原生菜单上限,一行放得下名字和等级);没有折叠、没有 Tag 条、没有底部状态条。
|
|
8
|
+
2. **行内等级,一次点完**:每行右侧直接给出该模型的推理等级,点等级即同时提交模型和等级;点模型名则按供应商默认等级选择。当前行的等级用 6% 填充标出,其它行用字重标出默认等级。
|
|
9
|
+
3. **当前行展开**:只有当前模型向下展开 2 行描述,其余行保持 34px 基线;打开菜单时自动把当前模型滚到列表中间。
|
|
10
|
+
4. **搜索**:34px 单行搜索,按模型名 / 描述 / provider 过滤,带清除按钮;打开即自动聚焦。
|
|
11
|
+
5. **收藏置顶**:行尾星标(悬停出现)收藏,收藏项移动到顶部独立分组,并在行尾标出 provider;取消后回到原分组。收藏存于浏览器内存,刷新即重置。
|
|
12
|
+
6. **分组标题**:11px 吸顶,只在真正吸到顶部时铺底色,静态时是纯文字;不显示数量,也不可折叠。
|
|
13
|
+
7. **选中态**:6% 填充 + 行尾对勾 + 500 字重,不再用 10% 灰块(那读起来像禁用)。
|
|
14
|
+
8. **触发按钮**:显示 `供应商/模型`;供应商 11px 次级色,超宽时先省略供应商、保住模型名。推理等级放在 tooltip 里。
|
|
15
|
+
9. **键盘**:`↑` / `↓` 在行间移动,`Enter` 选择,`Esc` 关闭并把焦点还给触发按钮。
|
|
15
16
|
|
|
16
17
|
打开时按触发按钮在视口内的剩余空间决定向上/向下弹,收敛高度并把左右夹在视口内;浅色与深色都走主题令牌(深色下分段控件的滑块改用 active 填充),所有图标为手绘 SVG,不用文字字符充当图标。
|
|
17
18
|
|
package/lib/client.cjs
CHANGED
|
@@ -54,20 +54,21 @@ var module = { exports: {} };
|
|
|
54
54
|
|
|
55
55
|
/* Trigger: the composer's 28px chip, same as the sibling permission / plan
|
|
56
56
|
controls, so the row does not jump when this plugin replaces the seat. */
|
|
57
|
-
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width:
|
|
57
|
+
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 260px; max-width: min(260px, 45cqw); height: 28px; padding: 0 4px 0 8px; border: 0; border-radius: var(--dsw-radius-sm, 8px); background: transparent; color: var(--dsw-alias-label-secondary); font-family: inherit; font-size: 13px; line-height: 20px; font-weight: 400; cursor: pointer; outline: none; }
|
|
58
58
|
.mdsl-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
59
59
|
.mdsl-trigger:focus-visible { box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
|
|
60
60
|
.mdsl-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }
|
|
61
|
-
.mdsl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
-
/* The
|
|
63
|
-
|
|
61
|
+
.mdsl-label { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
+
/* The provider is context, the model is the subject: on overflow the level
|
|
63
|
+
collapses first, then the provider, and the model name stays whole. */
|
|
64
|
+
.mdsl-trigger-provider { flex-shrink: 100; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); }
|
|
64
65
|
.mdsl-effort { flex-shrink: 1000; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-caption); }
|
|
65
66
|
.mdsl-chevron { flex: none; display: inline-flex; color: var(--dsw-alias-label-caption); }
|
|
66
67
|
.mdsl-chevron-open { transform: rotate(180deg); }
|
|
67
68
|
|
|
68
|
-
/* Card: the shipped menu material.
|
|
69
|
-
|
|
70
|
-
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width:
|
|
69
|
+
/* Card: the shipped menu material. 420px is the native menu ceiling; the
|
|
70
|
+
extra width is what keeps names whole once every row carries its levels. */
|
|
71
|
+
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width: 420px; max-width: calc(100vw - 24px); max-height: min(440px, calc(100vh - 120px)); padding: 4px; background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-overlay)); -webkit-backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); border: 0; border-radius: var(--dsw-radius-lg, 16px); --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); box-shadow: var(--dsw-elevation-prominent, 0 10px 36px rgba(0,0,0,.14)); color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 13px; --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2); --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2); overflow: hidden; animation: mdsl-in .16s cubic-bezier(.22, 1, .36, 1); transform-origin: bottom right; }
|
|
71
72
|
body[data-ds-dark-theme] .mdsl-menu { --dsw-elevation-stroke-color: var(--dsw-alias-border-l3); }
|
|
72
73
|
@keyframes mdsl-in { from { opacity: 0; transform: translateY(4px) scale(.99); } to { opacity: 1; transform: none; } }
|
|
73
74
|
@media (prefers-reduced-motion: reduce) { .mdsl-menu { animation: none; } }
|
|
@@ -115,16 +116,18 @@ var module = { exports: {} };
|
|
|
115
116
|
.mdsl-star:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
116
117
|
.mdsl-star-on { color: var(--dsw-alias-brand-primary); }
|
|
117
118
|
|
|
118
|
-
/*
|
|
119
|
-
|
|
119
|
+
/* Effort lives on the row: one click commits model + level. The provider
|
|
120
|
+
default is the weight-only chip; the current row's pinned level gets a
|
|
121
|
+
fill as well. Only the description still expands under the current row. */
|
|
122
|
+
.mdsl-chips { display: flex; align-items: center; gap: 2px; flex: none; }
|
|
123
|
+
.mdsl-chip { height: 20px; padding: 0 5px; border: 0; border-radius: 4px; background: transparent; color: var(--dsw-alias-label-tertiary); font-family: inherit; font-size: 11px; line-height: 20px; cursor: pointer; }
|
|
124
|
+
.mdsl-chip:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
125
|
+
.mdsl-chip:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
126
|
+
.mdsl-chip-eff { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
127
|
+
.mdsl-chip-on { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); font-weight: 500; }
|
|
128
|
+
|
|
120
129
|
.mdsl-sub { padding: 2px 8px 8px; }
|
|
121
130
|
.mdsl-desc { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
122
|
-
.mdsl-track { display: flex; align-items: center; gap: 2px; height: 26px; margin-top: 6px; padding: 3px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover); }
|
|
123
|
-
.mdsl-seg { flex: 1; height: 20px; padding: 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); font-family: inherit; font-size: 11px; line-height: 20px; text-align: center; cursor: pointer; }
|
|
124
|
-
.mdsl-seg:hover { color: var(--dsw-alias-label-primary); }
|
|
125
|
-
.mdsl-seg:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
126
|
-
.mdsl-seg-on { background: var(--dsw-alias-bg-base, #fff); color: var(--dsw-alias-label-primary); font-weight: 500; box-shadow: 0 0 0 0.5px var(--dsw-alias-border-l2), 0 1px 2px rgba(0, 0, 0, .05); }
|
|
127
|
-
body[data-ds-dark-theme] .mdsl-seg-on { background: var(--dsw-alias-interactive-bg-active); }
|
|
128
131
|
|
|
129
132
|
.mdsl-empty { padding: 16px 8px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
|
|
130
133
|
.mdsl-error { margin: 4px 2px; padding: 6px 8px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover-danger); color: var(--dsw-alias-state-error-primary); font-size: 11px; line-height: 16px; }
|
|
@@ -217,7 +220,7 @@ var module = { exports: {} };
|
|
|
217
220
|
const rect = trigger.getBoundingClientRect();
|
|
218
221
|
const margin = 12;
|
|
219
222
|
const gap = 6;
|
|
220
|
-
const width = Math.min(
|
|
223
|
+
const width = Math.min(420, window.innerWidth - margin * 2);
|
|
221
224
|
const spaceAbove = rect.top - gap - margin;
|
|
222
225
|
const spaceBelow = window.innerHeight - rect.bottom - gap - margin;
|
|
223
226
|
const side = spaceAbove >= spaceBelow ? "top" : "bottom";
|
|
@@ -279,6 +282,27 @@ var module = { exports: {} };
|
|
|
279
282
|
if (raf) cancelAnimationFrame(raf);
|
|
280
283
|
};
|
|
281
284
|
}, [open, placement, data.status, data.current, query]);
|
|
285
|
+
const locatedForOpen = import_react.default.useRef(false);
|
|
286
|
+
import_react.default.useLayoutEffect(() => {
|
|
287
|
+
if (!open) {
|
|
288
|
+
locatedForOpen.current = false;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (locatedForOpen.current || placement === null) return;
|
|
292
|
+
if (data.status !== "ready" || query !== "") return;
|
|
293
|
+
const body = bodyRef.current;
|
|
294
|
+
if (!body) return;
|
|
295
|
+
const item = body.querySelector('[data-current="true"]');
|
|
296
|
+
if (item === null) {
|
|
297
|
+
locatedForOpen.current = true;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const bodyRect = body.getBoundingClientRect();
|
|
301
|
+
const itemRect = item.getBoundingClientRect();
|
|
302
|
+
const delta = itemRect.top - bodyRect.top - (body.clientHeight - itemRect.height) / 2;
|
|
303
|
+
body.scrollTop = Math.max(0, body.scrollTop + delta);
|
|
304
|
+
locatedForOpen.current = true;
|
|
305
|
+
}, [open, placement, data.status, query]);
|
|
282
306
|
const focusTrigger = () => {
|
|
283
307
|
const el = triggerRef.current;
|
|
284
308
|
if (el) el.focus({ preventScroll: true });
|
|
@@ -332,7 +356,8 @@ var module = { exports: {} };
|
|
|
332
356
|
selectSelection({ provider: g.id, model: m.id, ...effort === void 0 ? {} : { reasoningEffort: effort } }, false);
|
|
333
357
|
};
|
|
334
358
|
const chooseEffort = (g, m, effort) => {
|
|
335
|
-
|
|
359
|
+
const sameModel = current !== null && current !== void 0 && current.provider === g.id && current.model === m.id;
|
|
360
|
+
selectSelection({ provider: g.id, model: m.id, ...effort === void 0 ? {} : { reasoningEffort: effort } }, sameModel);
|
|
336
361
|
};
|
|
337
362
|
const current = data.current;
|
|
338
363
|
const curGroup = current ? data.groups.find((g) => g.id === current.provider) : void 0;
|
|
@@ -378,6 +403,10 @@ var module = { exports: {} };
|
|
|
378
403
|
const fav = favorites.has(`${g.id}/${m.id}`);
|
|
379
404
|
const hasEfforts = !!(m.reasoning && m.reasoning.efforts && m.reasoning.efforts.length);
|
|
380
405
|
const desc = typeof m.description === "string" && m.description !== "" ? m.description : void 0;
|
|
406
|
+
const rowEffort = selected ? pinnedEffort : m.reasoning ? m.reasoning.defaultEffort : void 0;
|
|
407
|
+
const stop = (ev) => {
|
|
408
|
+
if (ev.key === "Enter" || ev.key === " ") ev.stopPropagation();
|
|
409
|
+
};
|
|
381
410
|
const row = h(
|
|
382
411
|
"div",
|
|
383
412
|
{
|
|
@@ -396,6 +425,28 @@ var module = { exports: {} };
|
|
|
396
425
|
},
|
|
397
426
|
h("span", { className: "mdsl-name" }, m.name),
|
|
398
427
|
showProvider ? h("span", { className: "mdsl-prov" }, g.name) : null,
|
|
428
|
+
hasEfforts ? h(
|
|
429
|
+
"span",
|
|
430
|
+
{ className: "mdsl-chips", role: "group", "aria-label": "\u63A8\u7406\u7B49\u7EA7" },
|
|
431
|
+
m.reasoning.efforts.map((e) => h(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
key: e.id,
|
|
435
|
+
type: "button",
|
|
436
|
+
title: e.description || e.name,
|
|
437
|
+
"aria-pressed": rowEffort === e.id,
|
|
438
|
+
className: "mdsl-chip" + (rowEffort === e.id ? selected ? " mdsl-chip-on" : " mdsl-chip-eff" : ""),
|
|
439
|
+
onClick: (ev) => {
|
|
440
|
+
ev.stopPropagation();
|
|
441
|
+
chooseEffort(g, m, e.id);
|
|
442
|
+
},
|
|
443
|
+
// A real button fires click on Enter/Space; keep the row's own
|
|
444
|
+
// keyboard handler out of the way so the level wins.
|
|
445
|
+
onKeyDown: stop
|
|
446
|
+
},
|
|
447
|
+
e.name
|
|
448
|
+
))
|
|
449
|
+
) : null,
|
|
399
450
|
h(
|
|
400
451
|
"button",
|
|
401
452
|
{
|
|
@@ -407,45 +458,20 @@ var module = { exports: {} };
|
|
|
407
458
|
ev.stopPropagation();
|
|
408
459
|
toggleFav(g.id, m.id);
|
|
409
460
|
},
|
|
410
|
-
|
|
411
|
-
// keyboard handler out of the way so toggling does not select.
|
|
412
|
-
onKeyDown: (ev) => {
|
|
413
|
-
if (ev.key === "Enter" || ev.key === " ") ev.stopPropagation();
|
|
414
|
-
}
|
|
461
|
+
onKeyDown: stop
|
|
415
462
|
},
|
|
416
463
|
star(fav)
|
|
417
464
|
),
|
|
418
465
|
selected ? h("span", { className: "mdsl-check" }, check()) : null
|
|
419
466
|
);
|
|
420
|
-
const sub = selected &&
|
|
421
|
-
"div",
|
|
422
|
-
{ className: "mdsl-sub" },
|
|
423
|
-
desc ? h("div", { className: "mdsl-desc" }, desc) : null,
|
|
424
|
-
hasEfforts ? h(
|
|
425
|
-
"div",
|
|
426
|
-
{ className: "mdsl-track", role: "group", "aria-label": "\u63A8\u7406\u7B49\u7EA7" },
|
|
427
|
-
h(
|
|
428
|
-
"button",
|
|
429
|
-
{ type: "button", "aria-pressed": pinnedEffort === void 0, className: "mdsl-seg" + (pinnedEffort === void 0 ? " mdsl-seg-on" : ""), onClick: () => chooseEffort(g, m, void 0) },
|
|
430
|
-
"\u9ED8\u8BA4"
|
|
431
|
-
),
|
|
432
|
-
m.reasoning.efforts.map((e) => h(
|
|
433
|
-
"button",
|
|
434
|
-
{
|
|
435
|
-
key: e.id,
|
|
436
|
-
type: "button",
|
|
437
|
-
title: e.description || e.name,
|
|
438
|
-
"aria-pressed": pinnedEffort === e.id,
|
|
439
|
-
className: "mdsl-seg" + (pinnedEffort === e.id ? " mdsl-seg-on" : ""),
|
|
440
|
-
onClick: () => chooseEffort(g, m, e.id)
|
|
441
|
-
},
|
|
442
|
-
e.name
|
|
443
|
-
))
|
|
444
|
-
) : null
|
|
445
|
-
) : null;
|
|
467
|
+
const sub = selected && desc !== void 0 ? h("div", { className: "mdsl-sub" }, h("div", { className: "mdsl-desc" }, desc)) : null;
|
|
446
468
|
return h(
|
|
447
469
|
"div",
|
|
448
|
-
{
|
|
470
|
+
{
|
|
471
|
+
key: `${g.id}/${m.id}`,
|
|
472
|
+
className: "mdsl-item" + (selected ? " mdsl-item-current" : ""),
|
|
473
|
+
"data-current": selected ? "true" : void 0
|
|
474
|
+
},
|
|
449
475
|
row,
|
|
450
476
|
sub
|
|
451
477
|
);
|
|
@@ -487,6 +513,7 @@ var module = { exports: {} };
|
|
|
487
513
|
"aria-haspopup": "dialog",
|
|
488
514
|
"aria-expanded": open
|
|
489
515
|
},
|
|
516
|
+
current && providerName ? h("span", { className: "mdsl-trigger-provider" }, providerName + "/") : null,
|
|
490
517
|
h("span", { className: "mdsl-label" }, current ? modelName : "\u9009\u62E9\u6A21\u578B"),
|
|
491
518
|
effortLabel ? h("span", { className: "mdsl-effort" }, effortLabel) : null,
|
|
492
519
|
h("span", { className: "mdsl-chevron" + (open ? " mdsl-chevron-open" : "") }, chevronDown())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-select-plus",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A calmer model-selection popup for DeepSeek Harness: provider-grouped rows at the native 34px rhythm, an inline description and reasoning-effort control on the current model, search and pinned favorites, replacing the composer's default ModelSelect.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/host.js",
|
package/src/client.js
CHANGED
|
@@ -10,20 +10,21 @@
|
|
|
10
10
|
* through `document` (the `plugin-dashboard` / `skin-material-you` pattern).
|
|
11
11
|
*
|
|
12
12
|
* Layout (one column, native menu measures):
|
|
13
|
-
* - card
|
|
14
|
-
*
|
|
13
|
+
* - card 420 x 440: the native menu ceiling, and the width a name plus its
|
|
14
|
+
* levels need on one line; shipped menu material, 16px radius
|
|
15
15
|
* - one 34px search line with a 0.5px rule; no jump rail, no chips
|
|
16
|
-
* -
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
16
|
+
* - rows at the native 34px height: name, inline effort chips, star, check.
|
|
17
|
+
* A level chip commits model + level in one click; the name commits the
|
|
18
|
+
* provider default, which is the chip drawn in the weight-only state
|
|
19
|
+
* - selection is a 6% fill plus the trailing check; only the current row
|
|
20
|
+
* expands, and only for its two-line description
|
|
21
21
|
* - provider headings are 11px labels that paint their group-header fill only
|
|
22
22
|
* while stuck to the top; static groups stay flat
|
|
23
23
|
* - favorites stay pinned in their own top group, and their rows carry the
|
|
24
24
|
* provider name because the same model exists under several providers
|
|
25
|
-
* - trigger shows
|
|
26
|
-
*
|
|
25
|
+
* - the trigger shows provider/model (the provider ellipsizes first); the
|
|
26
|
+
* effort level lives in the tooltip and on the row chips
|
|
27
|
+
* - re-opening centers the current model instead of resetting to the top
|
|
27
28
|
*
|
|
28
29
|
* Data comes from the Host half at `/plugins/dsh-model-select-plus/api`.
|
|
29
30
|
* The seat passes `locked` (owner prop) and we inject `sessionId`.
|
|
@@ -47,20 +48,21 @@ const CSS = `
|
|
|
47
48
|
|
|
48
49
|
/* Trigger: the composer's 28px chip, same as the sibling permission / plan
|
|
49
50
|
controls, so the row does not jump when this plugin replaces the seat. */
|
|
50
|
-
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width:
|
|
51
|
+
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 260px; max-width: min(260px, 45cqw); height: 28px; padding: 0 4px 0 8px; border: 0; border-radius: var(--dsw-radius-sm, 8px); background: transparent; color: var(--dsw-alias-label-secondary); font-family: inherit; font-size: 13px; line-height: 20px; font-weight: 400; cursor: pointer; outline: none; }
|
|
51
52
|
.mdsl-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
52
53
|
.mdsl-trigger:focus-visible { box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
|
|
53
54
|
.mdsl-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }
|
|
54
|
-
.mdsl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
55
|
-
/* The
|
|
56
|
-
|
|
55
|
+
.mdsl-label { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
56
|
+
/* The provider is context, the model is the subject: on overflow the level
|
|
57
|
+
collapses first, then the provider, and the model name stays whole. */
|
|
58
|
+
.mdsl-trigger-provider { flex-shrink: 100; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); }
|
|
57
59
|
.mdsl-effort { flex-shrink: 1000; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-caption); }
|
|
58
60
|
.mdsl-chevron { flex: none; display: inline-flex; color: var(--dsw-alias-label-caption); }
|
|
59
61
|
.mdsl-chevron-open { transform: rotate(180deg); }
|
|
60
62
|
|
|
61
|
-
/* Card: the shipped menu material.
|
|
62
|
-
|
|
63
|
-
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width:
|
|
63
|
+
/* Card: the shipped menu material. 420px is the native menu ceiling; the
|
|
64
|
+
extra width is what keeps names whole once every row carries its levels. */
|
|
65
|
+
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width: 420px; max-width: calc(100vw - 24px); max-height: min(440px, calc(100vh - 120px)); padding: 4px; background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-overlay)); -webkit-backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); border: 0; border-radius: var(--dsw-radius-lg, 16px); --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); box-shadow: var(--dsw-elevation-prominent, 0 10px 36px rgba(0,0,0,.14)); color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 13px; --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2); --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2); overflow: hidden; animation: mdsl-in .16s cubic-bezier(.22, 1, .36, 1); transform-origin: bottom right; }
|
|
64
66
|
body[data-ds-dark-theme] .mdsl-menu { --dsw-elevation-stroke-color: var(--dsw-alias-border-l3); }
|
|
65
67
|
@keyframes mdsl-in { from { opacity: 0; transform: translateY(4px) scale(.99); } to { opacity: 1; transform: none; } }
|
|
66
68
|
@media (prefers-reduced-motion: reduce) { .mdsl-menu { animation: none; } }
|
|
@@ -108,16 +110,18 @@ const CSS = `
|
|
|
108
110
|
.mdsl-star:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
109
111
|
.mdsl-star-on { color: var(--dsw-alias-brand-primary); }
|
|
110
112
|
|
|
111
|
-
/*
|
|
112
|
-
|
|
113
|
+
/* Effort lives on the row: one click commits model + level. The provider
|
|
114
|
+
default is the weight-only chip; the current row's pinned level gets a
|
|
115
|
+
fill as well. Only the description still expands under the current row. */
|
|
116
|
+
.mdsl-chips { display: flex; align-items: center; gap: 2px; flex: none; }
|
|
117
|
+
.mdsl-chip { height: 20px; padding: 0 5px; border: 0; border-radius: 4px; background: transparent; color: var(--dsw-alias-label-tertiary); font-family: inherit; font-size: 11px; line-height: 20px; cursor: pointer; }
|
|
118
|
+
.mdsl-chip:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
119
|
+
.mdsl-chip:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
120
|
+
.mdsl-chip-eff { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
121
|
+
.mdsl-chip-on { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); font-weight: 500; }
|
|
122
|
+
|
|
113
123
|
.mdsl-sub { padding: 2px 8px 8px; }
|
|
114
124
|
.mdsl-desc { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
115
|
-
.mdsl-track { display: flex; align-items: center; gap: 2px; height: 26px; margin-top: 6px; padding: 3px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover); }
|
|
116
|
-
.mdsl-seg { flex: 1; height: 20px; padding: 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); font-family: inherit; font-size: 11px; line-height: 20px; text-align: center; cursor: pointer; }
|
|
117
|
-
.mdsl-seg:hover { color: var(--dsw-alias-label-primary); }
|
|
118
|
-
.mdsl-seg:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
119
|
-
.mdsl-seg-on { background: var(--dsw-alias-bg-base, #fff); color: var(--dsw-alias-label-primary); font-weight: 500; box-shadow: 0 0 0 0.5px var(--dsw-alias-border-l2), 0 1px 2px rgba(0, 0, 0, .05); }
|
|
120
|
-
body[data-ds-dark-theme] .mdsl-seg-on { background: var(--dsw-alias-interactive-bg-active); }
|
|
121
125
|
|
|
122
126
|
.mdsl-empty { padding: 16px 8px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
|
|
123
127
|
.mdsl-error { margin: 4px 2px; padding: 6px 8px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover-danger); color: var(--dsw-alias-state-error-primary); font-size: 11px; line-height: 16px; }
|
|
@@ -231,7 +235,7 @@ function ModelSelectLite(props) {
|
|
|
231
235
|
const rect = trigger.getBoundingClientRect();
|
|
232
236
|
const margin = 12;
|
|
233
237
|
const gap = 6;
|
|
234
|
-
const width = Math.min(
|
|
238
|
+
const width = Math.min(420, window.innerWidth - margin * 2);
|
|
235
239
|
const spaceAbove = rect.top - gap - margin;
|
|
236
240
|
const spaceBelow = window.innerHeight - rect.bottom - gap - margin;
|
|
237
241
|
const side = spaceAbove >= spaceBelow ? "top" : "bottom";
|
|
@@ -309,6 +313,24 @@ function ModelSelectLite(props) {
|
|
|
309
313
|
};
|
|
310
314
|
}, [open, placement, data.status, data.current, query]);
|
|
311
315
|
|
|
316
|
+
// Re-opening lands on the current model instead of the top of the list.
|
|
317
|
+
// useLayoutEffect so the jump happens before the card is painted.
|
|
318
|
+
const locatedForOpen = React.useRef(false);
|
|
319
|
+
React.useLayoutEffect(() => {
|
|
320
|
+
if (!open) { locatedForOpen.current = false; return; }
|
|
321
|
+
if (locatedForOpen.current || placement === null) return;
|
|
322
|
+
if (data.status !== "ready" || query !== "") return;
|
|
323
|
+
const body = bodyRef.current;
|
|
324
|
+
if (!body) return;
|
|
325
|
+
const item = body.querySelector('[data-current="true"]');
|
|
326
|
+
if (item === null) { locatedForOpen.current = true; return; }
|
|
327
|
+
const bodyRect = body.getBoundingClientRect();
|
|
328
|
+
const itemRect = item.getBoundingClientRect();
|
|
329
|
+
const delta = itemRect.top - bodyRect.top - (body.clientHeight - itemRect.height) / 2;
|
|
330
|
+
body.scrollTop = Math.max(0, body.scrollTop + delta);
|
|
331
|
+
locatedForOpen.current = true;
|
|
332
|
+
}, [open, placement, data.status, query]);
|
|
333
|
+
|
|
312
334
|
const focusTrigger = () => {
|
|
313
335
|
const el = triggerRef.current;
|
|
314
336
|
if (el) el.focus({ preventScroll: true });
|
|
@@ -365,9 +387,12 @@ function ModelSelectLite(props) {
|
|
|
365
387
|
};
|
|
366
388
|
|
|
367
389
|
const chooseEffort = (g, m, effort) => {
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
|
|
390
|
+
// Changing the level of the model already in use keeps the card open so
|
|
391
|
+
// the user can compare levels; picking a level on another model commits
|
|
392
|
+
// model + level in one click and closes.
|
|
393
|
+
const sameModel = current !== null && current !== undefined
|
|
394
|
+
&& current.provider === g.id && current.model === m.id;
|
|
395
|
+
selectSelection({ provider: g.id, model: m.id, ...(effort === undefined ? {} : { reasoningEffort: effort }) }, sameModel);
|
|
371
396
|
};
|
|
372
397
|
|
|
373
398
|
const current = data.current;
|
|
@@ -422,6 +447,10 @@ function ModelSelectLite(props) {
|
|
|
422
447
|
const fav = favorites.has(`${g.id}/${m.id}`);
|
|
423
448
|
const hasEfforts = !!(m.reasoning && m.reasoning.efforts && m.reasoning.efforts.length);
|
|
424
449
|
const desc = typeof m.description === "string" && m.description !== "" ? m.description : undefined;
|
|
450
|
+
// The level a click would commit: the pinned one on the current row, the
|
|
451
|
+
// provider default on every other row.
|
|
452
|
+
const rowEffort = selected ? pinnedEffort : (m.reasoning ? m.reasoning.defaultEffort : undefined);
|
|
453
|
+
const stop = (ev) => { if (ev.key === "Enter" || ev.key === " ") ev.stopPropagation(); };
|
|
425
454
|
const row = h(
|
|
426
455
|
"div",
|
|
427
456
|
{
|
|
@@ -440,6 +469,30 @@ function ModelSelectLite(props) {
|
|
|
440
469
|
},
|
|
441
470
|
h("span", { className: "mdsl-name" }, m.name),
|
|
442
471
|
showProvider ? h("span", { className: "mdsl-prov" }, g.name) : null,
|
|
472
|
+
hasEfforts
|
|
473
|
+
? h(
|
|
474
|
+
"span",
|
|
475
|
+
{ className: "mdsl-chips", role: "group", "aria-label": "推理等级" },
|
|
476
|
+
m.reasoning.efforts.map((e) => h(
|
|
477
|
+
"button",
|
|
478
|
+
{
|
|
479
|
+
key: e.id,
|
|
480
|
+
type: "button",
|
|
481
|
+
title: e.description || e.name,
|
|
482
|
+
"aria-pressed": rowEffort === e.id,
|
|
483
|
+
className: "mdsl-chip" + (rowEffort === e.id ? (selected ? " mdsl-chip-on" : " mdsl-chip-eff") : ""),
|
|
484
|
+
onClick: (ev) => {
|
|
485
|
+
ev.stopPropagation();
|
|
486
|
+
chooseEffort(g, m, e.id);
|
|
487
|
+
},
|
|
488
|
+
// A real button fires click on Enter/Space; keep the row's own
|
|
489
|
+
// keyboard handler out of the way so the level wins.
|
|
490
|
+
onKeyDown: stop,
|
|
491
|
+
},
|
|
492
|
+
e.name,
|
|
493
|
+
)),
|
|
494
|
+
)
|
|
495
|
+
: null,
|
|
443
496
|
h(
|
|
444
497
|
"button",
|
|
445
498
|
{
|
|
@@ -451,51 +504,24 @@ function ModelSelectLite(props) {
|
|
|
451
504
|
ev.stopPropagation();
|
|
452
505
|
toggleFav(g.id, m.id);
|
|
453
506
|
},
|
|
454
|
-
|
|
455
|
-
// keyboard handler out of the way so toggling does not select.
|
|
456
|
-
onKeyDown: (ev) => {
|
|
457
|
-
if (ev.key === "Enter" || ev.key === " ") ev.stopPropagation();
|
|
458
|
-
},
|
|
507
|
+
onKeyDown: stop,
|
|
459
508
|
},
|
|
460
509
|
star(fav),
|
|
461
510
|
),
|
|
462
511
|
selected ? h("span", { className: "mdsl-check" }, check()) : null,
|
|
463
512
|
);
|
|
464
513
|
|
|
465
|
-
const sub = selected &&
|
|
466
|
-
? h(
|
|
467
|
-
"div",
|
|
468
|
-
{ className: "mdsl-sub" },
|
|
469
|
-
desc ? h("div", { className: "mdsl-desc" }, desc) : null,
|
|
470
|
-
hasEfforts
|
|
471
|
-
? h(
|
|
472
|
-
"div",
|
|
473
|
-
{ className: "mdsl-track", role: "group", "aria-label": "推理等级" },
|
|
474
|
-
h(
|
|
475
|
-
"button",
|
|
476
|
-
{ type: "button", "aria-pressed": pinnedEffort === undefined, className: "mdsl-seg" + (pinnedEffort === undefined ? " mdsl-seg-on" : ""), onClick: () => chooseEffort(g, m, undefined) },
|
|
477
|
-
"默认",
|
|
478
|
-
),
|
|
479
|
-
m.reasoning.efforts.map((e) => h(
|
|
480
|
-
"button",
|
|
481
|
-
{
|
|
482
|
-
key: e.id,
|
|
483
|
-
type: "button",
|
|
484
|
-
title: e.description || e.name,
|
|
485
|
-
"aria-pressed": pinnedEffort === e.id,
|
|
486
|
-
className: "mdsl-seg" + (pinnedEffort === e.id ? " mdsl-seg-on" : ""),
|
|
487
|
-
onClick: () => chooseEffort(g, m, e.id),
|
|
488
|
-
},
|
|
489
|
-
e.name,
|
|
490
|
-
)),
|
|
491
|
-
)
|
|
492
|
-
: null,
|
|
493
|
-
)
|
|
514
|
+
const sub = selected && desc !== undefined
|
|
515
|
+
? h("div", { className: "mdsl-sub" }, h("div", { className: "mdsl-desc" }, desc))
|
|
494
516
|
: null;
|
|
495
517
|
|
|
496
518
|
return h(
|
|
497
519
|
"div",
|
|
498
|
-
{
|
|
520
|
+
{
|
|
521
|
+
key: `${g.id}/${m.id}`,
|
|
522
|
+
className: "mdsl-item" + (selected ? " mdsl-item-current" : ""),
|
|
523
|
+
"data-current": selected ? "true" : undefined,
|
|
524
|
+
},
|
|
499
525
|
row,
|
|
500
526
|
sub,
|
|
501
527
|
);
|
|
@@ -541,6 +567,7 @@ function ModelSelectLite(props) {
|
|
|
541
567
|
"aria-haspopup": "dialog",
|
|
542
568
|
"aria-expanded": open,
|
|
543
569
|
},
|
|
570
|
+
current && providerName ? h("span", { className: "mdsl-trigger-provider" }, providerName + "/") : null,
|
|
544
571
|
h("span", { className: "mdsl-label" }, current ? modelName : "选择模型"),
|
|
545
572
|
effortLabel ? h("span", { className: "mdsl-effort" }, effortLabel) : null,
|
|
546
573
|
h("span", { className: "mdsl-chevron" + (open ? " mdsl-chevron-open" : "") }, chevronDown()),
|