dsh-effort-mosaic 1.2.0 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  按版本倒序。每条按「新增 / 修复 / 质量」归类;没有的分类省略。
4
4
 
5
+ ## 1.2.2 — 2026-11-20
6
+
7
+ ### 修复
8
+
9
+ - **切换模型后推理轨道偶尔空白**:`current.reasoningEffort` 可能还留着上一个模型的 id,旧逻辑直接拿它找下标会得到 `-1`,轨道进入未就绪状态。现在会先用当前模型的 `efforts` 校验,失效时回落到 `defaultEffort`;`default` / `auto` / `none` 只有不在当前档位表里时才当作“跟随默认”的占位值,真实声明的 `none` 档不再被误吞。
10
+ - **模型切换后目录桥仍读旧 store**:`createAccess` 现在每次读取、订阅、选择都重新解析 `directoryFor`;目录包装对象换了、内部 store 换了、连接重置都会重新订阅,清空旧快照并主动通知 React。新目录加载不再沿用旧目录的 400ms 节流,避免刚打开菜单就切模型时新目录被跳过。
11
+ - **轨道索引解析失败仍占 30px 空白**:只要当前模型确实声明了 `reasoning.efforts`,轨道就不会因为 `liveIndex` / 行文案暂时解析不出而完全隐藏;最后会先落在第一档,等快照或官方行文本回来再纠正。未就绪轨道高度收为 0,空容器 `display:none`,不再留下空白占位。
12
+ - **官方行文本和档位对象格式兼容性**:行文本支持 `推理等级 Max`、`Effort: Default`、尾部箭头、大小写混用;不会把 `Maximum` 误判成 `Max`。`efforts` 支持 `{ id, name }`、`{ id, label }` 和字符串数组,`current.model` 兼容字符串与 `{ id }` 对象。
13
+ - **模型换代时旧乐观状态串台**:切换模型会清掉上一代留下的 `draft`、待写档位和超时计时器,避免旧档位短暂盖在新模型轨道上,或把旧档位写进新模型;`teardownEntry` 也会摘掉官方行重建后遗留的空容器。
14
+ - **切模型后非最高档字符被误染蓝**:最高档染色现在只作用于当前最高档那一段文字,不再给卡片里所有档位名统一上蓝;乐观染色索引会绑定模型 id,刚把模型 A 拉到最高档就切到模型 B 时,B 的首帧直接按自己的真实档位绘制,不会先沿用 A 的最高档索引。
15
+
16
+ ### 质量
17
+
18
+ - `node --check lib/client.js` 通过;离线检查覆盖 `Default` 回落、旧模型档位失效、真实 `none` 档、字符串档位、provider 重挂、对象模型 id、菜单行标签/箭头解析、目录切换、加载节流和快照身份稳定性。
19
+ - 发布包仍只包含运行文件:`lib/`、`cordis.patch.yml`、`icon.svg`、`package.json`、`README.md`、`CHANGELOG.md`、`LICENSE`。
20
+
21
+ ## 1.2.1 — 2026-11-20
22
+
23
+ ### 修复
24
+
25
+ - **详情页面板在未注入 DSH 令牌的宿主里变黑**:`.dem-cfg` 不再依赖宿主的深浅主题令牌,改用作用域内固定浅色值,选中块为白底蓝字、正文为深灰、预览卡片为浅蓝渐变;即使宿主是深色页面或没注入 `--dsw-alias-*`,面板也保持可读,对话轨道不受影响。
26
+ - **滑块右缘在拖拽形变时露出色轨**:色带、粒子和滑块现在共用同一条右端收口线 `--dem-knob-tail-inset`。实心滑块切在圆心左侧 8px,空心环保持圆心透色,细棒退到棒体左缘;粒子引擎每帧写的 `clip-path` 也使用这条收口,不再把右侧重新放开成 0,`scale / skew` 时右上、右下不会冒出蓝色方块或细线。
27
+ - **预览首帧与重渲染时的右侧漏色**:填充自身按宽度反推收口,粒子层在自己的宽度上独立裁右,不再依赖可能缺失或滞后的轨道像素变量;越界动画仍可飞出轨道上下边,只有右边界被统一收住。
28
+
29
+ ### 质量
30
+
31
+ - `node --check lib/client.js` 通过;用 4x 渲染台复现实机内联 `clip-path`,在 `scaleX 1.32 / scaleY 1.18 / skew 7°` 下确认旋钮右侧无色轨或粒子方块。
32
+ - 发布包仍只包含运行文件:`lib/`、`cordis.patch.yml`、`icon.svg`、`package.json`、`README.md`、`CHANGELOG.md`、`LICENSE`。
33
+
5
34
  ## 1.2.0 — 2026-11-20
6
35
 
7
36
  ### 新增
package/README.md CHANGED
@@ -57,7 +57,7 @@ dsh plugin --profile web add "github:xiaobaga281/dsh-effort-mosaic"
57
57
 
58
58
  ## 视觉
59
59
 
60
- 一条 30px 高的胶囊凹槽,自下而上叠四层:填充渐变 → 6 行 × 5px 粒子 → 刻度 → 滑块。填充、粒子、凹槽共用同一条轮廓:右端按滑块内缘收口,带高跟随滑块(`min(30, 滑块高)`),接缝处不会露出蓝边。
60
+ 一条 30px 高的胶囊凹槽,自下而上叠四层:填充渐变 → 6 行 × 5px 粒子 → 刻度 → 滑块。填充、粒子、凹槽共用同一条轮廓:右端按滑块内缘收口,带高跟随滑块(`min(30, 滑块高)`),接缝处不会露出蓝边。拖动形变时色带和滑块共用同一条右端收口线,`scale / skew` 也不会让色轨从旋钮右上、右下探出来。
61
61
 
62
62
  粒子按离滑块的距离决定散开程度:右侧 2% 是严格贴网格的墙,往左 `amp` 增大、漂移与抖动随之变大,最左端几乎全部脱离。颜色取自同一条渐变色阶 × 明度系数(0.80–1.06),砖缝从浅蓝到纯蓝都看得清。
63
63
 
@@ -69,7 +69,7 @@ dsh plugin --profile web add "github:xiaobaga281/dsh-effort-mosaic"
69
69
 
70
70
  ## 自定义版式
71
71
 
72
- 插件详情页里有一块面板,预览直接使用正式的三档轨道(Off / Medium / Max),可以拖动、点击、键盘切换;改任何一项即时生效,最高档字符按当前染色设置显示,旁边可「播放」重播一次点亮。打开「拖拽动效」开关时会自动演示一次端点 / 纵向形变,不用真的去拖也能看出差别。越界选「全档位」会把预览自动停到 Medium、选「最高档」停回 Max,两种模式当场就能对上画面。点击预览轨道时,档位字符等滑块 `.3s` 过渡收口后再切换,不会在滑块还在走的时候提前跳字。预览的粒子遮罩变量完全由每帧的 `syncTail` 按真实滑块位置写,点击瞬间不会再先跳到目标档位;粒子边缘也按滑块内缘连续裁切,不按 5px 整格淘汰,从 Max 切到 Medium 时右缘不会闪一下或一格一格地空/满跳。
72
+ 插件详情页里有一块面板,预览直接使用正式的三档轨道(Off / Medium / Max),可以拖动、点击、键盘切换;改任何一项即时生效,最高档字符按当前染色设置显示,旁边可「播放」重播一次点亮。打开「拖拽动效」开关时会自动演示一次端点 / 纵向形变,不用真的去拖也能看出差别。越界选「全档位」会把预览自动停到 Medium、选「最高档」停回 Max,两种模式当场就能对上画面。点击预览轨道时,档位字符等滑块 `.3s` 过渡收口后再切换,不会在滑块还在走的时候提前跳字。预览的粒子遮罩变量完全由每帧的 `syncTail` 按真实滑块位置写,点击瞬间不会再先跳到目标档位;粒子边缘也按滑块内缘连续裁切,不按 5px 整格淘汰,从 Max 切到 Medium 时右缘不会闪一下或一格一格地空/满跳。详情页面板本身锁定为固定浅色,不跟随宿主深浅主题;选中项白底蓝字,预览卡浅蓝底,宿主没注入 `--dsw-alias-*` 也不会变成黑底黑字。
73
73
 
74
74
  | 项 | 取值 | 默认 |
75
75
  |---|---|---|
@@ -109,7 +109,7 @@ dsh plugin --profile web add "github:xiaobaga281/dsh-effort-mosaic"
109
109
 
110
110
  改动前值得知道的几条约束(都是踩过坑的地方):
111
111
 
112
- 1. **右端收口不能用 `clip-path`** —— 它只有轴对齐四条边,半圆端帽会露方角。用 `TAIL_MASK` + `mask-clip: no-clip`;否则 mask 默认的 `border-box` 会把飞出轨道的方块整片裁掉。
112
+ 1. **右端收口要分层处理**:半圆端帽不能用单层 `clip-path` 硬切(它只有轴对齐四条边,会露方角),必须用 `TAIL_MASK` + `mask-clip: no-clip`;粒子层的直线右缘可以在自身宽度上用 `clip-path` 收口,但右端 inset 必须和填充共用 `--dem-knob-tail-inset`,否则两层各收各的,动画一开就会错位。
113
113
  2. **拖动吸附是临界阻尼闭式解**:松手 ω=22(带指针初速),收尾时间取 `9.5/ω`,写死上限会在末尾剩几个像素硬跳。点击 / 键盘换档不走这条曲线,直接走 `.dem-knob / .dem-fill` 的 `.3s` CSS 过渡 —— 离散操作平滑到位即可,弹簧尾巴反而会在档位前"顿一下"。
114
114
  3. **点亮等落位**:`shownIndex` 是乐观档位,点下去就变;拖动由 `beginSettle` 在滑块进入目标 1% 时播,点击 / 键盘由 `landByCss` 的 330ms 兜底定时器播,否则光先铺完、滑块才到。
115
115
  4. **墙区的格子首帧也要写 `transform`**(`c.placed`),否则天生就在墙区的那几列永久停在轨道 `(0,0)`,看着像"多了一颗不动的蓝方块"。
@@ -148,6 +148,8 @@ README.md / LICENSE 说明与许可
148
148
 
149
149
  完整记录见 [CHANGELOG.md](./CHANGELOG.md)。
150
150
 
151
+ - **1.2.2** — 修复切换模型后推理滑轨偶尔空白:旧 `reasoningEffort` 先用新模型的档位表校验,失效时回落 `defaultEffort`;目录换代时重新解析并订阅新 store,新目录不再被旧加载节流跳过;只要模型声明了档位,轨道就有兜底落点,不再留下 30px 空占位。另修复拉到最高档后立即切模型、新模型非最高档字符被旧最高档索引误染蓝的问题。
152
+ - **1.2.1** — 修复详情页面板在未注入 DSH 令牌的宿主里选中块纯黑、文字看不清、预览黑底;色带与粒子层改用同一条右端收口,拖拽 `scale / skew` 时不会在滑块右缘露出色轨;粒子引擎的逐帧 `clip-path` 不再把右侧重新放开。
151
153
  - **1.2.0** — 详情页预览接入真实三档轨道与「拖拽动效 / 玻璃材质」开关;无感档位引擎将字符切换提前到视觉落位帧;修复玻璃上缘过厚、旋钮浅色环、轨道底缘硬黑线;修复输入胶囊 Max 染色先蓝后灰再蓝;发布包只保留运行文件。
152
154
  - **1.1.9** — 补充 `screenshots.json` 与 `engines.dsh`,修复插件市场介绍页无截图、宿主要求显示未知。
153
155
  - **1.1.8** — 修复最高档滑块光晕熄灭太直接:进入保持快,退出改为 1.05s 呼吸式衰减;粒子和霓虹同时生效。
package/lib/client.js CHANGED
@@ -91,6 +91,15 @@ window.__ModuleLoader__.load({
91
91
  var SETTLE_OMEGA = 22; /* 1/s,22 ≈ 0.22s 基本落位,再慢就有拖沓感 */
92
92
  /** 判定"点击"还是"拖动"的横向阈值(px):小于它抬起就算点击。 */
93
93
  var TAP_SLOP = 5;
94
+ /**
95
+ * 实心滑块收口向左让出的安全距离(px)。
96
+ *
97
+ * 填充/粒子的竖切原本切在滑块圆心。静止时白色旋钮能盖住,但拖动形变时
98
+ * 旋钮会 scale + skew,右上 / 右下角比填充的竖切口更早收进去,填充的
99
+ * 顶边 / 底边就会在旋钮右侧露出两小截蓝线。把切口往左退 8px,切口永远
100
+ * 藏在旋钮本体下面;空心环需要环心透色,不能退,保持圆心。
101
+ */
102
+ var TAIL_CUT_GUARD = 8;
94
103
  /* 点击 / 键盘换档的视觉落位时间:对话界面保持原来的 300ms;
95
104
  预览卡原来为了早一点改字压到 240ms,但 240ms 落在 `.dem-knob` 的
96
105
  `.3s` 过渡中段,字符先跳、滑块还在走,看起来像"点完又弹一下"。
@@ -635,8 +644,11 @@ window.__ModuleLoader__.load({
635
644
  root.style.setProperty("--dem-knob-w", knobW + "px");
636
645
  root.style.setProperty("--dem-knob-r", (knobW / 2) + "px");
637
646
  /* 霓虹填充用 `calc(100% - inset)` 反推竖切位置。只有细棒退到左缘,
638
- 圆 / 环 / 圆角方 / 胶囊都切圆心 —— 填充必须铺到滑块下方。 */
639
- var tailInset = settings.knobShape === "blade" ? knobW : knobW / 2;
647
+ 圆 / 环 / 圆角方 / 胶囊都切圆心 —— 填充必须铺到滑块下方。
648
+ 实心形状再额外退 TAIL_CUT_GUARD,避免形变时旋钮角上露出填充边。 */
649
+ var tailInset = settings.knobShape === "blade" ? knobW + TAIL_CUT_GUARD
650
+ : settings.knobShape === "ring" ? knobW / 2
651
+ : knobW / 2 + TAIL_CUT_GUARD;
640
652
  root.style.setProperty("--dem-knob-tail-inset", tailInset + "px");
641
653
  root.style.setProperty("--dem-knob-radius", knobRadiusOf(settings));
642
654
  /* 凹槽、填充、粒子层统一用同一条可见带高度(min(轨道高, 滑块高))。
@@ -733,6 +745,8 @@ window.__ModuleLoader__.load({
733
745
  插件若在这里自己画白底,深色主题下就会露出一条白块。 */
734
746
  ".dem-inline{box-sizing:border-box;flex-basis:100%;width:100%;min-width:0;background:transparent;"
735
747
  + "clip-path:inset(-12px 0 -12px 0)}",
748
+ /* 组件返回 null / 档位从有到无时,容器里没有子节点;不要让它继续占一行高度。 */
749
+ ".dem-inline:empty{display:none}",
736
750
  ".dem-track{--dem-slot-bg:var(--dsw-alias-border-l1,color-mix(in srgb,var(--dsw-alias-label-primary,#0f1115) 8%,transparent));"
737
751
  + "position:relative;box-sizing:border-box;height:" + TRACK_HEIGHT + "px;margin:2px " + TRACK_INSET + "px 0;"
738
752
  + "border-radius:999px;"
@@ -808,6 +822,11 @@ window.__ModuleLoader__.load({
808
822
  /* 右端不再是"固定半圆":交给 TAIL_MASK 按滑块内缘裁(见上面的说明)。
809
823
  这里仍保留右端圆角,只是半径跟着滑块走 —— 遮罩没生效时(变量缺失)也能少露一截。 */
810
824
  ".dem-fill{position:absolute;left:0;top:50%;height:var(--dem-fill-h,30px);"
825
+ /* 填充的收口按**自身宽度**反推,不依赖 track 上由 rAF 写入的像素值:
826
+ 首帧 / 重渲染 / 粒子墙还没跑起来时也不会退化成 100% 露出右缘色线。
827
+ inset 已含实心滑块的 TAIL_CUT_GUARD,切在滑块圆心左侧 8px;
828
+ 环的 inset 是半径,仍从环心透色。track 上的同名变量只给粒子裁切层用。 */
829
+ + "--dem-fill-tail-x:calc(100% - var(--dem-knob-tail-inset,15px));"
811
830
  + "transform:translateY(-50%) translateZ(0) scaleX(var(--dem-rail-sx,1)) scaleY(var(--dem-rail-sy,1))"
812
831
  + " skewX(var(--dem-rail-skew,0deg)) skewY(var(--dem-rail-skew-y,0deg));"
813
832
  + "transform-origin:var(--dem-rail-origin-x,var(--dem-rail-base-origin,100%)) 50%;"
@@ -861,7 +880,12 @@ window.__ModuleLoader__.load({
861
880
  粒子层若还是 30px 就会比凹槽顶边高出一截,外轮廓出现阶梯缺口。 */
862
881
  + "-webkit-mask-clip:no-clip;mask-clip:no-clip;"
863
882
  + "-webkit-mask-image:" + HEAD_MASK + ";mask-image:" + HEAD_MASK + ";"
864
- + "clip-path:inset(calc(-1 * var(--dem-scatter-clip,0px)) 0 calc(-1 * var(--dem-scatter-clip,0px)) 0)}",
883
+ /* 右边界再由粒子层**自己**裁一刀:它的宽度就是填充宽度(= 滑块右缘),
884
+ clip-path 相对自身,不依赖 track 上由 rAF 写入的 `--dem-fill-tail-x`。
885
+ 预览首帧、粒子墙尚未 syncTail 时也不会漏出方块;上下仍放行越界,只收右。 */
886
+ + "clip-path:inset(calc(-1 * var(--dem-scatter-clip,0px))"
887
+ + " var(--dem-knob-tail-inset,15px)"
888
+ + " calc(-1 * var(--dem-scatter-clip,0px)) 0)}",
865
889
  /* 裁切层(外形 + 右端):
866
890
  粒子层自己是个矩形,`inset()` 只有轴对齐四条边,不会跟着轨道收圆。
867
891
  这一层恒等于**可见带**,负责两件事:
@@ -935,8 +959,10 @@ window.__ModuleLoader__.load({
935
959
  不能被当成换档过渡播出来。等这一帧画完(data-measured 翻 1)才恢复缓动。 */
936
960
  ".dem-track[data-measured='0'] .dem-knob,.dem-track[data-measured='0'] .dem-fill{transition:none}",
937
961
  /* 目录快照还没给出真实档位时,整条轨道先不显示。否则会先画在 0 档,
938
- 等快照回来再滑到正确档位 —— 就是"每次打开浮层从最左端起步"的另一半根因。 */
939
- ".dem-track[data-ready='0']{opacity:0;pointer-events:none}",
962
+ 等快照回来再滑到正确档位 —— 就是"每次打开浮层从最左端起步"的另一半根因。
963
+ 同时把高度收成 0:只设 opacity 会留下一块 30px 的空白占位,
964
+ 模型切换 / 索引未解析时看起来就是"轨道消失但菜单多了一块洞"。 */
965
+ ".dem-track[data-ready='0']{opacity:0;pointer-events:none;height:0;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0}",
940
966
  ".dem-track[data-dragging='1'] .dem-knob,.dem-track[data-dragging='1'] .dem-fill{transition:none}",
941
967
  /* 吸附阶段位置由 `beginSettle` 的 rAF 逐帧写,再叠一层 CSS transition 就是双重缓动,
942
968
  滑块和填充的插值曲线不同会互相追不上 —— 这一段两边都直接跟数值走。 */
@@ -1092,10 +1118,23 @@ window.__ModuleLoader__.load({
1092
1118
  + "70%{opacity:.85}100%{opacity:0;transform:translate(-50%,-50%) rotate(var(--a)) translateX(var(--r,22px)) scale(.25)}}",
1093
1119
  ".dem-hint{margin-top:6px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#6b7280)}",
1094
1120
  /* ── 插件详情页里的自定义版式面板 ────────────────────────────────
1095
- 所有颜色都吃 DSH 令牌,浅色/深色主题自动适配;只有"强调色预览块"
1096
- 用插件自己的颜色,那是它唯一该显眼的地方。 */
1097
- ".dem-cfg{display:flex;flex-direction:column;gap:14px;padding:2px 0 4px;"
1098
- + "font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary,#0f1115)}",
1121
+ 详情页的宿主不一定带齐 DSH 令牌;不能拿浅色页去赌深色 fallback。
1122
+ 这里把面板用到的别名令牌**局部锁定成固定浅色值**,只作用于
1123
+ `.dem-cfg` 内部,对话轨道和菜单面板完全不受影响。
1124
+ 这样浅色 / 深色主题、不同机器、不同缩放下的配色都一致。 */
1125
+ ".dem-cfg{"
1126
+ + "--dsw-alias-label-primary:#172033;"
1127
+ + "--dsw-alias-label-secondary:#667085;"
1128
+ + "--dsw-alias-card-fill:#ffffff;"
1129
+ + "--dsw-alias-bg-base:#ffffff;"
1130
+ + "--dsw-alias-border-l1:#dfe6f0;"
1131
+ + "--dsw-alias-interactive-bg-hover:#f1f5fa;"
1132
+ + "--dsw-focus-ring-color:#4a84ff;"
1133
+ + "--dsw-focus-ring-width:2px;"
1134
+ + "color-scheme:light;box-sizing:border-box;display:flex;flex-direction:column;gap:14px;"
1135
+ + "padding:14px 12px 12px;border:1px solid #e4eaf3;border-radius:14px;"
1136
+ + "background:#ffffff;box-shadow:0 1px 2px rgba(16,24,40,.04);"
1137
+ + "font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary)}",
1099
1138
  ".dem-cfg-head{display:flex;flex-direction:column;gap:3px}",
1100
1139
  ".dem-cfg-title{font-size:14px;font-weight:600;letter-spacing:.01em}",
1101
1140
  ".dem-cfg-desc{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#6b7280)}",
@@ -1133,9 +1172,9 @@ window.__ModuleLoader__.load({
1133
1172
  + "padding:3px 10px;border-radius:7px;font-size:12px;line-height:18px;"
1134
1173
  + "color:var(--dsw-alias-label-secondary,#6b7280);transition:background .16s ease,color .16s ease}",
1135
1174
  ".dem-cfg-opt:hover{color:var(--dsw-alias-label-primary,#0f1115)}",
1136
- ".dem-cfg-opt[data-on='1']{background:var(--dsw-alias-card-fill,#1a1d24);"
1137
- + "color:var(--dsw-alias-label-primary,#0f1115);font-weight:600;"
1138
- + "box-shadow:0 1px 2px rgba(10,16,30,.16)}",
1175
+ ".dem-cfg-opt[data-on='1']{background:#ffffff;"
1176
+ + "color:#1d4ed8;font-weight:600;"
1177
+ + "box-shadow:0 0 0 1px #c3d7f6,0 1px 2px rgba(15,25,50,.06)}",
1139
1178
  ".dem-cfg-range{appearance:none;width:150px;height:4px;border-radius:2px;outline:none;cursor:pointer;"
1140
1179
  + "background:linear-gradient(90deg,var(--dem-accent,#4a84ff) 0%,"
1141
1180
  + "color-mix(in srgb,var(--dem-accent,#4a84ff) 30%,transparent) 100%)}",
@@ -1147,8 +1186,8 @@ window.__ModuleLoader__.load({
1147
1186
  /* 预览卡片同时当"取景框":开了越界之后粒子会飞出轨道,这一层把溢出裁在卡片圆角里,
1148
1187
  不然方块会糊到下面的「恢复默认」上。 */
1149
1188
  ".dem-cfg-preview{padding:14px 12px;border-radius:12px;overflow:hidden;"
1150
- + "background:var(--dsw-alias-card-fill,#1a1d24);"
1151
- + "border:1px solid var(--dsw-alias-border-l1,rgba(255,255,255,.06))}",
1189
+ + "background:linear-gradient(180deg,#f8fbff 0%,#edf3fb 100%);"
1190
+ + "border:1px solid #d9e4f2;box-shadow:inset 0 1px 0 #ffffff}",
1152
1191
  /* 环心那层乳白玻璃要用 backdrop-filter 虚化底下粒子,否则环里还是能看见方块在动。 */
1153
1192
  ".dem-knob[data-knob-shape='ring']"
1154
1193
  + "{backdrop-filter:blur(4px) saturate(1.15);-webkit-backdrop-filter:blur(4px) saturate(1.15)}",
@@ -1159,7 +1198,7 @@ window.__ModuleLoader__.load({
1159
1198
  + "color:var(--dsw-alias-label-secondary,#6b7280)}",
1160
1199
  ".dem-cfg-preview-hint{font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#6b7280)}",
1161
1200
  ".dem-cfg-preview-stage{position:relative;min-height:38px;padding:4px 0 2px}",
1162
- ".dem-cfg-preview-stage .dem-track{width:100%;margin:0;cursor:grab}",
1201
+ ".dem-cfg-preview-stage .dem-track{--dem-slot-bg:#c8d7e9;width:100%;margin:0;cursor:grab}",
1163
1202
  ".dem-cfg-preview-stage .dem-track:active{cursor:grabbing}",
1164
1203
  ".dem-cfg-preview-caption{display:flex;align-items:baseline;gap:8px;min-height:20px;margin-top:10px}",
1165
1204
  ".dem-cfg-preview-label{font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#6b7280)}",
@@ -1202,20 +1241,37 @@ window.__ModuleLoader__.load({
1202
1241
  error: null,
1203
1242
  });
1204
1243
 
1244
+ /** 当前模型 id:目录正常给字符串;兼容少数把 current.model 给成对象的宿主。 */
1245
+ function modelIdOf(value) {
1246
+ if (typeof value === "string") return value.trim();
1247
+ if (value && typeof value === "object") {
1248
+ if (typeof value.id === "string") return value.id.trim();
1249
+ if (typeof value.value === "string") return value.value.trim();
1250
+ }
1251
+ return "";
1252
+ }
1253
+
1205
1254
  /** 在目录快照里找到当前模型条目(groups[].models[])。 */
1206
1255
  function modelOf(state) {
1207
1256
  var current = state && state.current;
1208
- if (!current || typeof current.provider !== "string" || typeof current.model !== "string") return null;
1257
+ var wanted = modelIdOf(current && current.model);
1258
+ if (!current || typeof current.provider !== "string" || wanted.length === 0) return null;
1209
1259
  var groups = state && Array.isArray(state.groups) ? state.groups : [];
1260
+ var fallback = null;
1210
1261
  for (var i = 0; i < groups.length; i += 1) {
1211
1262
  var group = groups[i];
1212
- if (!group || group.id !== current.provider) continue;
1213
- var models = Array.isArray(group.models) ? group.models : [];
1263
+ if (!group || !Array.isArray(group.models)) continue;
1264
+ var models = group.models;
1214
1265
  for (var j = 0; j < models.length; j += 1) {
1215
- if (models[j] && models[j].id === current.model) return models[j];
1266
+ var model = models[j];
1267
+ if (!model || model.id !== wanted) continue;
1268
+ /* provider 目录项正常时优先取同一分组;目录正在重建、
1269
+ 分组 id 暂时对不上时,至少按模型 id 找到唯一候选。 */
1270
+ if (group.id === current.provider) return model;
1271
+ if (fallback === null) fallback = model;
1216
1272
  }
1217
1273
  }
1218
- return null;
1274
+ return fallback;
1219
1275
  }
1220
1276
 
1221
1277
  /**
@@ -1228,29 +1284,68 @@ window.__ModuleLoader__.load({
1228
1284
  var out = [];
1229
1285
  for (var i = 0; i < efforts.length; i += 1) {
1230
1286
  var effort = efforts[i];
1287
+ /* 目录里通常是 { id, name };少数适配器会直接给字符串。
1288
+ 两种都归一成同一种档位对象,避免"有档位但读不出来"。 */
1289
+ if (typeof effort === "string" && effort.trim().length > 0) {
1290
+ out.push({ id: effort.trim(), name: effort.trim() });
1291
+ continue;
1292
+ }
1231
1293
  if (!effort || typeof effort.id !== "string" || effort.id.length === 0) continue;
1232
1294
  out.push({
1233
1295
  id: effort.id,
1234
- name: typeof effort.name === "string" && effort.name.length > 0 ? effort.name : effort.id,
1296
+ name: typeof effort.name === "string" && effort.name.length > 0
1297
+ ? effort.name
1298
+ : (typeof effort.label === "string" && effort.label.length > 0 ? effort.label : effort.id),
1235
1299
  });
1236
1300
  }
1237
1301
  return out;
1238
1302
  }
1239
1303
 
1240
- /** 当前**生效**的档位 id:显式设置优先,否则回落到模型的 defaultEffort。 */
1304
+ function effortValueOf(value) {
1305
+ if (typeof value === "string") return value.trim();
1306
+ if (value && typeof value === "object") {
1307
+ if (typeof value.id === "string") return value.id.trim();
1308
+ if (typeof value.value === "string") return value.value.trim();
1309
+ if (typeof value.name === "string") return value.name.trim();
1310
+ }
1311
+ return "";
1312
+ }
1313
+
1314
+ /** 当前**生效**的档位 id:显式设置优先,否则回落到模型的 defaultEffort。
1315
+ DSH 会把"跟随模型默认"写成 `default` / `auto`,这不是一个真实档位 id;
1316
+ 如果直接拿它去 levels 里找下标,就会得到 -1,轨道进入"未就绪"状态并留下
1317
+ 一块空白占位。这里先把这类占位值当作"未显式设置",再落回 defaultEffort。 */
1241
1318
  function effectiveEffortId(state) {
1242
1319
  var current = state && state.current;
1243
- if (current && typeof current.reasoningEffort === "string" && current.reasoningEffort.length > 0) {
1244
- return current.reasoningEffort;
1245
- }
1320
+ var explicit = effortValueOf(current && current.reasoningEffort);
1246
1321
  var model = modelOf(state);
1247
- var fallback = model && model.reasoning && model.reasoning.defaultEffort;
1248
- return typeof fallback === "string" && fallback.length > 0 ? fallback : null;
1322
+ var levels = levelsOf(state);
1323
+ var explicitIsLevel = indexOfLevel(levels, explicit) >= 0;
1324
+ /* `none` 也可能是模型真实声明的档位;只有它不在当前档位表里时,
1325
+ 才把 default / auto / none 当成"跟随默认"的占位值。 */
1326
+ var placeholder = /^(default|auto|none)$/i.test(explicit) && !explicitIsLevel;
1327
+ var fallback = effortValueOf(model && model.reasoning && model.reasoning.defaultEffort);
1328
+ if (!placeholder && explicit.length > 0) {
1329
+ /* 切模型时 current.reasoningEffort 可能还留着上一个模型的 id。
1330
+ 这个 id 在新模型的 efforts 里不存在时不能直接拿去定位,
1331
+ 否则会得到 -1,轨道再次变成空白;优先回到新模型的默认档。 */
1332
+ if (levels.length === 0 || explicitIsLevel) return explicit;
1333
+ }
1334
+ if (fallback.length > 0) return fallback;
1335
+ return null;
1249
1336
  }
1250
1337
 
1251
1338
  function indexOfLevel(levels, id) {
1252
1339
  if (typeof id !== "string") return -1;
1253
- for (var i = 0; i < levels.length; i += 1) if (levels[i].id === id) return i;
1340
+ var needle = id.trim().toLowerCase();
1341
+ if (!needle) return -1;
1342
+ for (var i = 0; i < levels.length; i += 1) {
1343
+ var level = levels[i];
1344
+ if (!level) continue;
1345
+ var levelId = typeof level.id === "string" ? level.id.trim().toLowerCase() : "";
1346
+ var levelName = typeof level.name === "string" ? level.name.trim().toLowerCase() : "";
1347
+ if (levelId === needle || levelName === needle) return i;
1348
+ }
1254
1349
  return -1;
1255
1350
  }
1256
1351
 
@@ -1261,12 +1356,42 @@ window.__ModuleLoader__.load({
1261
1356
  if (!row || typeof document === "undefined" || typeof document.createTreeWalker !== "function") return -1;
1262
1357
  var walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT, null);
1263
1358
  var node;
1264
- while ((node = walker.nextNode())) {
1265
- var text = (node.nodeValue || "").trim();
1266
- if (!text) continue;
1267
- for (var i = 0; i < levels.length; i += 1) {
1268
- if (levels[i] && levels[i].name === text) return i;
1359
+ function normalize(value) {
1360
+ return (value || "").replace(/[\s\u00a0\u200b]+/g, " ").trim().toLowerCase();
1361
+ }
1362
+ function matches(value) {
1363
+ var text = normalize(value);
1364
+ if (!text) return -1;
1365
+ var candidates = [text];
1366
+ /* 有些宿主把标题和值渲染在同一个文本节点里:`推理等级 Default`
1367
+ 或 `Effort: Default`。去掉标题前缀后再做一次精确匹配。 */
1368
+ for (var li = 0; li < EFFORT_ROW_LABELS.length; li += 1) {
1369
+ var label = normalize(EFFORT_ROW_LABELS[li]);
1370
+ if (text.indexOf(label) === 0) {
1371
+ candidates.push(normalize(text.slice(label.length).replace(/^[::·\-—\s]+/, "")));
1372
+ }
1269
1373
  }
1374
+ /* 值后面常跟展开箭头 / 分隔符;把整段拆成独立 token 再匹配,
1375
+ 避免 `Max` 被 `Maximum` 这类更长文案误命中。 */
1376
+ var pieces = text.split(/[^a-z0-9\u4e00-\u9fff]+/i);
1377
+ for (var pi = 0; pi < pieces.length; pi += 1) {
1378
+ if (pieces[pi]) candidates.push(pieces[pi]);
1379
+ }
1380
+ for (var ci = 0; ci < candidates.length; ci += 1) {
1381
+ if (!candidates[ci]) continue;
1382
+ for (var i = 0; i < levels.length; i += 1) {
1383
+ var level = levels[i];
1384
+ if (!level) continue;
1385
+ var id = normalize(level.id);
1386
+ var name = normalize(level.name);
1387
+ if ((id && id === candidates[ci]) || (name && name === candidates[ci])) return i;
1388
+ }
1389
+ }
1390
+ return -1;
1391
+ }
1392
+ while ((node = walker.nextNode())) {
1393
+ var found = matches(node.nodeValue);
1394
+ if (found >= 0) return found;
1270
1395
  }
1271
1396
  return -1;
1272
1397
  }
@@ -1561,18 +1686,20 @@ window.__ModuleLoader__.load({
1561
1686
  var escStep = 1 - Math.exp(-Math.min(50, dt) / 1000 / escTau);
1562
1687
  escAmt += (escTarget - escAmt) * escStep;
1563
1688
  if (Math.abs(escTarget - escAmt) < 0.002) escAmt = escTarget;
1564
- /* 裁剪每帧由状态直接写死(不依赖变量继承 / clip-path 解析)。
1689
+ /* 裁剪每帧由状态直接写死;横向右边界与填充共用同一个
1690
+ `--dem-knob-tail-inset`,避免 JS 这层把色带的收口重新放开。
1565
1691
  判据用 `escAmt` 而不是 `scattered`:退档时那 0.6s 还在往回飞,
1566
1692
  盒子得先开着,否则收回去的半路会被 30px 的盒子齐着切掉。
1567
1693
  **必须排在 `escAmt` 更新之后**:冷启动那一帧强度已经是 0.25 了,
1568
1694
  放到前面就会出现"首帧被裁、第二帧才张开"的闪一下。 */
1569
1695
  var openBox = escAmt > 0.01;
1570
1696
  host.style.overflow = openBox ? "visible" : "hidden";
1571
- /* 静止态裁到粒子层盒子;不做单侧收边(只收上边会把毛边赶到下边)。
1572
- 裁切层恒为 visible —— 越界动画需要方块飞出上下边,不能在这里合上。 */
1697
+ /* 粒子层宽度 = 填充宽度 = 滑块右缘;右侧 inset 用和填充完全相同的
1698
+ `--dem-knob-tail-inset`,两层共用一条收口线,滑块与色轨才是一体。
1699
+ 纵向按 openBox 放行/收拢,越界动画仍能飞出上下边。 */
1573
1700
  host.style.clipPath = openBox
1574
- ? "inset(-420px 0px -420px 0px)"
1575
- : "inset(0px 0px 0px 0px)";
1701
+ ? "inset(-420px var(--dem-knob-tail-inset,15px) -420px 0px)"
1702
+ : "inset(0px var(--dem-knob-tail-inset,15px) 0px 0px)";
1576
1703
  waveT += dt / 1000;
1577
1704
  /* 设计稿:speedBase = (0.0022 + lv*0.040) * (1 + burstPower*1.6),每帧固定增量,
1578
1705
  burstPower 每帧衰减 0.05。**不做 dt 归一** —— 设计稿就是按帧走的,144Hz 屏上
@@ -2106,7 +2233,10 @@ window.__ModuleLoader__.load({
2106
2233
  /* 圆心吸附到**设备像素**:遮罩边缘落在半个物理像素上时,相邻两帧会在
2107
2234
  1px 之间来回跳,看起来就是边缘在"爬"(蚂蚁线)。吸附后位置稳定。 */
2108
2235
  var dpr = Math.min(3, Math.max(1, window.devicePixelRatio || 1));
2109
- var cutX = Math.max(0, g.cx - (g.cut || 0));
2236
+ /* 实心滑块把切口再往左退 8px:拖动 skew/scale 时,切口会先被
2237
+ 旋钮本体盖住,右侧不会露出填充的顶边 / 底边。空心环仍切圆心。 */
2238
+ var guard = liveSettings.knobShape === "ring" ? 0 : TAIL_CUT_GUARD;
2239
+ var cutX = Math.max(0, g.cx - (g.cut || 0) - guard);
2110
2240
  var cx = (Math.round(cutX * dpr) / dpr).toFixed(2) + "px";
2111
2241
  var r = (Math.round(fillTailRadiusOf(liveSettings) * 2) / 2).toFixed(2) + "px";
2112
2242
  if (cx !== tailXRef.current) {
@@ -2868,7 +2998,12 @@ window.__ModuleLoader__.load({
2868
2998
  左端锚轨道左缘、右端锚这里。玻璃和色带共用同一个变量。 */
2869
2999
  "--dem-rail-base-origin": geom,
2870
3000
  };
2871
- if (!softParticleEdge) trackStyle["--dem-fill-tail-x"] = knobPos;
3001
+ if (!softParticleEdge) {
3002
+ /* 首帧也按实心滑块的收口让位,避免挂载第一帧就露出右缘色线。 */
3003
+ var initialGuard = liveSettings.knobShape === "ring" ? 0 : TAIL_CUT_GUARD;
3004
+ var initialCut = Math.max(0, knobPx - (liveSettings.knobShape === "blade" ? knobW / 2 : 0) - initialGuard);
3005
+ trackStyle["--dem-fill-tail-x"] = initialCut.toFixed(3) + "px";
3006
+ }
2872
3007
 
2873
3008
  return React.createElement(
2874
3009
  React.Fragment,
@@ -2947,10 +3082,12 @@ window.__ModuleLoader__.load({
2947
3082
  function createAccess(ctx, sessionId) {
2948
3083
  var listeners = new Set();
2949
3084
  var directory = null;
3085
+ var activeStore = null;
2950
3086
  var unsubscribe = null;
2951
3087
  var last = EMPTY_SNAPSHOT;
2952
3088
  var retryIndex = 0;
2953
3089
  var retryTimer = null;
3090
+ var notifyTimer = null;
2954
3091
  var closed = false;
2955
3092
  var lastLoadAt = 0;
2956
3093
 
@@ -2962,6 +3099,16 @@ window.__ModuleLoader__.load({
2962
3099
  }
2963
3100
  }
2964
3101
 
3102
+ /* 目录换代本身也要通知 React:新 store 可能已经带着完整快照,
3103
+ 如果只依赖它后续的 subscribe 回调,轨道会一直停在旧档位 / 空白占位上。 */
3104
+ function scheduleNotify() {
3105
+ if (closed || notifyTimer !== null) return;
3106
+ notifyTimer = window.setTimeout(function () {
3107
+ notifyTimer = null;
3108
+ notify();
3109
+ }, 0);
3110
+ }
3111
+
2965
3112
  function scheduleRetry() {
2966
3113
  if (closed || retryTimer !== null || retryIndex >= RETRY_DELAYS.length) return;
2967
3114
  var delay = RETRY_DELAYS[retryIndex];
@@ -2982,23 +3129,38 @@ window.__ModuleLoader__.load({
2982
3129
  fresh = null;
2983
3130
  }
2984
3131
  if (!fresh || !fresh.store || typeof fresh.store.getSnapshot !== "function") fresh = null;
2985
- if (fresh === directory) return directory;
3132
+ /* 解析失败时保留旧目录,别把已经挂上的桥拆掉;下次读写会再试。 */
3133
+ if (fresh === null) return directory;
3134
+ if (fresh === directory && activeStore === fresh.store) return directory;
3135
+ /* 有些宿主在换模型代时只换 directory 包装对象、store 还是同一个;
3136
+ 这种情况不要重新订阅、也不要清空快照,否则会白闪一下空白。 */
3137
+ if (directory !== null && fresh.store === activeStore) {
3138
+ directory = fresh;
3139
+ return directory;
3140
+ }
2986
3141
  if (unsubscribe !== null) {
2987
3142
  try { unsubscribe(); } catch (err) { /* 退订失败不影响新订阅 */ }
2988
3143
  unsubscribe = null;
2989
3144
  }
2990
3145
  directory = fresh;
2991
- if (directory !== null) {
2992
- retryIndex = 0;
2993
- try {
2994
- unsubscribe = typeof directory.store.subscribe === "function"
2995
- ? directory.store.subscribe(notify)
2996
- : null;
2997
- } catch (err) {
2998
- unsubscribe = null;
2999
- }
3000
- kickLoad();
3146
+ activeStore = fresh.store;
3147
+ /* 换代后旧快照里的 current / groups 不再可信;先清空,
3148
+ 等新 store 的 load 回调回来再重新判定档位和轨道。 */
3149
+ last = EMPTY_SNAPSHOT;
3150
+ retryIndex = 0;
3151
+ /* 不要沿用旧目录的加载节流时间:刚打开菜单就切模型时,
3152
+ 旧目录的 load 可能还在 400ms 窗口内,新目录会被误跳过,
3153
+ 一直停在空快照上。 */
3154
+ lastLoadAt = 0;
3155
+ try {
3156
+ unsubscribe = typeof directory.store.subscribe === "function"
3157
+ ? directory.store.subscribe(notify)
3158
+ : null;
3159
+ } catch (err) {
3160
+ unsubscribe = null;
3001
3161
  }
3162
+ kickLoad();
3163
+ scheduleNotify();
3002
3164
  return directory;
3003
3165
  }
3004
3166
 
@@ -3017,16 +3179,18 @@ window.__ModuleLoader__.load({
3017
3179
  /** 同一份快照对象身份必须稳定,否则 useSyncExternalStore 会判定"每帧都变"。 */
3018
3180
  function readStable() {
3019
3181
  if (closed) return EMPTY_SNAPSHOT;
3020
- if (directory === null) {
3021
- resolve();
3022
- if (directory === null) scheduleRetry();
3023
- }
3182
+ /* 每次读都重新解析:换模型代 / 连接重置后目录实例会换,
3183
+ 只认第一次拿到的旧目录会把整条轨道留在旧模型上或直接空掉。 */
3184
+ resolve();
3185
+ if (directory === null) scheduleRetry();
3024
3186
  if (directory !== null) {
3025
3187
  try {
3026
3188
  var value = directory.store.getSnapshot();
3027
3189
  if (value && typeof value === "object") {
3028
3190
  if (last === EMPTY_SNAPSHOT
3029
- || value.current !== last.current
3191
+ || (value.current && value.current.provider) !== (last.current && last.current.provider)
3192
+ || modelIdOf(value.current && value.current.model) !== modelIdOf(last.current && last.current.model)
3193
+ || effortValueOf(value.current && value.current.reasoningEffort) !== effortValueOf(last.current && last.current.reasoningEffort)
3030
3194
  || value.groups !== last.groups
3031
3195
  || value.status !== last.status
3032
3196
  || value.error !== last.error) {
@@ -3044,25 +3208,25 @@ window.__ModuleLoader__.load({
3044
3208
  getSnapshot: readStable,
3045
3209
  subscribe: function (listener) {
3046
3210
  if (closed) return function () {};
3211
+ resolve();
3212
+ if (directory === null) scheduleRetry();
3047
3213
  listeners.add(listener);
3048
- if (directory === null) {
3049
- resolve();
3050
- if (directory === null) scheduleRetry();
3051
- }
3052
3214
  return function () { listeners.delete(listener); };
3053
3215
  },
3054
- directory: function () { return directory; },
3216
+ directory: function () { return resolve(); },
3055
3217
  select: function (payload) {
3056
- if (directory === null) resolve();
3218
+ resolve();
3057
3219
  if (directory === null || typeof directory.select !== "function") return null;
3058
3220
  return directory.select(payload);
3059
3221
  },
3060
3222
  destroy: function () {
3061
3223
  closed = true;
3062
3224
  if (retryTimer !== null) { window.clearTimeout(retryTimer); retryTimer = null; }
3225
+ if (notifyTimer !== null) { window.clearTimeout(notifyTimer); notifyTimer = null; }
3063
3226
  if (unsubscribe !== null) { try { unsubscribe(); } catch (err) { /* 忽略 */ } unsubscribe = null; }
3064
3227
  listeners.clear();
3065
3228
  directory = null;
3229
+ activeStore = null;
3066
3230
  },
3067
3231
  };
3068
3232
  }
@@ -3092,12 +3256,22 @@ window.__ModuleLoader__.load({
3092
3256
  }
3093
3257
 
3094
3258
  function teardownEntry(entry) {
3095
- if (entry.row === null) return;
3259
+ if (!entry) return;
3260
+ var removed = false;
3261
+ /* 即使 row 已经在宿主重建时被换掉,也要把旧容器从它原来的父节点摘掉;
3262
+ 否则会留下一个空 .dem-inline,行高仍是被 mountEntry 加高过的 8px 内边距。 */
3096
3263
  try {
3097
3264
  if (entry.container !== null && entry.container.parentNode) {
3098
3265
  entry.container.parentNode.removeChild(entry.container);
3266
+ removed = true;
3099
3267
  }
3100
3268
  } catch (err) { /* 容器可能已被官方一起销毁 */ }
3269
+ if (entry.row === null) {
3270
+ entry.container = null;
3271
+ entry.setContainer(null);
3272
+ if (removed) bumpResize();
3273
+ return;
3274
+ }
3101
3275
  try {
3102
3276
  entry.row.style.height = entry.prevStyle.height;
3103
3277
  entry.row.style.flexWrap = entry.prevStyle.flexWrap;
@@ -3125,6 +3299,7 @@ window.__ModuleLoader__.load({
3125
3299
  ? indexOverride
3126
3300
  : indexOfLevel(levels, effectiveEffortId(snapshot));
3127
3301
  var hot = liveIndex === levels.length - 1;
3302
+ var hotName = hot && levels[levels.length - 1] ? levels[levels.length - 1].name : "";
3128
3303
  /* 档位名来自模型目录,内容不可控;用无原型表,避免名字恰好是
3129
3304
  "__proto__" / "constructor" 时污染原型、把无关文字也染色。 */
3130
3305
  var byName = Object.create(null);
@@ -3139,7 +3314,9 @@ window.__ModuleLoader__.load({
3139
3314
  if (textInsideEditor(node, root)) continue;
3140
3315
  var host = node.parentElement;
3141
3316
  if (!host) continue;
3142
- if (hot) host.style.setProperty("color", tintColorOf(), "important");
3317
+ /* 只给**当前最高档**那一段文字上蓝;不能把卡片里其它档位名
3318
+ (例如刚切到新模型后行里显示的 Medium)也一起染蓝。 */
3319
+ if (hot && hotName && text === hotName) host.style.setProperty("color", tintColorOf(), "important");
3143
3320
  else if (host.style.getPropertyValue("color")) host.style.removeProperty("color");
3144
3321
  }
3145
3322
  }
@@ -3411,6 +3588,7 @@ window.__ModuleLoader__.load({
3411
3588
 
3412
3589
  var levels = levelsOf(state);
3413
3590
  var liveIndex = indexOfLevel(levels, effectiveEffortId(state));
3591
+ var currentModelId = modelIdOf(state && state.current && state.current.model);
3414
3592
 
3415
3593
  /* 容器裁到宿主浮层:形变/粒子只能在菜单面板里出现,不能顶到面板外。 */
3416
3594
  React.useEffect(function () {
@@ -3432,9 +3610,16 @@ window.__ModuleLoader__.load({
3432
3610
  var _draft = React.useState(null);
3433
3611
  var draft = _draft[0];
3434
3612
  var setDraft = _draft[1];
3613
+ /* 模型切换的当帧不能继续使用上一代 draft:否则新模型的首帧会先
3614
+ 按旧模型的 Max 画一遍,等 effect 清掉 draft 才回退,看起来就是
3615
+ 非最高档字符先蓝一下。等 modelIdRef 跟上后再恢复 draft。 */
3616
+ var sameModelAsPrevious = entry.modelIdRef.current === null
3617
+ || entry.modelIdRef.current === currentModelId;
3618
+ var draftForView = sameModelAsPrevious ? draft : null;
3435
3619
  /* 给 SlotComponent 的胶囊观察器读:等待宿主回写的窗口里,
3436
3620
  颜色必须跟 draft 目标走,不能读尚未更新的 snapshot。 */
3437
- entry.displayIndexRef.current = draft !== null ? draft : (liveIndex >= 0 ? liveIndex : null);
3621
+ entry.displayIndexRef.current = draftForView !== null ? draftForView : (liveIndex >= 0 ? liveIndex : null);
3622
+ entry.displayModelIdRef.current = currentModelId;
3438
3623
 
3439
3624
  var _hint = React.useState(null);
3440
3625
  var hint = _hint[0];
@@ -3446,6 +3631,41 @@ window.__ModuleLoader__.load({
3446
3631
  var flushIdleRef = React.useRef(null);
3447
3632
  var labelGuardRef = React.useRef(null);
3448
3633
 
3634
+ /* 模型换代时清掉上一代留下的乐观 draft / 待写档位:
3635
+ 否则旧模型的索引会短暂盖在新模型的轨道上,甚至把旧档位写进新模型。 */
3636
+ React.useEffect(function () {
3637
+ var previous = entry.modelIdRef.current;
3638
+ if (previous === null) {
3639
+ entry.modelIdRef.current = currentModelId;
3640
+ return;
3641
+ }
3642
+ if (previous === currentModelId) return;
3643
+ entry.modelIdRef.current = currentModelId;
3644
+ /* 旧模型的最高档索引立即作废;下一次绘制由快照的 liveIndex 决定。 */
3645
+ entry.displayIndexRef.current = null;
3646
+ entry.displayModelIdRef.current = currentModelId;
3647
+ var pending = pendingRef.current;
3648
+ pending.levelId = null;
3649
+ pending.inFlight = false;
3650
+ pending.seq += 1;
3651
+ pending.landed = false;
3652
+ pending.effortless = false;
3653
+ if (deadlineRef.current !== null) {
3654
+ window.clearTimeout(deadlineRef.current);
3655
+ deadlineRef.current = null;
3656
+ }
3657
+ if (flushTimerRef.current !== null) {
3658
+ window.clearTimeout(flushTimerRef.current);
3659
+ flushTimerRef.current = null;
3660
+ }
3661
+ if (flushIdleRef.current !== null && typeof window.cancelIdleCallback === "function") {
3662
+ window.cancelIdleCallback(flushIdleRef.current);
3663
+ flushIdleRef.current = null;
3664
+ }
3665
+ setDraft(null);
3666
+ setHint(null);
3667
+ }, [currentModelId, entry]);
3668
+
3449
3669
  function cancelPendingPick() {
3450
3670
  if (flushTimerRef.current !== null) {
3451
3671
  window.clearTimeout(flushTimerRef.current);
@@ -3467,17 +3687,17 @@ window.__ModuleLoader__.load({
3467
3687
  这里负责在组件提交后 / 回滚时再校准)。draft 清空 = 宿主已经接上
3468
3688
  真实档位,或写入失败要回滚,都用 liveIndex 重画。 */
3469
3689
  React.useEffect(function () {
3470
- var shown = draft !== null ? draft : liveIndex;
3690
+ var shown = draftForView !== null ? draftForView : liveIndex;
3471
3691
  paintEffortEverywhere(entry, levels, shown);
3472
- }, [draft, liveIndex, levels, entry]);
3692
+ }, [draftForView, liveIndex, levels, entry]);
3473
3693
 
3474
3694
  /* 官方行 / 输入胶囊可能在等待宿主回写的窗口里被 React 重渲染回旧字符;
3475
3695
  在 draft 未落库前守住目标文字,MutationObserver 的回调在 paint 前跑,
3476
3696
  所以画面不会闪回旧档位。paint 是幂等的,不会自激。 */
3477
3697
  React.useEffect(function () {
3478
- if (draft === null) return undefined;
3698
+ if (draftForView === null) return undefined;
3479
3699
  if (typeof MutationObserver !== "function") return undefined;
3480
- var target = draft;
3700
+ var target = draftForView;
3481
3701
  var roots = [];
3482
3702
  if (entry.row) roots.push(entry.row);
3483
3703
  if (entry.card && entry.card !== entry.row) {
@@ -3519,7 +3739,7 @@ window.__ModuleLoader__.load({
3519
3739
  }
3520
3740
  if (labelGuardRef.current === guards) labelGuardRef.current = null;
3521
3741
  };
3522
- }, [draft, levels, entry]);
3742
+ }, [draftForView, levels, entry]);
3523
3743
 
3524
3744
  React.useEffect(function () {
3525
3745
  return function () {
@@ -3566,7 +3786,8 @@ window.__ModuleLoader__.load({
3566
3786
 
3567
3787
  var snapshot = access.getSnapshot();
3568
3788
  var current = snapshot && snapshot.current;
3569
- if (!current || typeof current.provider !== "string" || typeof current.model !== "string") {
3789
+ var currentModel = modelIdOf(current && current.model);
3790
+ if (!current || typeof current.provider !== "string" || currentModel.length === 0) {
3570
3791
  setDraft(null);
3571
3792
  setHint("模型目录尚未就绪");
3572
3793
  return;
@@ -3575,7 +3796,7 @@ window.__ModuleLoader__.load({
3575
3796
 
3576
3797
  var result;
3577
3798
  try {
3578
- result = access.select({ provider: current.provider, model: current.model, reasoningEffort: levelId });
3799
+ result = access.select({ provider: current.provider, model: currentModel, reasoningEffort: levelId });
3579
3800
  } catch (err) {
3580
3801
  result = Promise.reject(err);
3581
3802
  }
@@ -3627,7 +3848,7 @@ window.__ModuleLoader__.load({
3627
3848
  pending.inFlight = true; /* 兜底写也是一笔宿主写,别让新档位插进来抢 */
3628
3849
  var plain = null;
3629
3850
  try {
3630
- plain = access.select({ provider: current.provider, model: current.model });
3851
+ plain = access.select({ provider: current.provider, model: currentModel });
3631
3852
  } catch (err2) {
3632
3853
  plain = Promise.reject(err2);
3633
3854
  }
@@ -3746,11 +3967,18 @@ window.__ModuleLoader__.load({
3746
3967
  if (levels.length === 0) return null;
3747
3968
 
3748
3969
  /* 目录快照未就绪时,先读官方行里的当前档位名;它通常比快照更早可用。
3749
- 两者都没有才隐藏轨道,等快照回来,绝不先画在 0 档。 */
3970
+ 两者都没有时先落在第 1 档,等快照回来再纠正;绝不先画在 0 档后消失。 */
3750
3971
  var rowIndex = rowEffortIndex(entry.row, levels);
3751
3972
  var seedIndex = liveIndex >= 0 ? liveIndex : rowIndex;
3752
- var indexReady = draft !== null || seedIndex >= 0;
3753
- var displayIndex = draft !== null ? draft : (seedIndex >= 0 ? seedIndex : 0);
3973
+ /* 最后一道兜底:只要这个模型确实声明了档位,就不能让轨道因为
3974
+ `current.reasoningEffort` / 行文案暂时解析不出来而完全消失。
3975
+ 正常路径仍优先用 liveIndex 或官方行里的真实档位名;两者都没有时
3976
+ 才先落在第 1 档,等宿主快照回来再由上面的优先级纠正。 */
3977
+ if (seedIndex < 0 && levels.length > 0) seedIndex = 0;
3978
+ var indexReady = levels.length > 0;
3979
+ var displayIndex = draftForView !== null ? draftForView : seedIndex;
3980
+ entry.displayIndexRef.current = draftForView !== null ? draftForView : seedIndex;
3981
+ entry.displayModelIdRef.current = currentModelId;
3754
3982
 
3755
3983
  return React.createElement(EffortTrack, {
3756
3984
  levels: levels,
@@ -3800,6 +4028,11 @@ window.__ModuleLoader__.load({
3800
4028
  setContainer: setContainer,
3801
4029
  /* 当前应染蓝的档位索引;由 ConnectedTrack 在每次渲染 / 落位时更新。 */
3802
4030
  displayIndexRef: { current: null },
4031
+ /* 这个索引属于哪个模型;模型切换后必须作废旧索引,否则会把
4032
+ 新模型的非最高档字符继续按旧模型的最高档染蓝。 */
4033
+ displayModelIdRef: { current: null },
4034
+ /* 上一次渲染时的模型 id,用于换代时清掉旧 draft / 待写档位。 */
4035
+ modelIdRef: { current: null },
3803
4036
  };
3804
4037
  entryRef.current = entry;
3805
4038
  composers.set(card, entry);
@@ -3820,7 +4053,13 @@ window.__ModuleLoader__.load({
3820
4053
  等待宿主回写的窗口里读 displayIndexRef,不能读尚未更新的 snapshot,
3821
4054
  否则会把刚落位的蓝先擦回灰。 */
3822
4055
  var snap = entry.access.getSnapshot();
3823
- var idx = entry.displayIndexRef.current;
4056
+ var snapModelId = modelIdOf(snap && snap.current && snap.current.model);
4057
+ /* 乐观索引必须和当前快照属于同一个模型;否则用户刚把模型 A 拉到
4058
+ 最高档就切换模型 B,这里还会拿 A 的最高档索引去染 B 的档位字符,
4059
+ B 的非最高档就会被误染成蓝色。模型不一致时强制回到快照真实档位。 */
4060
+ var idx = entry.displayModelIdRef.current === snapModelId
4061
+ ? entry.displayIndexRef.current
4062
+ : null;
3824
4063
  tintEffortText(card, snap, typeof idx === "number" ? idx : undefined);
3825
4064
  }
3826
4065
  function queueTint(records) {
@@ -4381,6 +4620,10 @@ window.__ModuleLoader__.load({
4381
4620
  exports.__internals = {
4382
4621
  levelsOf: levelsOf,
4383
4622
  effectiveEffortId: effectiveEffortId,
4623
+ indexOfLevel: indexOfLevel,
4624
+ rowEffortIndex: rowEffortIndex,
4625
+ tintEffortText: tintEffortText,
4626
+ createAccess: createAccess,
4384
4627
  pctOfIndex: pctOfIndex,
4385
4628
  indexOfPct: indexOfPct,
4386
4629
  ampOf: ampOf,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-effort-mosaic",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "把 DSH 模型菜单里的推理等级档位换成一条滑轨:马赛克粒子墙(右侧静止、越往左越散)或 霓虹(蓝轨道 + 最高档蓝紫擦除渐变)。两套风格可切换 / A reasoning-effort track for DeepSeek Harness, with a pixel-mosaic style and a 霓虹变体",
5
5
  "icon": "./icon.svg",
6
6
  "license": "MIT",