dsh-colophon 0.2.1 → 0.2.3

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.
Files changed (3) hide show
  1. package/README.md +8 -0
  2. package/client.js +465 -238
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -103,6 +103,14 @@ usage.jsonl API 调用账本(rules 引擎不写)
103
103
  - 摘要面板新增「下载 Markdown」按钮(直接保存为 `.md` 文件)
104
104
  - 版本号 0.2.0;测试 38 项全绿
105
105
 
106
+ ## 0.2.2(设置界面统一设计规范)
107
+
108
+ - 一套配色贯穿所有控件:文字/弱化/提示三级灰阶,唯一操作色 `#6d97ff`,状态色只用于状态(绿/琥珀/红)。
109
+ - 警示提示改为「深底 + 琥珀文字 + 边框」的低饱和样式,不再出现黄色看不清的问题;崩溃提示条改为中性深色。
110
+ - 摘要引擎改为分段控件(本地规则 / API 摘要),两种模式的选择一目了然。
111
+ - 所有数值设置都带单位:个会话 / 条 / tokens / 元 / 百万 token;批量上限只在开启「关闭时批量生成」时出现,并紧跟提示。
112
+ - 设置页统一为「行式表单 + 发丝分隔线 + 卡片标题竖条」的结构,左下角固定「保存修改」主按钮。
113
+
106
114
  ## 0.2.1(设置界面可读性)
107
115
 
108
116
  - 设置页重做:渐变标题卡 + 状态胶囊、强调条卡片、整行可点的开关(带滑动圆钮)、蓝底主按钮「保存修改」、描边次按钮「处理队列」/「查询」
package/client.js CHANGED
@@ -37,11 +37,13 @@ window.__ModuleLoader__.load({
37
37
  failed: '读取失败:{message}',
38
38
  crash: '上次 DSH 没有正常退出,卷末已在本地恢复(0 token)。',
39
39
  crashAck: '知道了',
40
- settingsLabel: '卷末 Colophon',
40
+ settingsLabel: '卷末摘要',
41
41
  settingsIntro: '规则引擎只读本地日志,不调用模型、不花 token;API 摘要为可选项。',
42
42
  engine: '摘要引擎',
43
- engineRules: '本地规则(0 token)',
44
- engineApi: 'API 摘要(可选的增强)',
43
+ engineRules: '本地规则',
44
+ engineRulesHint: '0 token · 本地生成',
45
+ engineApi: 'API 摘要',
46
+ engineApiHint: '按次调用模型',
45
47
  enabled: '启用卷末',
46
48
  triggers: '触发时机',
47
49
  onIdle: '会话空闲时',
@@ -90,6 +92,18 @@ window.__ModuleLoader__.load({
90
92
  statusOff: '已暂停',
91
93
  settingsSubtitle: '把每次对话的最终结论留在本地;重开会话时先看结论,不必重读整段历史。',
92
94
  saveHint: '保存后立即生效,无需重启。',
95
+ note: '注意',
96
+ unitSessions: '个会话',
97
+ unitMessages: '条',
98
+ unitPrice: '元 / 百万 token',
99
+ perSummaryCapHint: '单次调用超过此金额则按右侧策略处理',
100
+ dailyBudgetHint: '每天累计消耗的上限',
101
+ overCapHint: '达到单次/每日上限后的动作',
102
+ minMessagesHint: '低于该消息数的会话不生成',
103
+ minTokensHint: '低于该 token 数的会话不生成',
104
+ queueReason: '原因:{reason}',
105
+ saving: '保存中…',
106
+ rangeEmptyHint: '可查询任意自定义区间;结束时间留空表示到当前时刻。',
93
107
  enabledHint: '关闭后不再采集新会话;已有摘要仍可查看。',
94
108
  engineHint: 'rules 完全本地,0 token;api 每次生成会调用模型,并受下方预算限制。',
95
109
  onIdleHint: '智能体停止后几秒内写出摘要。',
@@ -121,8 +135,10 @@ window.__ModuleLoader__.load({
121
135
  settingsLabel: 'Colophon',
122
136
  settingsIntro: 'The rules engine only reads local logs — no model call, no token spend. API summaries are optional.',
123
137
  engine: 'Summary engine',
124
- engineRules: 'Local rules (0 tokens)',
125
- engineApi: 'API summary (optional)',
138
+ engineRules: 'Local rules',
139
+ engineRulesHint: '0 tokens · local',
140
+ engineApi: 'API summary',
141
+ engineApiHint: 'Calls a model per digest',
126
142
  enabled: 'Enable Colophon',
127
143
  triggers: 'Triggers',
128
144
  onIdle: 'When a session goes idle',
@@ -171,6 +187,18 @@ window.__ModuleLoader__.load({
171
187
  statusOff: 'Paused',
172
188
  settingsSubtitle: 'Keep every conversation’s final conclusion locally. Reopen a session and read the conclusion first — no need to replay the whole history.',
173
189
  saveHint: 'Changes take effect immediately after saving.',
190
+ note: 'Note',
191
+ unitSessions: 'sessions',
192
+ unitMessages: 'messages',
193
+ unitPrice: 'CNY / 1M tokens',
194
+ perSummaryCapHint: 'Above this per-call cost, the policy on the right applies',
195
+ dailyBudgetHint: 'Daily token ceiling',
196
+ overCapHint: 'What to do after hitting a cap',
197
+ minMessagesHint: 'Sessions below this are skipped',
198
+ minTokensHint: 'Sessions below this are skipped',
199
+ queueReason: 'Reason: {reason}',
200
+ saving: 'Saving…',
201
+ rangeEmptyHint: 'Any custom range; leave the end empty to use now.',
174
202
  enabledHint: 'When off, new sessions are no longer captured; existing digests stay readable.',
175
203
  engineHint: 'Local rules cost 0 tokens. The API engine calls a model per digest and is capped by the budgets below.',
176
204
  onIdleHint: 'Write the digest a few seconds after the agent stops.',
@@ -236,7 +264,7 @@ window.__ModuleLoader__.load({
236
264
  banner: {
237
265
  position: 'fixed', top: 12, left: '50%', transform: 'translateX(-50%)', zIndex: 70,
238
266
  display: 'flex', alignItems: 'center', gap: 10, padding: '8px 12px',
239
- background: 'rgba(84,64,16,0.98)', color: '#ffe9b0', border: '1px solid rgba(255,220,140,0.35)',
267
+ background: 'rgba(24,28,38,0.97)', color: '#dfe7f7', border: '1px solid rgba(109,151,255,0.4)',
240
268
  borderRadius: 10, fontSize: 12, boxShadow: '0 8px 24px rgba(0,0,0,0.35)',
241
269
  },
242
270
  field: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 120 },
@@ -255,81 +283,111 @@ window.__ModuleLoader__.load({
255
283
  warn: { color: '#ffd27a', fontSize: 11 },
256
284
  ok: { color: '#4cc38a', fontSize: 11 },
257
285
 
258
- // ---- Settings page ----
259
- page: { display: 'flex', flexDirection: 'column', gap: 14, fontSize: 13, maxWidth: 760, paddingBottom: 8, lineHeight: 1.5 },
286
+ // ---- Design tokens: one palette + one spacing scale for every control ----
287
+ // text / muted / faint -> three text contrast levels
288
+ // accent -> the only "selected / action" color
289
+ // amber / green / red -> status only, always paired with an icon dot
290
+ page: { display: 'flex', flexDirection: 'column', gap: 12, fontSize: 13, maxWidth: 780, paddingBottom: 6, color: '#e9edf3', lineHeight: 1.55 },
260
291
  headCard: {
261
- display: 'flex', flexDirection: 'column', gap: 6, padding: '18px 20px', borderRadius: 14,
292
+ display: 'flex', flexDirection: 'column', gap: 8, padding: '18px 18px 16px', borderRadius: 12,
262
293
  border: '1px solid rgba(255,255,255,0.08)',
263
- background: 'linear-gradient(135deg, rgba(79,124,255,0.12), rgba(255,255,255,0.02) 62%)',
264
- },
265
- headTitle: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', fontSize: 17, fontWeight: 650 },
266
- headSub: { fontSize: 12.5, lineHeight: 1.6, opacity: 0.7, maxWidth: 560 },
267
- pill: { display: 'inline-flex', alignItems: 'center', gap: 6, height: 22, padding: '0 10px', borderRadius: 999, fontSize: 11.5, fontWeight: 600, whiteSpace: 'nowrap' },
268
- pillOn: { background: 'rgba(76,195,138,0.14)', color: '#6fe0a8', border: '1px solid rgba(76,195,138,0.3)' },
269
- pillOff: { background: 'rgba(255,255,255,0.06)', color: 'rgba(255,255,255,0.62)', border: '1px solid rgba(255,255,255,0.12)' },
270
- card2: {
271
- display: 'flex', flexDirection: 'column', gap: 12, padding: '16px 18px', borderRadius: 14,
272
- border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(255,255,255,0.028)',
273
- },
274
- cardHead: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10 },
275
- cardTitle: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 13.5, fontWeight: 650 },
276
- accentBar: { width: 3, height: 14, borderRadius: 2, background: '#4f7cff', display: 'inline-block' },
277
- hint: { fontSize: 12, lineHeight: 1.6, opacity: 0.6 },
294
+ background: 'linear-gradient(135deg, rgba(109,151,255,0.18), rgba(109,151,255,0.03) 58%, rgba(255,255,255,0.015))',
295
+ },
296
+ headTitle: { fontSize: 17, fontWeight: 650, letterSpacing: '-0.01em' },
297
+ headSub: { fontSize: 12.5, lineHeight: 1.65, color: '#9aa4b5', maxWidth: 600 },
298
+ headMeta: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', marginTop: 2 },
299
+ pill: { display: 'inline-flex', alignItems: 'center', gap: 6, height: 22, padding: '0 10px', borderRadius: 999, fontSize: 11.5, fontWeight: 600, whiteSpace: 'nowrap', border: '1px solid transparent' },
300
+ pillOn: { background: 'rgba(127,215,162,0.12)', color: '#7fd7a2', borderColor: 'rgba(127,215,162,0.32)' },
301
+ pillOff: { background: 'rgba(255,255,255,0.05)', color: '#9aa4b5', borderColor: 'rgba(255,255,255,0.12)' },
302
+ pillCount: { background: 'rgba(109,151,255,0.12)', color: '#9db9ff', borderColor: 'rgba(109,151,255,0.3)' },
303
+ pillDot: { width: 6, height: 6, borderRadius: 999, display: 'inline-block' },
304
+ card: { borderRadius: 12, border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(255,255,255,0.026)', overflow: 'hidden' },
305
+ cardHead: { display: 'flex', alignItems: 'center', gap: 8, padding: '11px 14px', borderBottom: '1px solid rgba(255,255,255,0.07)' },
306
+ cardTitle: { display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: 13, fontWeight: 600 },
307
+ accentBar: { width: 3, height: 12, borderRadius: 2, background: '#6d97ff', display: 'inline-block' },
308
+ cardMeta: { marginLeft: 'auto', fontSize: 11.5, color: '#76819a' },
309
+ row: { display: 'flex', alignItems: 'center', gap: 16, padding: '12px 14px', minHeight: 46, borderBottom: '1px solid rgba(255,255,255,0.07)', boxSizing: 'border-box' },
310
+ rowLast: { borderBottom: 'none' },
311
+ labelBlock: { display: 'flex', flexDirection: 'column', gap: 3, flex: '1 1 180px', minWidth: 0 },
312
+ label: { fontSize: 13, color: '#e9edf3' },
313
+ hint: { fontSize: 11.5, lineHeight: 1.6, color: '#9aa4b5' },
314
+ control: { display: 'flex', alignItems: 'center', gap: 8, flex: '0 0 auto', flexWrap: 'wrap', justifyContent: 'flex-end' },
315
+ input: {
316
+ height: 34, boxSizing: 'border-box', padding: '0 10px', borderRadius: 8,
317
+ border: '1px solid rgba(255,255,255,0.14)', background: 'rgba(0,0,0,0.28)',
318
+ color: '#e9edf3', fontSize: 12.5, outline: 'none',
319
+ },
320
+ inputNum: { width: 112, textAlign: 'right', fontVariantNumeric: 'tabular-nums' },
321
+ inputText: { width: 168 },
322
+ unit: { fontSize: 11.5, color: '#76819a', whiteSpace: 'nowrap' },
323
+ selectWrap: { position: 'relative', display: 'inline-flex', alignItems: 'center' },
324
+ select: {
325
+ appearance: 'none', WebkitAppearance: 'none', height: 34, boxSizing: 'border-box',
326
+ padding: '0 26px 0 10px', borderRadius: 8, border: '1px solid rgba(255,255,255,0.14)',
327
+ background: 'rgba(0,0,0,0.28)', color: '#e9edf3', fontSize: 12.5, cursor: 'pointer', outline: 'none',
328
+ },
329
+ chevron: { position: 'absolute', right: 10, pointerEvents: 'none', fontSize: 9, color: '#9aa4b5' },
330
+ segmented: { display: 'inline-flex', gap: 3, padding: 3, borderRadius: 9, background: 'rgba(0,0,0,0.25)', border: '1px solid rgba(255,255,255,0.1)' },
331
+ segItem: {
332
+ appearance: 'none', border: '1px solid transparent', background: 'transparent', color: '#9aa4b5',
333
+ borderRadius: 7, padding: '5px 11px', cursor: 'pointer', display: 'inline-flex', flexDirection: 'column',
334
+ alignItems: 'flex-start', gap: 1, minWidth: 108, textAlign: 'left',
335
+ },
336
+ segItemOn: { background: 'rgba(109,151,255,0.16)', borderColor: 'rgba(109,151,255,0.5)', color: '#bcd0ff' },
337
+ segTitle: { fontSize: 12.5, fontWeight: 550 },
338
+ segHint: { fontSize: 10.5, color: '#76819a' },
339
+ segHintOn: { color: 'rgba(188,208,255,0.75)' },
278
340
  switchRow: {
279
- display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 14,
280
- padding: '10px 12px', borderRadius: 10, border: '1px solid rgba(255,255,255,0.07)',
281
- background: 'rgba(0,0,0,0.16)', cursor: 'pointer', minHeight: 46, boxSizing: 'border-box',
341
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16,
342
+ padding: '12px 14px', minHeight: 52, borderBottom: '1px solid rgba(255,255,255,0.07)',
343
+ cursor: 'pointer', boxSizing: 'border-box', outline: 'none',
282
344
  },
283
- switchRowOn: { borderColor: 'rgba(79,124,255,0.45)', background: 'rgba(79,124,255,0.1)' },
345
+ switchRowOn: { background: 'rgba(109,151,255,0.05)' },
284
346
  switchTrack: {
285
- position: 'relative', flex: '0 0 auto', width: 38, height: 22, borderRadius: 999,
286
- background: 'rgba(255,255,255,0.18)', transition: 'background 120ms ease',
347
+ position: 'relative', flex: '0 0 auto', width: 40, height: 23, borderRadius: 999,
348
+ background: 'rgba(255,255,255,0.16)', transition: 'background 140ms ease',
287
349
  },
288
- switchTrackOn: { background: '#4f7cff' },
350
+ switchTrackOn: { background: '#5b8cff' },
289
351
  switchKnob: {
290
- position: 'absolute', top: 3, left: 3, width: 16, height: 16, borderRadius: 999,
291
- background: '#fff', transition: 'transform 120ms ease', boxShadow: '0 1px 3px rgba(0,0,0,0.4)',
352
+ position: 'absolute', top: 3, left: 3, width: 17, height: 17, borderRadius: 999,
353
+ background: '#fff', transition: 'transform 140ms ease', boxShadow: '0 1px 3px rgba(0,0,0,0.45)',
292
354
  },
293
- switchKnobOn: { transform: 'translateX(16px)' },
294
- callout: {
295
- display: 'flex', gap: 8, padding: '10px 12px', borderRadius: 10,
296
- border: '1px solid rgba(255,210,122,0.28)', background: 'rgba(255,210,122,0.08)',
297
- color: '#ffd27a', fontSize: 12, lineHeight: 1.55,
298
- },
299
- fieldWide: { display: 'flex', flexDirection: 'column', gap: 5, minWidth: 150, flex: '1 1 150px', maxWidth: 300 },
300
- inputWide: {
301
- background: 'rgba(0,0,0,0.3)', color: 'inherit', border: '1px solid rgba(255,255,255,0.14)',
302
- borderRadius: 8, height: 34, padding: '0 10px', fontSize: 13, width: '100%', boxSizing: 'border-box',
303
- },
304
- row2: { display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'flex-end' },
305
- actionsBar: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 10, paddingTop: 2 },
355
+ switchKnobOn: { transform: 'translateX(17px)' },
356
+ callout: { display: 'flex', gap: 8, alignItems: 'flex-start', margin: '10px 14px', padding: '9px 11px', borderRadius: 8, fontSize: 11.5, lineHeight: 1.6, border: '1px solid transparent' },
357
+ calloutInfo: { background: 'rgba(109,151,255,0.08)', borderColor: 'rgba(109,151,255,0.28)', color: '#c7d7ff' },
358
+ calloutWarn: { background: 'rgba(238,207,148,0.10)', borderColor: 'rgba(238,207,148,0.34)', color: '#eed7a6' },
359
+ calloutError: { background: 'rgba(255,130,130,0.10)', borderColor: 'rgba(255,130,130,0.30)', color: '#ffb3b3' },
360
+ calloutOk: { background: 'rgba(127,215,162,0.10)', borderColor: 'rgba(127,215,162,0.30)', color: '#8fe0b1' },
361
+ calloutDot: { width: 6, height: 6, borderRadius: 999, marginTop: 6, flex: '0 0 auto' },
362
+ calloutLabel: { fontWeight: 600, marginRight: 4 },
306
363
  buttonPrimary: {
307
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6,
308
- height: 36, minWidth: 104, padding: '0 18px', borderRadius: 9,
309
- border: '1px solid rgba(79,124,255,0.9)', background: '#4f7cff', color: '#fff',
310
- fontSize: 13, fontWeight: 650, cursor: 'pointer', boxShadow: '0 2px 10px rgba(79,124,255,0.35)',
364
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6, height: 36,
365
+ minWidth: 108, padding: '0 18px', borderRadius: 9, border: '1px solid #5b8cff',
366
+ background: '#4f7cff', color: '#fff', fontSize: 13, fontWeight: 650, cursor: 'pointer',
367
+ boxShadow: '0 2px 10px rgba(79,124,255,0.35)', boxSizing: 'border-box',
311
368
  },
312
369
  buttonSecondary: {
313
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6,
314
- height: 36, minWidth: 84, padding: '0 14px', borderRadius: 9,
315
- border: '1px solid rgba(255,255,255,0.22)', background: 'rgba(255,255,255,0.05)',
316
- color: 'inherit', fontSize: 13, fontWeight: 550, cursor: 'pointer',
317
- },
318
- buttonDisabled: { opacity: 0.45, cursor: 'not-allowed', boxShadow: 'none' },
319
- usageGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))', gap: 10 },
320
- usageCard: {
321
- display: 'flex', flexDirection: 'column', gap: 2, padding: '12px 14px', borderRadius: 12,
322
- border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(0,0,0,0.18)',
323
- },
324
- usageValue: { fontSize: 19, fontWeight: 650, letterSpacing: '-0.01em' },
325
- listRow: {
326
- display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap',
327
- padding: '8px 10px', borderRadius: 8, background: 'rgba(0,0,0,0.16)', fontSize: 12,
328
- },
329
- emptyBox: {
330
- padding: '14px 12px', borderRadius: 10, border: '1px dashed rgba(255,255,255,0.16)',
331
- color: 'rgba(255,255,255,0.5)', fontSize: 12, textAlign: 'center',
370
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 6, height: 34,
371
+ minWidth: 84, padding: '0 14px', borderRadius: 8, border: '1px solid rgba(255,255,255,0.2)',
372
+ background: 'rgba(255,255,255,0.045)', color: '#e9edf3', fontSize: 12.5, fontWeight: 550,
373
+ cursor: 'pointer', boxSizing: 'border-box',
332
374
  },
375
+ buttonDisabled: { opacity: 0.4, cursor: 'not-allowed', boxShadow: 'none' },
376
+ actionsBar: { display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 10, padding: '10px 14px' },
377
+ footer: {
378
+ display: 'flex', alignItems: 'center', gap: 12, padding: '10px 14px', borderRadius: 10,
379
+ border: '1px solid rgba(255,255,255,0.08)', background: 'rgba(20,23,30,0.94)',
380
+ backdropFilter: 'blur(8px)', position: 'sticky', bottom: 0, zIndex: 2,
381
+ },
382
+ footerText: { flex: '1 1 auto', fontSize: 11.5, color: '#76819a', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
383
+ usageGrid: { display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 8, padding: '12px 14px 0' },
384
+ usageCard: { display: 'flex', flexDirection: 'column', gap: 2, padding: '11px 12px', borderRadius: 10, border: '1px solid rgba(255,255,255,0.07)', background: 'rgba(0,0,0,0.2)' },
385
+ usageLabel: { fontSize: 11, color: '#9aa4b5' },
386
+ usageValue: { fontSize: 18, fontWeight: 650, letterSpacing: '-0.01em', fontVariantNumeric: 'tabular-nums' },
387
+ usageMeta: { fontSize: 10.5, color: '#76819a' },
388
+ listRow: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', padding: '8px 10px', borderRadius: 8, background: 'rgba(0,0,0,0.2)', fontSize: 12 },
389
+ emptyBox: { margin: '12px 14px 4px', padding: '14px 12px', borderRadius: 9, border: '1px dashed rgba(255,255,255,0.16)', color: '#76819a', fontSize: 11.5, textAlign: 'center' },
390
+ grid2: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, padding: '12px 14px' },
333
391
  }
334
392
 
335
393
  /** Read/persist the crash banner acknowledgement. */
@@ -450,60 +508,232 @@ window.__ModuleLoader__.load({
450
508
  return h(React.Fragment, null, h(CrashBanner), h('div', null, chip), panel)
451
509
  }
452
510
 
453
- /** One labelled number input bound to a form field. */
454
- function NumberField({ label, value, onChange, step }) {
455
- return h('label', { style: styles.fieldWide },
456
- h('span', { style: styles.label }, label),
457
- h('input', {
458
- style: styles.inputWide,
459
- type: 'number',
460
- step: step ?? 1,
461
- value: value ?? '',
462
- onChange: event => onChange(Number(event.target.value)),
463
- }))
511
+ /** A labelled row: text block on the left, control on the right. */
512
+ // ---- Settings page look: mirrors DSH's own settings design language ----
513
+ // Colors come from the shell's design tokens, so every theme (including the
514
+ // whale-dream skins) keeps readable contrast without hardcoded values.
515
+ const ui = {
516
+ page: {
517
+ display: 'flex', flexDirection: 'column', maxWidth: 760, padding: '2px 0 96px',
518
+ color: 'var(--dsw-alias-label-primary, #e9edf3)', lineHeight: 1.55,
519
+ },
520
+ header: { display: 'flex', flexDirection: 'column', gap: 6, padding: '2px 0 6px' },
521
+ headerRow: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' },
522
+ title: { fontSize: 19, fontWeight: 650, letterSpacing: '-0.01em' },
523
+ subtitle: { fontSize: 13, lineHeight: 1.6, color: 'var(--dsw-alias-label-tertiary, #8b93a1)', maxWidth: 620 },
524
+ meta: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', fontSize: 12, color: 'var(--dsw-alias-label-quaternary, #6d7686)' },
525
+ group: { display: 'flex', flexDirection: 'column' },
526
+ groupHead: { display: 'flex', alignItems: 'center', gap: 8, padding: '22px 0 2px' },
527
+ groupTitle: { fontSize: 13, fontWeight: 600, color: 'var(--dsw-alias-label-secondary, #b7bec9)' },
528
+ groupMeta: { marginLeft: 'auto', fontSize: 12, color: 'var(--dsw-alias-label-quaternary, #6d7686)' },
529
+ row: {
530
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24,
531
+ padding: '16px 0', minHeight: 46, boxSizing: 'border-box',
532
+ borderBottom: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.07))',
533
+ },
534
+ rowLast: { borderBottom: 'none' },
535
+ labelBlock: { display: 'flex', flexDirection: 'column', gap: 4, flex: '1 1 auto', minWidth: 0 },
536
+ label: { fontSize: 15, fontWeight: 500, color: 'var(--dsw-alias-label-primary, #e9edf3)' },
537
+ hint: { fontSize: 13, lineHeight: 1.55, color: 'var(--dsw-alias-label-tertiary, #8b93a1)' },
538
+ control: { display: 'flex', alignItems: 'center', gap: 8, flex: '0 0 auto', flexWrap: 'wrap', justifyContent: 'flex-end' },
539
+ input: {
540
+ height: 32, boxSizing: 'border-box', padding: '0 10px', outline: 'none',
541
+ borderRadius: 'var(--dsw-radius-sm, 8px)',
542
+ border: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.10))',
543
+ background: 'var(--dsw-alias-bg-layer-2, rgba(255,255,255,0.05))',
544
+ color: 'var(--dsw-alias-label-primary, #e9edf3)', fontSize: 13,
545
+ },
546
+ inputNum: { width: 96, textAlign: 'right', fontVariantNumeric: 'tabular-nums' },
547
+ inputText: { width: 180 },
548
+ unit: { fontSize: 13, color: 'var(--dsw-alias-label-quaternary, #6d7686)', whiteSpace: 'nowrap' },
549
+ selectWrap: { display: 'inline-flex', alignItems: 'center' },
550
+ select: {
551
+ appearance: 'none', WebkitAppearance: 'none', height: 32, boxSizing: 'border-box',
552
+ padding: '0 28px 0 10px', borderRadius: 'var(--dsw-radius-sm, 8px)', cursor: 'pointer', outline: 'none',
553
+ border: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.10))',
554
+ background: 'var(--dsw-alias-bg-layer-2, rgba(255,255,255,0.05))',
555
+ color: 'var(--dsw-alias-label-primary, #e9edf3)', fontSize: 13,
556
+ },
557
+ chevron: { position: 'absolute', right: 10, pointerEvents: 'none', fontSize: 9, color: 'var(--dsw-alias-label-quaternary, #6d7686)' },
558
+ segmented: {
559
+ display: 'inline-flex', padding: 2, gap: 2, borderRadius: 'var(--dsw-radius-sm, 8px)',
560
+ background: 'var(--dsw-alias-bg-layer-2, rgba(255,255,255,0.05))',
561
+ border: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.08))',
562
+ },
563
+ segItem: {
564
+ appearance: 'none', border: 0, background: 'transparent', cursor: 'pointer', borderRadius: 6,
565
+ padding: '4px 12px', display: 'inline-flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1,
566
+ minWidth: 92, textAlign: 'left', color: 'var(--dsw-alias-label-tertiary, #8b93a1)',
567
+ },
568
+ segItemOn: {
569
+ background: 'var(--dsw-alias-interactive-bg-hover, rgba(255,255,255,0.10))',
570
+ color: 'var(--dsw-alias-label-primary, #e9edf3)',
571
+ boxShadow: 'inset 0 0 0 1px var(--dsw-alias-border-l2, rgba(255,255,255,0.12))',
572
+ },
573
+ segTitle: { fontSize: 13, fontWeight: 550, lineHeight: 1.35 },
574
+ segHint: { fontSize: 11, lineHeight: 1.3, color: 'var(--dsw-alias-label-quaternary, #6d7686)', fontWeight: 400 },
575
+ switchRow: { cursor: 'pointer' },
576
+ switchTrack: {
577
+ position: 'relative', flex: '0 0 auto', width: 38, height: 22, borderRadius: 999,
578
+ background: 'var(--dsw-alias-border-l2, rgba(255,255,255,0.20))', transition: 'background 140ms ease',
579
+ },
580
+ switchTrackOn: { background: 'var(--dsw-alias-state-business-primary, #4d6bfe)' },
581
+ switchKnob: {
582
+ position: 'absolute', top: 3, left: 3, width: 16, height: 16, borderRadius: 999,
583
+ background: '#fff', transition: 'transform 140ms ease', boxShadow: '0 1px 2px rgba(0,0,0,0.35)',
584
+ },
585
+ switchKnobOn: { transform: 'translateX(16px)' },
586
+ callout: {
587
+ display: 'flex', gap: 8, alignItems: 'flex-start', margin: '10px 0 14px', padding: '10px 12px',
588
+ borderRadius: 'var(--dsw-radius-sm, 8px)', fontSize: 13, lineHeight: 1.55,
589
+ border: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.08))',
590
+ background: 'var(--dsw-alias-bg-layer-1, rgba(255,255,255,0.04))',
591
+ color: 'var(--dsw-alias-label-secondary, #b7bec9)',
592
+ },
593
+ calloutWarn: {
594
+ borderColor: 'var(--dsw-alias-state-warn-secondary, #6b5836)',
595
+ background: 'color-mix(in srgb, var(--dsw-alias-state-warn-primary, #e6c07a) 12%, transparent)',
596
+ color: 'var(--dsw-alias-state-warn-label, #e8c98f)',
597
+ },
598
+ calloutError: {
599
+ borderColor: 'var(--dsw-alias-state-error-secondary, #5c2b2b)',
600
+ background: 'rgba(239,103,92,0.10)', color: 'var(--dsw-alias-state-error-primary, #ef675c)',
601
+ },
602
+ calloutOk: {
603
+ borderColor: 'var(--dsw-alias-state-success-secondary, #2f5140)',
604
+ background: 'rgba(110,216,137,0.10)', color: 'var(--dsw-alias-state-success-primary, #6ed889)',
605
+ },
606
+ calloutDot: { width: 6, height: 6, borderRadius: 999, marginTop: 6, flex: '0 0 auto' },
607
+ calloutLabel: { fontWeight: 600, marginRight: 4 },
608
+ pill: { display: 'inline-flex', alignItems: 'center', gap: 6, height: 22, padding: '0 9px', borderRadius: 999, fontSize: 12, fontWeight: 500, whiteSpace: 'nowrap', border: '1px solid transparent' },
609
+ pillOn: { background: 'rgba(110,216,137,0.12)', color: 'var(--dsw-alias-state-success-primary, #6ed889)', borderColor: 'rgba(110,216,137,0.30)' },
610
+ pillOff: { background: 'var(--dsw-alias-bg-layer-2, rgba(255,255,255,0.05))', color: 'var(--dsw-alias-label-tertiary, #8b93a1)', borderColor: 'var(--dsw-alias-border-l1, rgba(255,255,255,0.08))' },
611
+ pillCount: { background: 'rgba(77,107,254,0.14)', color: 'var(--dsw-alias-label-primary, #e9edf3)', borderColor: 'rgba(77,107,254,0.34)' },
612
+ pillDot: { width: 6, height: 6, borderRadius: 999, display: 'inline-block' },
613
+ buttonPrimary: {
614
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', height: 34, minWidth: 108,
615
+ padding: '0 18px', borderRadius: 'var(--dsw-radius-sm, 8px)', cursor: 'pointer', boxSizing: 'border-box',
616
+ border: '1px solid var(--dsw-alias-button-primary-fill, #4d6bfe)',
617
+ background: 'var(--dsw-alias-button-primary-fill, #4d6bfe)',
618
+ color: 'var(--dsw-alias-label-on-color, #fff)', fontSize: 13, fontWeight: 600,
619
+ },
620
+ buttonSecondary: {
621
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', height: 32, minWidth: 84,
622
+ padding: '0 14px', borderRadius: 'var(--dsw-radius-sm, 8px)', cursor: 'pointer', boxSizing: 'border-box',
623
+ border: '1px solid var(--dsw-alias-border-l2, rgba(255,255,255,0.14))',
624
+ background: 'var(--dsw-alias-bg-layer-2, rgba(255,255,255,0.05))',
625
+ color: 'var(--dsw-alias-label-primary, #e9edf3)', fontSize: 13, fontWeight: 500,
626
+ },
627
+ buttonDisabled: { opacity: 0.4, cursor: 'not-allowed' },
628
+ footer: {
629
+ display: 'flex', alignItems: 'center', gap: 12, marginTop: 24, paddingTop: 14,
630
+ borderTop: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.07))',
631
+ },
632
+ footerText: { flex: '1 1 auto', fontSize: 13, color: 'var(--dsw-alias-label-quaternary, #6d7686)', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
633
+ statGrid: { display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 10, padding: '12px 0 4px' },
634
+ statCard: {
635
+ display: 'flex', flexDirection: 'column', gap: 2, padding: '12px 14px',
636
+ borderRadius: 'var(--dsw-radius-sm, 8px)',
637
+ background: 'var(--dsw-alias-card-fill, var(--dsw-alias-bg-layer-1, rgba(255,255,255,0.04)))',
638
+ border: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.07))',
639
+ },
640
+ statLabel: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary, #8b93a1)' },
641
+ statValue: { fontSize: 16, fontWeight: 600, fontVariantNumeric: 'tabular-nums', letterSpacing: '-0.01em', marginTop: 2 },
642
+ statMeta: { fontSize: 12, color: 'var(--dsw-alias-label-quaternary, #6d7686)' },
643
+ queueList: { display: 'flex', flexDirection: 'column' },
644
+ queueRow: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', padding: '10px 0', borderBottom: '1px solid var(--dsw-alias-border-l1, rgba(255,255,255,0.06))', fontSize: 13 },
645
+ emptyBox: { padding: '14px 0', fontSize: 13, color: 'var(--dsw-alias-label-quaternary, #6d7686)' },
646
+ rangeRow: { display: 'flex', alignItems: 'flex-end', gap: 10, flexWrap: 'wrap', padding: '12px 0 2px' },
647
+ field: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12, color: 'var(--dsw-alias-label-tertiary, #8b93a1)' },
648
+ }
649
+
650
+ /** A labelled row: text block on the left, control on the right. */
651
+ function Row({ children, last, onClick }) {
652
+ return h('div', { style: last ? { ...ui.row, ...ui.rowLast } : ui.row, onClick }, children)
464
653
  }
465
654
 
466
- /** One checkbox row. */
467
- function Check({ label, checked, onChange }) {
468
- return h('label', { style: styles.check },
469
- h('input', { type: 'checkbox', checked: checked === true, onChange: event => onChange(event.target.checked) }),
470
- h('span', null, label))
655
+ function LabelBlock({ label, hint }) {
656
+ return h('div', { style: ui.labelBlock },
657
+ h('div', { style: ui.label }, label),
658
+ hint ? h('div', { style: ui.hint }, hint) : null)
471
659
  }
472
660
 
473
- /** One card section on the settings page. */
474
- function Card({ title, extra, children }) {
475
- return h('div', { style: styles.card2 },
476
- h('div', { style: styles.cardHead },
477
- h('div', { style: styles.cardTitle }, h('span', { style: styles.accentBar }), title),
478
- extra ?? null),
661
+ function Group({ title, meta, children }) {
662
+ return h('div', { style: ui.group },
663
+ title
664
+ ? h('div', { style: ui.groupHead },
665
+ h('span', { style: ui.groupTitle }, title),
666
+ meta ? h('span', { style: ui.groupMeta }, meta) : null)
667
+ : null,
479
668
  children)
480
669
  }
481
670
 
482
- /** A full-row toggle: the whole row is the click target, the knob is obvious. */
483
- function SwitchRow({ label, hint, checked, onChange }) {
484
- const on = checked === true
485
- const toggle = () => onChange(!on)
671
+ function SwitchRow({ label, hint, checked, onChange, last }) {
486
672
  return h('div', {
487
- role: 'switch',
488
- 'aria-checked': on,
489
- tabIndex: 0,
490
- style: on ? { ...styles.switchRow, ...styles.switchRowOn } : styles.switchRow,
491
- onClick: toggle,
492
- onKeyDown: event => {
493
- if (event.key === 'Enter' || event.key === ' ') {
494
- event.preventDefault()
495
- toggle()
496
- }
497
- },
673
+ style: last ? { ...ui.row, ...ui.rowLast, ...ui.switchRow } : { ...ui.row, ...ui.switchRow },
674
+ role: 'switch', 'aria-checked': checked, tabIndex: 0,
675
+ onClick: () => onChange(!checked),
676
+ onKeyDown: event => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); onChange(!checked) } },
498
677
  },
499
- h('div', { style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
500
- h('span', { style: { fontSize: 13 } }, label),
501
- hint ? h('span', { style: styles.hint }, hint) : null),
502
- h('div', { style: on ? { ...styles.switchTrack, ...styles.switchTrackOn } : styles.switchTrack },
503
- h('div', { style: on ? { ...styles.switchKnob, ...styles.switchKnobOn } : styles.switchKnob })))
678
+ h(LabelBlock, { label, hint }),
679
+ h('div', { style: { ...ui.switchTrack, ...(checked ? ui.switchTrackOn : null) } },
680
+ h('div', { style: { ...ui.switchKnob, ...(checked ? ui.switchKnobOn : null) } })))
681
+ }
682
+
683
+ function Segmented({ options, value, onChange }) {
684
+ return h('div', { style: ui.segmented },
685
+ options.map(option => h('button', {
686
+ key: option.value, type: 'button',
687
+ style: option.value === value ? { ...ui.segItem, ...ui.segItemOn } : ui.segItem,
688
+ onClick: () => onChange(option.value),
689
+ },
690
+ h('span', { style: ui.segTitle }, option.label),
691
+ option.hint ? h('span', { style: ui.segHint }, option.hint) : null)))
692
+ }
693
+
694
+ function Select({ value, onChange, width, children }) {
695
+ return h('span', { style: ui.selectWrap },
696
+ h('select', { style: { ...ui.select, width: width || 160 }, value, onChange: event => onChange(event.target.value) }, children),
697
+ h('span', { style: ui.chevron }, '▾'))
698
+ }
699
+
700
+ function NumberRow({ label, hint, value, onChange, step, unit, last }) {
701
+ return h(Row, { last },
702
+ h(LabelBlock, { label, hint }),
703
+ h('div', { style: ui.control },
704
+ h('input', {
705
+ style: { ...ui.input, ...ui.inputNum }, type: 'number', step: step || 1,
706
+ value: value ?? '', onChange: event => onChange(Number(event.target.value)),
707
+ }),
708
+ unit ? h('span', { style: ui.unit }, unit) : null))
709
+ }
710
+
711
+ function TextRow({ label, hint, value, onChange, placeholder, width, last }) {
712
+ return h(Row, { last },
713
+ h(LabelBlock, { label, hint }),
714
+ h('div', { style: ui.control },
715
+ h('input', {
716
+ style: { ...ui.input, width: width || 180 }, type: 'text', value: value ?? '', placeholder,
717
+ onChange: event => onChange(event.target.value),
718
+ })))
719
+ }
720
+
721
+ function Callout({ tone = 'info', label, children }) {
722
+ const toneStyle = tone === 'warn' ? ui.calloutWarn : tone === 'error' ? ui.calloutError : tone === 'ok' ? ui.calloutOk : null
723
+ return h('div', { style: toneStyle ? { ...ui.callout, ...toneStyle } : ui.callout, role: 'note' },
724
+ h('span', { style: { ...ui.calloutDot, background: 'currentColor' } }),
725
+ h('span', null,
726
+ label ? h('span', { style: ui.calloutLabel }, label) : null,
727
+ children))
504
728
  }
505
729
 
506
- /** Settings page section: engine, triggers, API budget and usage cards. */
730
+ function StatusPill({ on, onText, offText, count }) {
731
+ const style = count ? { ...ui.pill, ...ui.pillCount } : on ? { ...ui.pill, ...ui.pillOn } : { ...ui.pill, ...ui.pillOff }
732
+ return h('span', { style },
733
+ h('span', { style: { ...ui.pillDot, background: 'currentColor', opacity: on || count ? 1 : 0.6 } }),
734
+ count ? onText : on ? onText : offText)
735
+ }
736
+ /** Settings page: native DSH layout (rows + hairlines) and token colors. */
507
737
  function ColophonSettings() {
508
738
  const [form, setForm] = useState(null)
509
739
  const [status, setStatus] = useState(null)
@@ -511,6 +741,7 @@ window.__ModuleLoader__.load({
511
741
  const [range, setRange] = useState({ from: '', to: '' })
512
742
  const [message, setMessage] = useState('')
513
743
  const [failed, setFailed] = useState('')
744
+ const [saving, setSaving] = useState(false)
514
745
 
515
746
  useEffect(() => {
516
747
  let alive = true
@@ -530,8 +761,7 @@ window.__ModuleLoader__.load({
530
761
  const update = (section, key, value) => {
531
762
  setForm(current => {
532
763
  if (!current) return current
533
- const next = { ...current, [section]: { ...current[section], [key]: value } }
534
- return next
764
+ return { ...current, [section]: { ...current[section], [key]: value } }
535
765
  })
536
766
  setMessage('')
537
767
  }
@@ -542,14 +772,12 @@ window.__ModuleLoader__.load({
542
772
 
543
773
  const save = async () => {
544
774
  if (!form) return
775
+ setSaving(true)
545
776
  setFailed('')
546
777
  try {
547
778
  const patch = {
548
- enabled: form.enabled,
549
- engine: form.engine,
550
- api: form.api,
551
- triggers: form.triggers,
552
- filter: form.filter,
779
+ enabled: form.enabled, engine: form.engine,
780
+ api: form.api, triggers: form.triggers, filter: form.filter,
553
781
  }
554
782
  const value = await callHost('config', { method: 'POST', body: { patch } })
555
783
  setForm(value.config)
@@ -557,6 +785,8 @@ window.__ModuleLoader__.load({
557
785
  setMessage(tr('saved'))
558
786
  } catch (cause) {
559
787
  setFailed(tr('saveFailed', { message: String(cause?.message ?? cause) }))
788
+ } finally {
789
+ setSaving(false)
560
790
  }
561
791
  }
562
792
 
@@ -572,56 +802,58 @@ window.__ModuleLoader__.load({
572
802
  const from = Date.parse(range.from)
573
803
  const to = range.to === '' ? Date.now() : Date.parse(range.to)
574
804
  if (!Number.isFinite(from) || !Number.isFinite(to) || from > to) {
575
- setFailed(tr('rangeInvalid'))
576
- setMessage('')
577
- return
805
+ setFailed(tr('rangeInvalid')); setMessage(''); return
578
806
  }
579
- setFailed('')
580
- setCustom(null)
581
- void loadCustom(from, to)
807
+ setFailed(''); setCustom(null); void loadCustom(from, to)
582
808
  }
583
809
 
810
+ const usage = status?.usage ?? {}
811
+ const usageCard = (label, slot, key) => h('div', { key, style: ui.statCard },
812
+ h('div', { style: ui.statLabel }, label),
813
+ h('div', { style: ui.statValue }, money(slot?.costCNY)),
814
+ h('div', { style: ui.statMeta }, tr('tokensLabel', { tokens: integer(slot?.tokens) }), ' · ', tr('calls', { count: slot?.calls ?? 0 })))
815
+
584
816
  if (!form) {
585
- return h('div', { style: styles.section },
817
+ return h('div', { style: ui.page },
586
818
  h(CrashBanner),
587
- h('div', { style: styles.muted }, failed || tr('loading')))
819
+ h('div', { style: ui.hint }, failed || tr('loading')))
588
820
  }
589
821
 
590
- const usage = status?.usage ?? {}
591
- const usageCard = (label, range) => h('div', { style: styles.usageCard },
592
- h('div', { style: styles.label }, label),
593
- h('div', { style: styles.usageValue }, money(range?.costCNY)),
594
- h('div', { style: styles.hint }, tr('tokensLabel', { tokens: integer(range?.tokens) }), ' · ', tr('calls', { count: range?.calls ?? 0 })))
595
-
596
822
  const queueItems = status?.queueItems ?? []
597
823
  const queueCount = Number(status?.queueCount ?? status?.queue ?? 0) || 0
598
824
  const enabled = form.enabled === true
599
825
  const apiOn = form.engine === 'api'
600
- const pill = (on, onText, offText) => h('span', { style: on ? { ...styles.pill, ...styles.pillOn } : { ...styles.pill, ...styles.pillOff } },
601
- h('span', { style: { width: 6, height: 6, borderRadius: 999, background: on ? '#6fe0a8' : 'rgba(255,255,255,0.4)' } }),
602
- on ? onText : offText)
826
+ const batchOn = form.triggers.closeBatch === true
603
827
 
604
- return h('div', { style: styles.page },
828
+ return h('div', { style: ui.page },
605
829
  h(CrashBanner),
606
- h('div', { style: styles.headCard },
607
- h('div', { style: styles.headTitle },
608
- '卷末 · Colophon',
609
- pill(enabled, tr('statusOn'), tr('statusOff'))),
610
- h('div', { style: styles.headSub }, tr('settingsSubtitle')),
611
- h('div', { style: styles.hint }, tr('saveHint'))),
612
- h(Card, { title: tr('basicTitle') },
830
+ h('div', { style: ui.header },
831
+ h('div', { style: ui.headerRow },
832
+ h('span', { style: ui.title }, '卷末 Colophon'),
833
+ h(StatusPill, { on: enabled, onText: tr('statusOn'), offText: tr('statusOff') })),
834
+ h('div', { style: ui.subtitle }, tr('settingsSubtitle')),
835
+ h('div', { style: ui.meta },
836
+ h('span', null, tr('saveHint')),
837
+ status ? h('span', null, tr('dataRoot'), ':', status.dataRoot) : null)),
838
+
839
+ h(Group, { title: tr('basicTitle') },
613
840
  h(SwitchRow, {
614
- label: tr('enabled'), hint: tr('enabledHint'), checked: enabled,
841
+ label: tr('enabled'), hint: tr('enabledHint'), checked: enabled, last: true,
615
842
  onChange: value => updateTop('enabled', value),
616
843
  }),
617
- h('div', { style: styles.row2 },
618
- h('label', { style: styles.fieldWide },
619
- h('span', { style: styles.label }, tr('engine')),
620
- h('select', { style: styles.inputWide, value: form.engine, onChange: event => updateTop('engine', event.target.value) },
621
- h('option', { value: 'rules' }, tr('engineRules')),
622
- h('option', { value: 'api' }, tr('engineApi')))),
623
- h('div', { style: { ...styles.hint, flex: '1 1 240px', paddingBottom: 6 } }, tr('engineHint')))),
624
- h(Card, { title: tr('triggers') },
844
+ h(Row, { last: true },
845
+ h(LabelBlock, { label: tr('engine'), hint: tr('engineHint') }),
846
+ h('div', { style: ui.control },
847
+ h(Segmented, {
848
+ value: form.engine,
849
+ onChange: value => updateTop('engine', value),
850
+ options: [
851
+ { value: 'rules', label: tr('engineRules'), hint: tr('engineRulesHint') },
852
+ { value: 'api', label: tr('engineApi'), hint: tr('engineApiHint') },
853
+ ],
854
+ })))),
855
+
856
+ h(Group, { title: tr('triggers') },
625
857
  h(SwitchRow, {
626
858
  label: tr('onIdle'), hint: tr('onIdleHint'), checked: form.triggers.onIdle === true,
627
859
  onChange: value => update('triggers', 'onIdle', value),
@@ -631,98 +863,93 @@ window.__ModuleLoader__.load({
631
863
  onChange: value => update('triggers', 'onSwitch', value),
632
864
  }),
633
865
  h(SwitchRow, {
634
- label: tr('closeBatch'), checked: form.triggers.closeBatch === true,
866
+ label: tr('closeBatch'), checked: batchOn, last: !batchOn,
635
867
  onChange: value => update('triggers', 'closeBatch', value),
636
868
  }),
637
- h('div', { style: styles.callout }, tr('closeBatchWarn')),
638
- h(NumberField, {
639
- label: tr('closeBatchMax'), value: form.triggers.closeBatchMaxSessions, step: 1,
869
+ batchOn ? h(NumberRow, {
870
+ label: tr('closeBatchMax'), unit: tr('unitSessions'), step: 1,
871
+ value: form.triggers.closeBatchMaxSessions, last: true,
640
872
  onChange: value => update('triggers', 'closeBatchMaxSessions', value),
641
- })),
642
- h(Card, {
643
- title: tr('apiSection'),
644
- extra: pill(apiOn, tr('apiOn'), tr('apiOff')),
645
- },
646
- h('div', { style: styles.hint }, tr('apiNote')),
647
- h('div', { style: styles.row2 },
648
- h('label', { style: styles.fieldWide },
649
- h('span', { style: styles.label }, tr('provider')),
650
- h('input', { style: styles.inputWide, value: form.api.provider, placeholder: 'deepseek', onChange: event => update('api', 'provider', event.target.value) })),
651
- h('label', { style: styles.fieldWide },
652
- h('span', { style: styles.label }, tr('model')),
653
- h('input', { style: styles.inputWide, value: form.api.model, onChange: event => update('api', 'model', event.target.value) }))),
654
- h('div', { style: styles.row2 },
655
- h(NumberField, { label: tr('priceIn'), value: form.api.priceInCNYPerM, step: 0.1, onChange: value => update('api', 'priceInCNYPerM', value) }),
656
- h(NumberField, { label: tr('priceOut'), value: form.api.priceOutCNYPerM, step: 0.1, onChange: value => update('api', 'priceOutCNYPerM', value) })),
657
- h('div', { style: styles.row2 },
658
- h(NumberField, { label: tr('perSummaryCap'), value: form.api.maxCostPerSummaryCNY, step: 0.01, onChange: value => update('api', 'maxCostPerSummaryCNY', value) }),
659
- h(NumberField, { label: tr('dailyBudget'), value: form.api.dailyTokenBudget, step: 1000, onChange: value => update('api', 'dailyTokenBudget', value) }),
660
- h('label', { style: styles.fieldWide },
661
- h('span', { style: styles.label }, tr('overCap')),
662
- h('select', { style: styles.inputWide, value: form.api.overCap, onChange: event => update('api', 'overCap', event.target.value) },
663
- h('option', { value: 'queue' }, tr('overCapQueue')),
664
- h('option', { value: 'skip' }, tr('overCapSkip'))))),
873
+ }) : null,
874
+ batchOn ? h(Callout, { tone: 'warn', label: tr('note') }, tr('closeBatchWarn')) : null),
875
+
876
+ h(Group, { title: tr('apiSection'), meta: apiOn ? tr('apiOn') : tr('apiOff') },
877
+ h(Callout, null, tr('apiNote')),
878
+ h(TextRow, { label: tr('provider'), hint: 'deepseek-official', value: form.api.provider, width: 200, onChange: value => update('api', 'provider', value) }),
879
+ h(TextRow, { label: tr('model'), hint: 'deepseek-chat', value: form.api.model, width: 200, onChange: value => update('api', 'model', value) }),
880
+ h(NumberRow, { label: tr('priceIn'), hint: tr('unitPrice'), step: 0.1, unit: '元', value: form.api.priceInCNYPerM, onChange: value => update('api', 'priceInCNYPerM', value) }),
881
+ h(NumberRow, { label: tr('priceOut'), hint: tr('unitPrice'), step: 0.1, unit: '元', value: form.api.priceOutCNYPerM, onChange: value => update('api', 'priceOutCNYPerM', value) }),
882
+ h(NumberRow, { label: tr('perSummaryCap'), hint: tr('perSummaryCapHint'), step: 0.01, unit: '元', value: form.api.maxCostPerSummaryCNY, onChange: value => update('api', 'maxCostPerSummaryCNY', value) }),
883
+ h(NumberRow, { label: tr('dailyBudget'), hint: tr('dailyBudgetHint'), step: 1000, unit: 'tokens', value: form.api.dailyTokenBudget, onChange: value => update('api', 'dailyTokenBudget', value) }),
884
+ h(Row, { last: !(apiOn && status && status.apiAvailable === false) },
885
+ h(LabelBlock, { label: tr('overCap'), hint: tr('overCapHint') }),
886
+ h('div', { style: ui.control },
887
+ h(Segmented, {
888
+ value: form.api.overCap,
889
+ onChange: value => update('api', 'overCap', value),
890
+ options: [
891
+ { value: 'queue', label: tr('overCapQueue') },
892
+ { value: 'skip', label: tr('overCapSkip') },
893
+ ],
894
+ }))),
665
895
  apiOn && status && status.apiAvailable === false
666
- ? h('div', { style: styles.callout }, tr('apiUnavailable'))
896
+ ? h(Callout, { tone: 'warn', label: tr('note') }, tr('apiUnavailable'))
667
897
  : null),
668
- h(Card, { title: tr('filter') },
669
- h('div', { style: styles.row2 },
670
- h(NumberField, { label: tr('minMessages'), value: form.filter.minMessages, onChange: value => update('filter', 'minMessages', value) }),
671
- h(NumberField, { label: tr('minTokens'), value: form.filter.minTokens, step: 500, onChange: value => update('filter', 'minTokens', value) }))),
672
- h(Card, { title: tr('queueTitle'), extra: pill(queueCount > 0, String(queueCount), String(queueCount)) },
673
- h('div', { style: styles.hint }, tr('queueHint')),
898
+
899
+ h(Group, { title: tr('filter') },
900
+ h(NumberRow, { label: tr('minMessages'), hint: tr('minMessagesHint'), unit: tr('unitMessages'), value: form.filter.minMessages, onChange: value => update('filter', 'minMessages', value) }),
901
+ h(NumberRow, { label: tr('minTokens'), hint: tr('minTokensHint'), unit: 'tokens', step: 500, last: true, value: form.filter.minTokens, onChange: value => update('filter', 'minTokens', value) })),
902
+
903
+ h(Group, { title: tr('queueTitle'), meta: queueCount > 0 ? String(queueCount) : tr('queueEmpty') },
674
904
  queueItems.length === 0
675
- ? h('div', { style: styles.emptyBox }, tr('queueEmpty'))
676
- : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
677
- queueItems.map(item => h('div', { key: item.sessionId, style: styles.listRow },
905
+ ? h('div', { style: ui.emptyBox }, tr('queueEmpty'))
906
+ : h('div', { style: ui.queueList },
907
+ queueItems.map(item => h('div', { key: item.sessionId, style: ui.queueRow },
678
908
  h('span', { style: { fontWeight: 600 } }, String(item.sessionId).slice(0, 14)),
679
- h('span', { style: styles.hint }, item.reason),
680
- h('span', { style: { ...styles.hint, marginLeft: 'auto' } }, new Date(item.at).toLocaleString())))),
681
- h('div', { style: styles.actionsBar },
682
- h('button', {
683
- style: queueCount === 0 ? { ...styles.buttonSecondary, ...styles.buttonDisabled } : styles.buttonSecondary,
684
- disabled: queueCount === 0,
685
- onClick: async () => {
686
- setFailed('')
687
- try {
688
- await callHost('queue/run', { method: 'POST', body: {} })
689
- setStatus(await callHost('status'))
690
- setMessage(tr('queueRun'))
691
- } catch (cause) {
692
- setFailed(String(cause?.message ?? cause))
693
- }
694
- },
695
- }, tr('queueProcess')))),
696
- h(Card, {
697
- title: tr('usage'),
698
- extra: h('span', { style: styles.hint }, tr('localZero')),
699
- },
700
- h('div', { style: styles.usageGrid },
701
- usageCard(tr('usageHour'), usage.hour),
702
- usageCard(tr('usageDay'), usage.day),
703
- usageCard(tr('usageWeek'), usage.week),
704
- usageCard(tr('usageMonth'), usage.month),
705
- custom ? usageCard(tr('usageCustom'), custom) : null),
706
- h('div', { style: styles.row2 },
707
- h('label', { style: styles.fieldWide },
708
- h('span', { style: styles.label }, tr('from')),
709
- h('input', {
710
- style: styles.inputWide, type: 'datetime-local', value: range.from,
711
- onChange: event => setRange(current => ({ ...current, from: event.target.value })),
712
- })),
713
- h('label', { style: styles.fieldWide },
714
- h('span', { style: styles.label }, tr('to')),
715
- h('input', {
716
- style: styles.inputWide, type: 'datetime-local', value: range.to,
717
- onChange: event => setRange(current => ({ ...current, to: event.target.value })),
718
- })),
719
- h('button', { style: styles.buttonSecondary, onClick: () => void applyRange() }, tr('apply'))),
720
- h('div', { style: styles.hint }, tr('customHint')),
721
- status ? h('div', { style: styles.hint }, tr('dataRoot'), ': ', status.dataRoot) : null),
722
- failed ? h('div', { style: styles.callout }, failed) : null,
723
- message ? h('div', { style: styles.ok }, message) : null,
724
- h('div', { style: styles.actionsBar },
725
- h('button', { style: styles.buttonPrimary, onClick: () => void save() }, tr('save'))))
909
+ h('span', { style: ui.hint }, tr('queueReason', { reason: item.reason })),
910
+ h('span', { style: { ...ui.hint, marginLeft: 'auto' } }, new Date(item.at).toLocaleString())))),
911
+ h(Row, { last: true },
912
+ h('div', { style: ui.hint }, tr('queueHint')),
913
+ h('div', { style: ui.control },
914
+ h('button', {
915
+ style: queueCount === 0 ? { ...ui.buttonSecondary, ...ui.buttonDisabled } : ui.buttonSecondary,
916
+ disabled: queueCount === 0,
917
+ onClick: async () => {
918
+ setFailed('')
919
+ try {
920
+ await callHost('queue/run', { method: 'POST', body: {} })
921
+ setStatus(await callHost('status'))
922
+ setMessage(tr('queueRun'))
923
+ } catch (cause) { setFailed(String(cause?.message ?? cause)) }
924
+ },
925
+ }, tr('queueProcess'))))),
926
+
927
+ h(Group, { title: tr('usage'), meta: tr('localZero') },
928
+ h('div', { style: ui.statGrid },
929
+ usageCard(tr('usageHour'), usage.hour, 'hour'),
930
+ usageCard(tr('usageDay'), usage.day, 'day'),
931
+ usageCard(tr('usageWeek'), usage.week, 'week'),
932
+ usageCard(tr('usageMonth'), usage.month, 'month')),
933
+ custom ? h('div', { style: { ...ui.statGrid, gridTemplateColumns: '1fr' } }, usageCard(tr('usageCustom'), custom, 'custom')) : null,
934
+ h('div', { style: ui.rangeRow },
935
+ h('label', { style: ui.field },
936
+ h('span', null, tr('from')),
937
+ h('input', { style: ui.input, type: 'datetime-local', value: range.from, onChange: event => setRange(current => ({ ...current, from: event.target.value })) })),
938
+ h('label', { style: ui.field },
939
+ h('span', null, tr('to')),
940
+ h('input', { style: ui.input, type: 'datetime-local', value: range.to, onChange: event => setRange(current => ({ ...current, to: event.target.value })) })),
941
+ h('button', { style: ui.buttonSecondary, onClick: () => void applyRange() }, tr('apply')),
942
+ h('span', { style: { ...ui.unit, paddingBottom: 6 } }, tr('customHint'))),
943
+ h('div', { style: { paddingBottom: 6 } }, h('span', { style: ui.unit }, tr('rangeEmptyHint')))),
944
+
945
+ h('div', { style: ui.footer },
946
+ failed
947
+ ? h('span', { style: { ...ui.footerText, color: 'var(--dsw-alias-state-error-primary, #ef675c)' } }, failed)
948
+ : message
949
+ ? h('span', { style: { ...ui.footerText, color: 'var(--dsw-alias-state-success-primary, #6ed889)' } }, message)
950
+ : h('span', { style: ui.footerText }, tr('saveHint')),
951
+ h('button', { style: saving ? { ...ui.buttonPrimary, opacity: 0.7, cursor: 'wait' } : ui.buttonPrimary, disabled: saving, onClick: () => void save() },
952
+ saving ? tr('saving') : tr('save'))))
726
953
  }
727
954
 
728
955
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-colophon",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Colophon(卷末)— keep a local, token-free conclusion digest for every conversation, so reopening an old session starts from its final state instead of its full history.",
5
5
  "documentation": "README.md",
6
6
  "license": "MIT",