dsh-codex-model-effort-ui 1.1.7 → 1.1.9

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.
@@ -0,0 +1,243 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-codex-model-effort-ui',
3
+ chunk: 'client.views.js',
4
+ factory(require) {
5
+ var module = { exports: {} };
6
+ var exports = module.exports;
7
+ function renderModelsView(ctx) {
8
+ const P = ctx.P, h = ctx.h, icon = ctx.icon, t = ctx.t, fill = ctx.fill;
9
+ const effortApi = ctx.effortApi;
10
+
11
+ /* 第 1 页 —— 提供方(每行 provider 名 + 当前组蓝点 + 雪弗龙) */
12
+ const providerNodes = ctx.groups.map(g => {
13
+ const isCurrent = ctx.selection?.provider === g.id;
14
+ return h('button', {
15
+ key: `p-${g.id}`,
16
+ className: `${P}-row`,
17
+ type: 'button',
18
+ 'aria-expanded': ctx.view === 2 && ctx.subProvider === g.id,
19
+ onClick: () => ctx.enterProvider(g.id)
20
+ },
21
+ h('span', { className: `${P}-rowName` }, g.name),
22
+ h('span', { className: `${P}-rowDot`, hidden: !isCurrent, 'aria-hidden': true }),
23
+ icon('chevron', `${P}-rowChev`));
24
+ });
25
+
26
+ /* 失败会被展示出来,而不是被吞掉:接管座位之后,出厂选择器的按 */
27
+ const noticeNodes = [];
28
+ if (ctx.noticeRows > 0) {
29
+ (ctx.state.failures || []).slice(0, 4).forEach((f, i) => {
30
+ noticeNodes.push(h('div', {
31
+ key: `f-${i}`, className: `${P}-failure`,
32
+ title: f.message
33
+ }, fill(t('loadFailed'), { name: f.name, message: f.message })));
34
+ });
35
+ } else if (ctx.groups.length === 0) {
36
+ noticeNodes.push(h('div', { key: 'empty', className: `${P}-empty` },
37
+ ctx.state.status === 'loading' ? t('loading') : t('empty')));
38
+ }
39
+
40
+ /* 第 2 页 —— 所选提供方的模型(带" N 档 "徽标) */
41
+ const modelNodes = ctx.providerModels.map(m => {
42
+ const entry = ctx.flatModels.findIndex(x => x.model.id === m.id);
43
+ const selected = ctx.selection?.provider === ctx.activeProvider?.id && ctx.selection?.model === m.id;
44
+ const levelCount = effortApi.sortEfforts(m.reasoning?.efforts).length;
45
+ const levelText = n => fill(t(n === 1 ? 'levelOne' : 'levels'), { count: n });
46
+ return h('button', {
47
+ key: `m-${m.id}`,
48
+ className: `${P}-model${selected ? ' sel' : ''}${levelCount ? '' : ' na'}${entry === ctx.highlight ? ' hovered' : ''}`,
49
+ type: 'button',
50
+ role: 'menuitemradio',
51
+ 'aria-checked': selected,
52
+ disabled: ctx.busy,
53
+ title: levelCount ? levelText(levelCount) : t('noLevels'),
54
+ onMouseEnter: () => ctx.setHighlight(entry),
55
+ onClick: () => ctx.chooseModel(ctx.activeProvider.id, m)
56
+ },
57
+ h('span', { className: `${P}-modelName` },
58
+ h('span', null, m.name || m.id),
59
+ h('span', { className: `${P}-cnt` }, levelCount ? levelText(levelCount) : t('noLevelsShort'))),
60
+ icon('check', `${P}-ck`));
61
+ });
62
+ if (ctx.activeProvider && !modelNodes.length) {
63
+ modelNodes.push(h('div', { key: 'empty', className: `${P}-empty` }, t('noMatch')));
64
+ }
65
+
66
+ return h('div', {
67
+ className: `${P}-pane ${P}-models${ctx.pane !== 'models' ? ' hidden' : ''}`,
68
+ role: 'menu', 'aria-label': t('model'),
69
+ inert: ctx.pane !== 'models' ? '' : undefined,
70
+ onKeyDown: ctx.modelKeyDown
71
+ },
72
+ h('div', {
73
+ className: `${P}-viewport${ctx.view === 2 ? ' view2' : ''}`
74
+ },
75
+ /* 第 1 页 —— 提供方(自有滚动容器,因此长列表可达) */
76
+ h('div', { className: `${P}-page slot1` },
77
+ h('div', { className: `${P}-sec` }, t('model')),
78
+ h('div', { className: `${P}-rows` }, ...providerNodes, ...noticeNodes)),
79
+
80
+ /* 第 2 页 —— 所选提供方的模型 */
81
+ h('div', {
82
+ className: `${P}-page slot2`,
83
+ inert: ctx.view !== 2 ? '' : undefined
84
+ },
85
+ h('div', { className: `${P}-head` },
86
+ h('button', {
87
+ type: 'button', className: `${P}-back`,
88
+ 'aria-label': t('back'), title: t('back'),
89
+ onClick: ctx.goBack
90
+ }, icon('chevron', `${P}-iconSmall`)),
91
+ h('span', { className: `${P}-title` },
92
+ ctx.activeProvider ? ctx.activeProvider.name : '')),
93
+ h('label', { className: `${P}-search` },
94
+ icon('search', `${P}-iconSmall`),
95
+ h('input', {
96
+ ref: ctx.searchRef, type: 'text', value: ctx.query,
97
+ placeholder: t('search'), 'aria-label': t('search'),
98
+ spellCheck: false,
99
+ onChange: e => ctx.setQuery(e.target.value)
100
+ })),
101
+ h('div', { className: `${P}-list` }, ...modelNodes))));
102
+ }
103
+ function renderEffortView(ctx) {
104
+ const P = ctx.P, h = ctx.h, icon = ctx.icon, t = ctx.t;
105
+ const effortApi = ctx.effortApi, metrics = ctx.metrics;
106
+ const ICON = ctx.ICON;
107
+
108
+ return h('div', {
109
+ className: `${P}-pane ${P}-main${ctx.pane !== 'effort' ? ' hidden' : ''}`,
110
+ inert: ctx.pane !== 'effort' ? '' : undefined,
111
+ /* Agent Teams 行需要多一个行高;上面的弹出面板高度使用同一份 */
112
+ style: { [`--${P}-main-h`]: `${ctx.team.supported ? metrics.teamPaneH : metrics.effortPaneH}px` }
113
+ },
114
+ h('button', {
115
+ className: `${P}-tool ${P}-fast${ctx.fast ? ' active' : ''}`,
116
+ ref: ctx.fastBtnRef,
117
+ 'aria-label': t('fast'), 'aria-pressed': ctx.fast,
118
+ 'aria-describedby': `${P}-fast-tip`,
119
+ /* tooltip 绝不能作为此按钮的子节点:弹出面板的 backdrop-filter */
120
+ onPointerEnter: () => ctx.setTipOn(true),
121
+ onPointerLeave: () => ctx.setTipOn(false),
122
+ onFocus: () => ctx.setTipOn(true),
123
+ onBlur: () => ctx.setTipOn(false),
124
+ onClick: () => ctx.setFast(v => !v)
125
+ },
126
+ h('svg', { viewBox: '0 0 24 24', 'aria-hidden': true, style: { width: 15, height: 17, fill: ctx.fast ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: ctx.fast ? 0.7 : 1.5, strokeLinejoin: 'round' } },
127
+ h('path', { d: ICON.bolt }))),
128
+
129
+ h('button', {
130
+ className: `${P}-modelLink`, onClick: () => ctx.setPane('models'),
131
+ 'aria-label': t('model'), title: ctx.modelName
132
+ },
133
+ h('span', { className: `${P}-heading` }, ctx.currentLabel || t('choose'), icon('chevron', `${P}-iconSmall`)),
134
+ h('span', { className: `${P}-modelLinkName` }, ctx.modelName)),
135
+
136
+ h('div', { className: `${P}-warning` }, h('span', null, t('warning'))),
137
+
138
+ h('button', {
139
+ className: `${P}-tool ${P}-reset`,
140
+ ref: ctx.resetRef,
141
+ /* 只有在确实没有可重置内容时才禁用:旧的 `!model?.reasoning` */
142
+ disabled: ctx.busy || ctx.efforts.length === 0,
143
+ 'aria-label': t('reset'),
144
+ 'aria-describedby': `${P}-reset-tip`,
145
+ /* 悬停提示改用与 ⚡ 相同的浮层卡片,而不是浏览器原生 title */
146
+ onPointerEnter: () => ctx.setResetTipOn(true),
147
+ onPointerLeave: () => ctx.setResetTipOn(false),
148
+ onFocus: () => ctx.setResetTipOn(true),
149
+ onBlur: () => ctx.setResetTipOn(false),
150
+ onClick: ctx.resetToDefault
151
+ }, icon('reset')),
152
+
153
+ ctx.efforts.length
154
+ ? h('div', {
155
+ className: `${P}-rail${ctx.rail.dragging ? ' dragging' : ''}`,
156
+ ref: ctx.railRef,
157
+ /* 逐档着色:填充、未填充轨道色调、标题墨色和圆点 */
158
+ style: {
159
+ [`--${P}-fill`]: effortApi.fillFor(ctx.displayed, ctx.dark),
160
+ [`--${P}-track`]: effortApi.trackFor(effortApi.fillFor(ctx.displayed, ctx.dark), ctx.dark),
161
+ [`--${P}-ink`]: effortApi.inkFor(ctx.displayed, ctx.dark),
162
+ [`--${P}-dot`]: 'var(--dsw-alias-label-caption,#b6b6b8)',
163
+ /* 绽放粒子是当前档位颜色向白色提亮——对 Ultra 而言正好落在 */
164
+ [`--${P}-mote`]: effortApi.mixHex(effortApi.fillFor(ctx.displayed, ctx.dark), '#ffffff', ctx.dark ? 0.30 : 0.42),
165
+ /* 一个无量纲比例同时驱动圆钮和填充 */
166
+ [`--${P}-pos`]: ctx.rail.dragging ? (ctx.rail.liveRef.current ?? ctx.fraction) : ctx.fraction
167
+ },
168
+ role: 'slider', tabIndex: 0,
169
+ 'aria-label': t('effort'),
170
+ 'aria-valuemin': 0, 'aria-valuemax': ctx.efforts.length - 1,
171
+ 'aria-valuenow': ctx.index, 'aria-valuetext': ctx.currentLabel,
172
+ 'aria-disabled': ctx.busy || ctx.disabled,
173
+ onPointerDown: ctx.rail.pointerDown, onPointerMove: ctx.rail.pointerMove,
174
+ onPointerUp: ctx.rail.finish, onPointerCancel: ctx.rail.cancelDrag,
175
+ onLostPointerCapture: () => { /* 丢失捕获不算取消 */ },
176
+ onPointerLeave: () => ctx.rail.setHovered(-1),
177
+ onKeyDown: ctx.rail.keyDown
178
+ },
179
+ h('div', { className: `${P}-fill` }),
180
+ ...ctx.efforts.map((effort, i) => h('i', {
181
+ key: effort.id,
182
+ className: `${P}-dot${i <= ctx.index ? ' passed' : ''}${ctx.rail.hovered === i ? ' hovered' : ''}`,
183
+ style: { [`--${P}-tick`]: ctx.efforts.length > 1 ? i / (ctx.efforts.length - 1) : 0 }
184
+ })),
185
+ h('div', { className: `${P}-sparks` },
186
+ ...ctx.sparkles.map(s => h('i', {
187
+ key: s.key, className: `${P}-sp`,
188
+ style: { top: s.top, [`--b`]: s.b, [`--dur`]: s.dur, [`--delay`]: s.delay }
189
+ }))),
190
+ /* 到达绽放:以到达计数器为 key,因此挂载新 key 会让每颗 */
191
+ ctx.bloom
192
+ ? h('div', {
193
+ key: `bloom-${ctx.bloom}`, className: `${P}-bloom`, 'aria-hidden': true
194
+ },
195
+ h('i', { className: `${P}-halo` }),
196
+ ...ctx.bloomMotes.map(m => h('i', {
197
+ key: m.key, className: `${P}-bp`,
198
+ style: {
199
+ [`--x0`]: m.x0, [`--y0`]: m.y0,
200
+ [`--x1`]: m.x1, [`--y1`]: m.y1,
201
+ [`--sz`]: m.sz, [`--bmax`]: m.bmax,
202
+ [`--bd`]: m.bd, [`--bdel`]: m.bdel
203
+ }
204
+ })))
205
+ : null,
206
+ h('div', { className: `${P}-knob` }))
207
+ : h('div', { className: `${P}-noeffort` }, t('unsupported')),
208
+
209
+ /* Agent Teams:DSH 放在模型菜单根面板里的开关,在滑杆下方重建 */
210
+ ctx.team.supported
211
+ ? h('div', { className: `${P}-team` },
212
+ h('span', { className: `${P}-teamLabel` },
213
+ h('span', null, t('team')),
214
+ h('button', {
215
+ type: 'button',
216
+ className: `${P}-teamInfo`,
217
+ ref: ctx.teamInfoBtnRef,
218
+ /* 可访问名只用简短的「Agent Teams」;整句说明交给 */
219
+ 'aria-label': t('team'),
220
+ 'aria-describedby': `${P}-team-tip`,
221
+ onPointerEnter: () => ctx.setTeamTipOn(true),
222
+ onPointerLeave: () => ctx.setTeamTipOn(false),
223
+ onFocus: () => ctx.setTeamTipOn(true),
224
+ onBlur: () => ctx.setTeamTipOn(false),
225
+ /* 提示卡的显隐完全交给 hover / focus:这里若再切一刀, */
226
+ onClick: event => { event.preventDefault(); event.stopPropagation(); }
227
+ }, icon('info', `${P}-teamInfoIcon`))),
228
+ h('button', {
229
+ type: 'button', role: 'switch',
230
+ className: `${P}-teamSwitch`,
231
+ 'aria-checked': ctx.team.enabled ? 'true' : 'false',
232
+ 'aria-label': t('team'),
233
+ disabled: Boolean(ctx.locked || ctx.team.pending),
234
+ onClick: () => ctx.team.toggle(!ctx.team.enabled)
235
+ }))
236
+ : null);
237
+ }
238
+
239
+ exports.renderModelsView = renderModelsView;
240
+ exports.renderEffortView = renderEffortView;
241
+ return module.exports;
242
+ }
243
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-model-effort-ui",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "把 Codex 桌面版的模型选择列表与推理强度滑块 1:1 复刻进 DeepSeek Harness:同一个弹层里切换模型与推理强度。",
5
5
  "author": "zxclf",
6
6
  "license": "MIT",
@@ -30,8 +30,10 @@
30
30
  "files": [
31
31
  "index.js",
32
32
  "client.js",
33
+ "client.hooks.js",
33
34
  "client.effort.js",
34
35
  "client.styles.js",
36
+ "client.views.js",
35
37
  "cordis.patch.yml",
36
38
  "icon.svg",
37
39
  "README.md",