dsh-colophon 0.2.2 → 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 +276 -189
  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,7 +37,7 @@ 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
43
  engineRules: '本地规则',
@@ -509,109 +509,231 @@ window.__ModuleLoader__.load({
509
509
  }
510
510
 
511
511
  /** A labelled row: text block on the left, control on the right. */
512
- function Row({ children, last }) {
513
- return h('div', { style: last ? { ...styles.row, ...styles.rowLast } : styles.row }, children)
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)
514
653
  }
515
654
 
516
655
  function LabelBlock({ label, hint }) {
517
- return h('div', { style: styles.labelBlock },
518
- h('span', { style: styles.label }, label),
519
- hint ? h('span', { style: styles.hint }, hint) : null)
656
+ return h('div', { style: ui.labelBlock },
657
+ h('div', { style: ui.label }, label),
658
+ hint ? h('div', { style: ui.hint }, hint) : null)
520
659
  }
521
660
 
522
- /** One card section on the settings page: accent bar + title + optional meta. */
523
- function Card({ title, meta, children }) {
524
- return h('div', { style: styles.card },
525
- h('div', { style: styles.cardHead },
526
- h('div', { style: styles.cardTitle }, h('span', { style: styles.accentBar }), title),
527
- meta ? h('span', { style: styles.cardMeta }, meta) : 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,
528
668
  children)
529
669
  }
530
670
 
531
- /** A full-row toggle: the whole row is the click target, the knob is obvious. */
532
671
  function SwitchRow({ label, hint, checked, onChange, last }) {
533
- const on = checked === true
534
- const toggle = () => onChange(!on)
535
672
  return h('div', {
536
- role: 'switch',
537
- 'aria-checked': on,
538
- tabIndex: 0,
539
- style: on ? { ...styles.switchRow, ...styles.switchRowOn, ...(last ? styles.rowLast : null) } : { ...styles.switchRow, ...(last ? styles.rowLast : null) },
540
- onClick: toggle,
541
- onKeyDown: event => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); toggle() } },
542
- },
543
- h('div', { style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
544
- h('span', { style: styles.label }, label),
545
- hint ? h('span', { style: styles.hint }, hint) : null),
546
- h('div', { style: on ? { ...styles.switchTrack, ...styles.switchTrackOn } : styles.switchTrack },
547
- h('div', { style: on ? { ...styles.switchKnob, ...styles.switchKnobOn } : styles.switchKnob })))
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) } },
677
+ },
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) } })))
548
681
  }
549
682
 
550
- /** Two-option (or N-option) segmented control, used instead of native selects for the mode fields. */
551
683
  function Segmented({ options, value, onChange }) {
552
- return h('div', { style: styles.segmented, role: 'tablist' },
553
- options.map(option => {
554
- const on = option.value === value
555
- return h('button', {
556
- key: option.value, type: 'button', role: 'tab', 'aria-selected': on,
557
- style: on ? { ...styles.segItem, ...styles.segItemOn } : styles.segItem,
558
- onClick: () => onChange(option.value),
559
- },
560
- h('span', { style: styles.segTitle }, option.label),
561
- option.hint ? h('span', { style: on ? { ...styles.segHint, ...styles.segHintOn } : styles.segHint }, option.hint) : null)
562
- }))
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)))
563
692
  }
564
693
 
565
- function Select({ value, onChange, children, width }) {
566
- return h('div', { style: styles.selectWrap },
567
- h('select', { style: { ...styles.select, width: width ?? 168 }, value, onChange: event => onChange(event.target.value) }, children),
568
- h('span', { style: styles.chevron, 'aria-hidden': 'true' }, '▾'))
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 }, '▾'))
569
698
  }
570
699
 
571
- /** Exactly one numeric input with a trailing unit; used by every numeric setting. */
572
700
  function NumberRow({ label, hint, value, onChange, step, unit, last }) {
573
701
  return h(Row, { last },
574
702
  h(LabelBlock, { label, hint }),
575
- h('div', { style: styles.control },
703
+ h('div', { style: ui.control },
576
704
  h('input', {
577
- style: { ...styles.input, ...styles.inputNum }, type: 'number', step: step ?? 1,
705
+ style: { ...ui.input, ...ui.inputNum }, type: 'number', step: step || 1,
578
706
  value: value ?? '', onChange: event => onChange(Number(event.target.value)),
579
707
  }),
580
- unit ? h('span', { style: styles.unit }, unit) : null))
708
+ unit ? h('span', { style: ui.unit }, unit) : null))
581
709
  }
582
710
 
583
711
  function TextRow({ label, hint, value, onChange, placeholder, width, last }) {
584
712
  return h(Row, { last },
585
713
  h(LabelBlock, { label, hint }),
586
- h('div', { style: styles.control },
714
+ h('div', { style: ui.control },
587
715
  h('input', {
588
- style: { ...styles.input, ...styles.inputText, width: width ?? styles.inputText.width },
589
- value: value ?? '', placeholder, onChange: event => onChange(event.target.value),
716
+ style: { ...ui.input, width: width || 180 }, type: 'text', value: value ?? '', placeholder,
717
+ onChange: event => onChange(event.target.value),
590
718
  })))
591
719
  }
592
720
 
593
- /** Inline status message with one consistent shape: a colored dot + readable text. */
594
721
  function Callout({ tone = 'info', label, children }) {
595
- const palette = {
596
- info: [styles.calloutInfo, '#6d97ff'],
597
- warn: [styles.calloutWarn, '#eecf94'],
598
- error: [styles.calloutError, '#ff9b9b'],
599
- ok: [styles.calloutOk, '#7fd7a2'],
600
- }[tone] || [styles.calloutInfo, '#6d97ff']
601
- return h('div', { style: { ...styles.callout, ...palette[0] }, role: tone === 'error' ? 'alert' : 'status' },
602
- h('span', { style: { ...styles.calloutDot, background: palette[1] } }),
603
- h('span', { style: { minWidth: 0 } },
604
- label ? h('span', { style: styles.calloutLabel }, label) : null,
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,
605
727
  children))
606
728
  }
607
729
 
608
- function StatusPill({ on, onText, offText }) {
609
- return h('span', { style: on ? { ...styles.pill, ...styles.pillOn } : { ...styles.pill, ...styles.pillOff } },
610
- h('span', { style: { ...styles.pillDot, background: on ? '#7fd7a2' : 'rgba(255,255,255,0.35)' } }),
611
- on ? onText : offText)
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)
612
735
  }
613
-
614
- /** Settings page section: unified controls, one palette, one spacing scale. */
736
+ /** Settings page: native DSH layout (rows + hairlines) and token colors. */
615
737
  function ColophonSettings() {
616
738
  const [form, setForm] = useState(null)
617
739
  const [status, setStatus] = useState(null)
@@ -654,11 +776,8 @@ window.__ModuleLoader__.load({
654
776
  setFailed('')
655
777
  try {
656
778
  const patch = {
657
- enabled: form.enabled,
658
- engine: form.engine,
659
- api: form.api,
660
- triggers: form.triggers,
661
- filter: form.filter,
779
+ enabled: form.enabled, engine: form.engine,
780
+ api: form.api, triggers: form.triggers, filter: form.filter,
662
781
  }
663
782
  const value = await callHost('config', { method: 'POST', body: { patch } })
664
783
  setForm(value.config)
@@ -683,52 +802,48 @@ window.__ModuleLoader__.load({
683
802
  const from = Date.parse(range.from)
684
803
  const to = range.to === '' ? Date.now() : Date.parse(range.to)
685
804
  if (!Number.isFinite(from) || !Number.isFinite(to) || from > to) {
686
- setFailed(tr('rangeInvalid'))
687
- setMessage('')
688
- return
805
+ setFailed(tr('rangeInvalid')); setMessage(''); return
689
806
  }
690
- setFailed('')
691
- setCustom(null)
692
- void loadCustom(from, to)
807
+ setFailed(''); setCustom(null); void loadCustom(from, to)
693
808
  }
694
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
+
695
816
  if (!form) {
696
- return h('div', { style: { ...styles.page, padding: 14 } },
817
+ return h('div', { style: ui.page },
697
818
  h(CrashBanner),
698
- h('div', { style: { fontSize: 12, color: '#9aa4b5' } }, failed || tr('loading')))
819
+ h('div', { style: ui.hint }, failed || tr('loading')))
699
820
  }
700
821
 
701
- const usage = status?.usage ?? {}
702
- const usageCard = (label, slot) => h('div', { style: styles.usageCard },
703
- h('div', { style: styles.usageLabel }, label),
704
- h('div', { style: styles.usageValue }, money(slot?.costCNY)),
705
- h('div', { style: styles.usageMeta }, tr('tokensLabel', { tokens: integer(slot?.tokens) }), ' · ', tr('calls', { count: slot?.calls ?? 0 })))
706
-
707
822
  const queueItems = status?.queueItems ?? []
708
823
  const queueCount = Number(status?.queueCount ?? status?.queue ?? 0) || 0
709
824
  const enabled = form.enabled === true
710
825
  const apiOn = form.engine === 'api'
711
826
  const batchOn = form.triggers.closeBatch === true
712
827
 
713
- return h('div', { style: styles.page },
828
+ return h('div', { style: ui.page },
714
829
  h(CrashBanner),
715
- h('div', { style: styles.headCard },
716
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
717
- h('span', { style: styles.headTitle }, '卷末 Colophon'),
830
+ h('div', { style: ui.header },
831
+ h('div', { style: ui.headerRow },
832
+ h('span', { style: ui.title }, '卷末 Colophon'),
718
833
  h(StatusPill, { on: enabled, onText: tr('statusOn'), offText: tr('statusOff') })),
719
- h('div', { style: styles.headSub }, tr('settingsSubtitle')),
720
- h('div', { style: styles.headMeta },
721
- h('span', { style: styles.hint }, tr('saveHint')),
722
- status ? h('span', { style: { ...styles.hint, marginLeft: 'auto' } }, tr('dataRoot'), ':', status.dataRoot) : null)),
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)),
723
838
 
724
- h(Card, { title: tr('basicTitle') },
839
+ h(Group, { title: tr('basicTitle') },
725
840
  h(SwitchRow, {
726
- label: tr('enabled'), hint: tr('enabledHint'), checked: enabled,
727
- onChange: value => updateTop('enabled', value), last: true,
841
+ label: tr('enabled'), hint: tr('enabledHint'), checked: enabled, last: true,
842
+ onChange: value => updateTop('enabled', value),
728
843
  }),
729
844
  h(Row, { last: true },
730
845
  h(LabelBlock, { label: tr('engine'), hint: tr('engineHint') }),
731
- h('div', { style: styles.control },
846
+ h('div', { style: ui.control },
732
847
  h(Segmented, {
733
848
  value: form.engine,
734
849
  onChange: value => updateTop('engine', value),
@@ -738,7 +853,7 @@ window.__ModuleLoader__.load({
738
853
  ],
739
854
  })))),
740
855
 
741
- h(Card, { title: tr('triggers') },
856
+ h(Group, { title: tr('triggers') },
742
857
  h(SwitchRow, {
743
858
  label: tr('onIdle'), hint: tr('onIdleHint'), checked: form.triggers.onIdle === true,
744
859
  onChange: value => update('triggers', 'onIdle', value),
@@ -751,42 +866,24 @@ window.__ModuleLoader__.load({
751
866
  label: tr('closeBatch'), checked: batchOn, last: !batchOn,
752
867
  onChange: value => update('triggers', 'closeBatch', value),
753
868
  }),
754
- batchOn ? h('div', null,
755
- h(NumberRow, {
756
- label: tr('closeBatchMax'), unit: tr('unitSessions'), step: 1,
757
- value: form.triggers.closeBatchMaxSessions, last: true,
758
- onChange: value => update('triggers', 'closeBatchMaxSessions', value),
759
- }),
760
- h(Callout, { tone: 'warn', label: tr('note') }, tr('closeBatchWarn'))) : null),
761
-
762
- h(Card, { title: tr('apiSection'), meta: h(StatusPill, { on: apiOn, onText: tr('apiOn'), offText: tr('apiOff') }) },
763
- h(Callout, { tone: 'info' }, tr('apiNote')),
869
+ batchOn ? h(NumberRow, {
870
+ label: tr('closeBatchMax'), unit: tr('unitSessions'), step: 1,
871
+ value: form.triggers.closeBatchMaxSessions, last: true,
872
+ onChange: value => update('triggers', 'closeBatchMaxSessions', value),
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')),
764
878
  h(TextRow, { label: tr('provider'), hint: 'deepseek-official', value: form.api.provider, width: 200, onChange: value => update('api', 'provider', value) }),
765
879
  h(TextRow, { label: tr('model'), hint: 'deepseek-chat', value: form.api.model, width: 200, onChange: value => update('api', 'model', value) }),
766
- h(Row, null,
767
- h(LabelBlock, { label: tr('priceIn'), hint: tr('unitPrice') }),
768
- h('div', { style: styles.control },
769
- h('input', {
770
- style: { ...styles.input, ...styles.inputNum }, type: 'number', step: 0.1,
771
- value: form.api.priceInCNYPerM ?? '', onChange: event => update('api', 'priceInCNYPerM', Number(event.target.value)),
772
- }),
773
- h('span', { style: styles.unit }, '元')),
774
- ),
775
- h(NumberRow, {
776
- label: tr('priceOut'), hint: tr('unitPrice'), step: 0.1, unit: '元',
777
- value: form.api.priceOutCNYPerM, onChange: value => update('api', 'priceOutCNYPerM', value),
778
- }),
779
- h(NumberRow, {
780
- label: tr('perSummaryCap'), hint: tr('perSummaryCapHint'), step: 0.01, unit: '元',
781
- value: form.api.maxCostPerSummaryCNY, onChange: value => update('api', 'maxCostPerSummaryCNY', value),
782
- }),
783
- h(NumberRow, {
784
- label: tr('dailyBudget'), hint: tr('dailyBudgetHint'), step: 1000, unit: 'tokens',
785
- value: form.api.dailyTokenBudget, onChange: value => update('api', 'dailyTokenBudget', value),
786
- }),
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) }),
787
884
  h(Row, { last: !(apiOn && status && status.apiAvailable === false) },
788
885
  h(LabelBlock, { label: tr('overCap'), hint: tr('overCapHint') }),
789
- h('div', { style: styles.control },
886
+ h('div', { style: ui.control },
790
887
  h(Segmented, {
791
888
  value: form.api.overCap,
792
889
  onChange: value => update('api', 'overCap', value),
@@ -799,69 +896,59 @@ window.__ModuleLoader__.load({
799
896
  ? h(Callout, { tone: 'warn', label: tr('note') }, tr('apiUnavailable'))
800
897
  : null),
801
898
 
802
- h(Card, { title: tr('filter') },
803
- h(NumberRow, {
804
- label: tr('minMessages'), hint: tr('minMessagesHint'), unit: tr('unitMessages'),
805
- value: form.filter.minMessages, onChange: value => update('filter', 'minMessages', value),
806
- }),
807
- h(NumberRow, {
808
- label: tr('minTokens'), hint: tr('minTokensHint'), unit: 'tokens', step: 500, last: true,
809
- value: form.filter.minTokens, onChange: value => update('filter', 'minTokens', value),
810
- })),
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) })),
811
902
 
812
- h(Card, { title: tr('queueTitle'), meta: h(StatusPill, { on: queueCount > 0, onText: `${queueCount}`, offText: `0` }) },
813
- h('div', { style: { ...styles.hint, padding: '10px 14px 2px' } }, tr('queueHint')),
903
+ h(Group, { title: tr('queueTitle'), meta: queueCount > 0 ? String(queueCount) : tr('queueEmpty') },
814
904
  queueItems.length === 0
815
- ? h('div', { style: styles.emptyBox }, tr('queueEmpty'))
816
- : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '10px 14px 2px' } },
817
- 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 },
818
908
  h('span', { style: { fontWeight: 600 } }, String(item.sessionId).slice(0, 14)),
819
- h('span', { style: styles.hint }, tr('queueReason', { reason: item.reason })),
820
- h('span', { style: { ...styles.hint, marginLeft: 'auto' } }, new Date(item.at).toLocaleString())))),
821
- h('div', { style: styles.actionsBar },
822
- h('button', {
823
- style: queueCount === 0 ? { ...styles.buttonSecondary, ...styles.buttonDisabled } : styles.buttonSecondary,
824
- disabled: queueCount === 0,
825
- onClick: async () => {
826
- setFailed('')
827
- try {
828
- await callHost('queue/run', { method: 'POST', body: {} })
829
- setStatus(await callHost('status'))
830
- setMessage(tr('queueRun'))
831
- } catch (cause) {
832
- setFailed(String(cause?.message ?? cause))
833
- }
834
- },
835
- }, tr('queueProcess')))),
836
-
837
- h(Card, { title: tr('usage'), meta: h('span', { style: styles.hint }, tr('localZero')) },
838
- h('div', { style: styles.usageGrid },
839
- usageCard(tr('usageHour'), usage.hour),
840
- usageCard(tr('usageDay'), usage.day),
841
- usageCard(tr('usageWeek'), usage.week),
842
- usageCard(tr('usageMonth'), usage.month)),
843
- custom ? h('div', { style: { ...styles.usageGrid, gridTemplateColumns: 'repeat(1, minmax(0,1fr))', paddingTop: 8 } },
844
- usageCard(tr('usageCustom'), custom)) : null,
845
- h('div', { style: { display: 'flex', alignItems: 'flex-end', gap: 10, flexWrap: 'wrap', padding: '12px 14px 4px' } },
846
- h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
847
- h('span', { style: styles.unit }, tr('from')),
848
- h('input', { style: styles.input, type: 'datetime-local', value: range.from,
849
- onChange: event => setRange(current => ({ ...current, from: event.target.value })) })),
850
- h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
851
- h('span', { style: styles.unit }, tr('to')),
852
- h('input', { style: styles.input, type: 'datetime-local', value: range.to,
853
- onChange: event => setRange(current => ({ ...current, to: event.target.value })) })),
854
- h('button', { style: styles.buttonSecondary, onClick: () => void applyRange() }, tr('apply')),
855
- custom ? null : h('span', { style: styles.unit }, tr('customHint'))),
856
- h('div', { style: { padding: '0 14px 12px' } }, h('span', { style: styles.unit }, tr('rangeEmptyHint')))),
857
-
858
- h('div', { style: styles.footer },
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 },
859
946
  failed
860
- ? h('span', { style: { ...styles.footerText, color: '#ffb3b3' } }, failed)
947
+ ? h('span', { style: { ...ui.footerText, color: 'var(--dsw-alias-state-error-primary, #ef675c)' } }, failed)
861
948
  : message
862
- ? h('span', { style: { ...styles.footerText, color: '#8fe0b1' } }, message)
863
- : h('span', { style: styles.footerText }, tr('saveHint')),
864
- h('button', { style: saving ? { ...styles.buttonPrimary, opacity: 0.7 } : styles.buttonPrimary, disabled: saving, onClick: () => void save() },
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() },
865
952
  saving ? tr('saving') : tr('save'))))
866
953
  }
867
954
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-colophon",
3
- "version": "0.2.2",
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",