dsh-session-superagent 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -418,7 +418,7 @@ window.__ModuleLoader__.load({
418
418
  }
419
419
 
420
420
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
421
- const CLIENT_VERSION = '0.10.0'
421
+ const CLIENT_VERSION = '0.10.2'
422
422
  // SEMVER_COMPARATOR_SOURCE_START
423
423
  // This block is duplicated verbatim in client.js because the browser UMD cannot import ESM.
424
424
  // test/update-semver.test.mjs audits both copies and exercises their behavior.
@@ -1038,7 +1038,14 @@ window.__ModuleLoader__.load({
1038
1038
  const parsed = Number(value)
1039
1039
  return Number.isFinite(parsed) ? parsed : undefined
1040
1040
  }
1041
- const watcherValuesFrom = (watcher) => ({
1041
+ // ack 默认值来自 /state.defaultAckLabels(issue #11);老服务端没有这个字段时仍回落旧字面量。
1042
+ const ACK_LABEL_FALLBACK = { github: '主理鱼:已处理', gitee: '主理鱼-已处理' }
1043
+ const ackLabelFallback = (watcher, defaults) => {
1044
+ const provider = watcher && watcher.provider === 'gitee' ? 'gitee' : 'github'
1045
+ const fromState = defaults && typeof defaults[provider] === 'string' ? defaults[provider].trim() : ''
1046
+ return fromState || ACK_LABEL_FALLBACK[provider]
1047
+ }
1048
+ const watcherValuesFrom = (watcher, ackDefaults) => ({
1042
1049
  repo: watcher.repo || '',
1043
1050
  intervalSec: watcherNumberText(watcher.intervalSec ?? 60),
1044
1051
  labels: (watcher.filters && Array.isArray(watcher.filters.labels) ? watcher.filters.labels : []).join(','),
@@ -1046,7 +1053,7 @@ window.__ModuleLoader__.load({
1046
1053
  assignee: (watcher.filters && watcher.filters.assignee) || '',
1047
1054
  activeHours: watcher.activeHours || '',
1048
1055
  goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
1049
- ackLabel: watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'),
1056
+ ackLabel: watcher.ackLabel || ackLabelFallback(watcher, ackDefaults),
1050
1057
  onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
1051
1058
  allowAuthors: (watcher.filters && Array.isArray(watcher.filters.allowAuthors) ? watcher.filters.allowAuthors : []).join(', '),
1052
1059
  observe: !!watcher.observe,
@@ -1684,6 +1691,9 @@ window.__ModuleLoader__.load({
1684
1691
  const [orbitError, setOrbitError] = useState(null)
1685
1692
  const [open, setOpen] = useState(false)
1686
1693
  const [anchor, setAnchor] = useState(null)
1694
+ // 品牌名(issue #11):/state 下发;老服务端没有这个字段时仍是「主理鱼」。
1695
+ // 只能在末尾追加状态槽,前面的位置契约(观测/删除确认)保持不变。
1696
+ const [brandName, setBrandName] = useState('主理鱼')
1687
1697
  const btnRef = useRef(null)
1688
1698
  const panelRef = useRef(null)
1689
1699
  const actionLocks = useRef(new Set())
@@ -1706,6 +1716,7 @@ window.__ModuleLoader__.load({
1706
1716
  const body = await call('/state')
1707
1717
  if (!orbitAlive.current || sequence !== stateSequence.current) return { applied: false, ok: true }
1708
1718
  setWatchers(Array.isArray(body && body.watchers) ? body.watchers : [])
1719
+ setBrandName((typeof (body && body.brandName) === 'string' && body.brandName.trim()) || '主理鱼')
1709
1720
  setOrbitError((current) => isReadError(current) ? null : current)
1710
1721
  return { applied: true, ok: true }
1711
1722
  } catch (error) {
@@ -1784,9 +1795,9 @@ window.__ModuleLoader__.load({
1784
1795
  const running = list.filter((w) => orbitStateOf(w) === 'active').length
1785
1796
  const broken = list.filter((w) => orbitStateOf(w) === 'error').length
1786
1797
  const summary = readError && watchers === null
1787
- ? '读不到主理鱼状态'
1798
+ ? '读不到' + brandName + '状态'
1788
1799
  : list.length === 0
1789
- ? '还没有主理鱼'
1800
+ ? '还没有' + brandName
1790
1801
  : '会话级 superagent:' + running + ' 运行中'
1791
1802
  + (broken ? ',' + broken + ' 异常' : '')
1792
1803
  + '(共 ' + list.length + ' 条)'
@@ -1809,7 +1820,7 @@ window.__ModuleLoader__.load({
1809
1820
  ? readError
1810
1821
  : list.length
1811
1822
  ? list.map((w) => (w.repo + ' · ' + (w.title || '未命名会话') + ' · ' + sessionTag(w.sessionId) + ' · ' + STATE_TEXT[orbitStateOf(w)])).join('\n')
1812
- : '还没有主理鱼 —— 在「主理鱼」页加一条',
1823
+ : '还没有' + brandName + ' —— 在「' + brandName + '」页加一条',
1813
1824
  'aria-label': summary,
1814
1825
  'aria-expanded': open ? 'true' : 'false',
1815
1826
  className: cx('dt-btn', 'dt-btn-ghost', 'sa-orbit-trigger', watchers === null && 'is-loading'),
@@ -1979,7 +1990,7 @@ window.__ModuleLoader__.load({
1979
1990
 
1980
1991
  const panelBody = h(React.Fragment, null,
1981
1992
  h('div', { className: 'sa-dock-head' },
1982
- h('span', { className: 'sa-dock-title' }, '主理鱼'),
1993
+ h('span', { className: 'sa-dock-title' }, brandName),
1983
1994
  // 和面板统计条同一套官方素材:dt-stat(数值强 + 单位弱),不再自己发明 sa-dock-metric-*
1984
1995
  h(Stat, {
1985
1996
  className: 'sa-dock-metric',
@@ -1990,13 +2001,13 @@ window.__ModuleLoader__.load({
1990
2001
  watchers === null
1991
2002
  ? (!readError ? h('div', { className: 'sa-dock-empty' }, '正在读取…') : null)
1992
2003
  : list.length === 0
1993
- ? h('div', { className: 'sa-dock-empty' }, '还没有。在「主理鱼」标签页填 owner/name 加一条。')
2004
+ ? h('div', { className: 'sa-dock-empty' }, '还没有。在「' + brandName + '」标签页填 owner/name 加一条。')
1994
2005
  : h(hostOrbitRow ? 'ul' : 'div', { className: 'sa-dock-rows' }, rows),
1995
2006
  // 读失败与写操作失败分开说;旧列表仍可保留在错误上方。
1996
2007
  readError ? h('div', { className: 'sa-dock-err', role: 'alert' }, readError) : null,
1997
2008
  !readError && orbitError ? h('div', { className: 'sa-dock-err', role: 'alert' }, '操作失败:' + orbitError) : null,
1998
2009
  list.length > 0
1999
- ? h('div', { className: 'sa-dock-foot' }, '详细状态与凭证在「主理鱼」标签页')
2010
+ ? h('div', { className: 'sa-dock-foot' }, '详细状态与凭证在「' + brandName + '」标签页')
2000
2011
  : null)
2001
2012
 
2002
2013
  const panel = hostOrbit
@@ -2285,10 +2296,13 @@ window.__ModuleLoader__.load({
2285
2296
  const body = snap.body || {}
2286
2297
  // 默认值提示从后端读:写死 12/3/6 会在常量变化后变成谎话(JSON Schema 的 default 也是这个用法)
2287
2298
  const DEFAULTS = body.defaults || {}
2299
+ // 品牌与默认 ack 都来自 /state(issue #11);缺省时保持 0.10.0 的文案。
2300
+ const BRAND = (typeof body.brandName === 'string' && body.brandName.trim()) || '主理鱼'
2301
+ const ACK_DEFAULTS = body.defaultAckLabels || null
2288
2302
  const watchers = body.watchers || []
2289
2303
  // 行内编辑只有这一条入口:clean 维持原直达行为;dirty 先确认,取消绝不重置 draft/touched。
2290
2304
  const applyWatcherEditor = (watcher, nextKey) => {
2291
- const values = watcherValuesFrom(watcher)
2305
+ const values = watcherValuesFrom(watcher, ACK_DEFAULTS)
2292
2306
  setEditing(nextKey)
2293
2307
  touchedRef.current = new Set()
2294
2308
  editSnapshotRef.current = nextKey ? { key: nextKey, values } : null
@@ -2300,7 +2314,7 @@ window.__ModuleLoader__.load({
2300
2314
  activeHours: watcher.activeHours || '',
2301
2315
  // `watcher.goal` 可能是 goalView 对象;输入框只能接收已展开的字符串。
2302
2316
  goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
2303
- ackLabel: watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'),
2317
+ ackLabel: watcher.ackLabel || ackLabelFallback(watcher, ACK_DEFAULTS),
2304
2318
  onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
2305
2319
  allowAuthors: (watcher.filters && watcher.filters.allowAuthors ? watcher.filters.allowAuthors : []).join(', '),
2306
2320
  observe: !!watcher.observe,
@@ -2321,7 +2335,7 @@ window.__ModuleLoader__.load({
2321
2335
  const editingWatcher = watchers.find((watcher) => watcher.repo + '#' + watcher.sessionId === editing)
2322
2336
  const editingOpening = editSnapshotRef.current && editSnapshotRef.current.key === editing
2323
2337
  ? editSnapshotRef.current.values
2324
- : editingWatcher ? watcherValuesFrom(editingWatcher) : null
2338
+ : editingWatcher ? watcherValuesFrom(editingWatcher, ACK_DEFAULTS) : null
2325
2339
  const editingDirty = Boolean(editing && editingOpening && (
2326
2340
  touchedRef.current.size > 0 || watcherDirty({ ...editingOpening, ...draft }, editingOpening)))
2327
2341
  const pendingCollapseKey = glossary && glossary.type === 'watcher-draft' && !glossary.nextKey
@@ -2624,7 +2638,7 @@ window.__ModuleLoader__.load({
2624
2638
  const rowBody = h('div', { className: 'dt-ticket-body' },
2625
2639
  h('div', { className: 'dt-row-title' },
2626
2640
  h('button', {
2627
- type: 'button', className: 'dt-open', title: '展开或收起这条主理鱼的设置',
2641
+ type: 'button', className: 'dt-open', title: '展开或收起这条' + BRAND + '的设置',
2628
2642
  'aria-expanded': displayedEditing === key, onClick: () => toggleWatcherEditor(watcher),
2629
2643
  }, watcher.repo)),
2630
2644
  pauseNote(watcher),
@@ -2640,7 +2654,7 @@ window.__ModuleLoader__.load({
2640
2654
  watcher.isolated ? h(Tag, null, isolationText(watcher)) : null,
2641
2655
  filterText(watcher.filters) ? h(Tag, null, filterText(watcher.filters)) : null,
2642
2656
  // ack 标签决定这条是否还会被叫醒,不能只在工具参数里出现。
2643
- h(Tag, { tone: 'quiet' }, '回执 ' + (watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'))),
2657
+ h(Tag, { tone: 'quiet' }, '回执 ' + (watcher.ackLabel || ackLabelFallback(watcher, ACK_DEFAULTS))),
2644
2658
  watcher.queuedWakes > 0 ? h(Tag, { tone: 'warning' }, '排队 ' + watcher.queuedWakes) : null,
2645
2659
  backoffText(watcher) ? h(Tag, { tone: 'warning' }, backoffText(watcher)) : null),
2646
2660
  // 三行,各管一件事:① 是谁 ② 节律与最近结果 ③ 目标
@@ -2714,7 +2728,7 @@ window.__ModuleLoader__.load({
2714
2728
  })))
2715
2729
  const opening = editSnapshotRef.current && editSnapshotRef.current.key === key
2716
2730
  ? editSnapshotRef.current.values
2717
- : watcherValuesFrom(watcher)
2731
+ : watcherValuesFrom(watcher, ACK_DEFAULTS)
2718
2732
  const editorValue = { ...opening, ...draft }
2719
2733
  const editor = displayedEditing === key
2720
2734
  ? h(WatcherForm, {
@@ -2881,7 +2895,7 @@ window.__ModuleLoader__.load({
2881
2895
  filterSummary,
2882
2896
  h('div', { className: 'dt-stats', key: 'stats' },
2883
2897
  h(Stat, {
2884
- key: 'all', value: watchers.length, unit: '条主理鱼',
2898
+ key: 'all', value: watchers.length, unit: '条' + BRAND,
2885
2899
  active: stateFilter === null, onClick: () => setStateFilter(null),
2886
2900
  }),
2887
2901
  h(Stat, {
@@ -2958,16 +2972,16 @@ window.__ModuleLoader__.load({
2958
2972
  '代码已更新到 ' + body.installedVersion + ',但宿主还在跑 ' + body.runningVersion
2959
2973
  + ' —— 服务端改动需要重启宿主才生效(客户端部分已生效,所以界面可能看起来是新的)。')
2960
2974
  : null,
2961
- h(Section, { key: 'list', title: needle ? '搜索结果' : '主理鱼', count: visible.length },
2975
+ h(Section, { key: 'list', title: needle ? '搜索结果' : BRAND, count: visible.length },
2962
2976
  watchers.length === 0
2963
2977
  ? h(Onboarding, { onStart: () => setTab('trigger') })
2964
2978
  : visible.length === 0
2965
2979
  ? h('div', { className: 'dt-empty' },
2966
2980
  h(Hint, null, needle
2967
- ? '没有匹配「' + search.trim() + '」的主理鱼。'
2981
+ ? '没有匹配「' + search.trim() + '」的' + BRAND + '。'
2968
2982
  : hasActiveFilters
2969
- ? '没有符合当前筛选条件的主理鱼。'
2970
- : '当前没有可显示的主理鱼。'),
2983
+ ? '没有符合当前筛选条件的' + BRAND + '。'
2984
+ : '当前没有可显示的' + BRAND + '。'),
2971
2985
  hasActiveFilters
2972
2986
  ? h('div', { className: 'dt-actions' },
2973
2987
  h(Btn, { size: 'sm', variant: 'outline', onClick: clearAllFilters }, '清除全部筛选'))
@@ -3055,7 +3069,7 @@ window.__ModuleLoader__.load({
3055
3069
  // 判定页的空态也要给路径:说清「加一条之后这里会出现什么」,而不是一句「还没有主理鱼」
3056
3070
  ? h('div', { className: 'dt-empty' },
3057
3071
  h('p', { className: 'dt-step-title' }, '还没有可判定的记录'),
3058
- h('p', { className: 'dt-step-detail' }, '添加一条主理鱼之后,每轮判定都会记在这里:唤醒、仅观察,或跳过及其原因。'),
3072
+ h('p', { className: 'dt-step-detail' }, '添加一条' + BRAND + '之后,每轮判定都会记在这里:唤醒、仅观察,或跳过及其原因。'),
3059
3073
  h('div', { className: 'dt-actions' },
3060
3074
  h(Btn, { size: 'sm', variant: 'primary', onClick: () => setTab('trigger') }, '去添加第一条')))
3061
3075
  : (() => {
@@ -3208,7 +3222,7 @@ window.__ModuleLoader__.load({
3208
3222
  group.silentWakes > 0 ? h('span', { className: 'dt-error-text' }, '未回音 ' + group.silentWakes + ' 次') : null,
3209
3223
  group.errors > 0 ? h('span', { className: 'dt-error-text' }, group.errors + ' 条报错') : null))))))
3210
3224
 
3211
- const trigger = h(Section, { title: '新增主理鱼' },
3225
+ const trigger = h(Section, { title: '新增' + BRAND },
3212
3226
  h(WatcherForm, {
3213
3227
  mode: 'create', idPrefix: 'watcher-new', value: { ...CREATE_WATCHER_VALUES, ...form },
3214
3228
  snapshot: createSnapshotRef.current, defaults: DEFAULTS, disabled: !sessionId, sessionId,
@@ -3567,7 +3581,7 @@ window.__ModuleLoader__.load({
3567
3581
  return h('div', { className: 'dt-page' },
3568
3582
  h('div', { className: 'dt-page-head' },
3569
3583
  h('div', null,
3570
- h('h1', { className: 'dt-page-title' }, '主理鱼'),
3584
+ h('h1', { className: 'dt-page-title' }, BRAND),
3571
3585
  h('span', { className: 'dt-hint' },
3572
3586
  (body.sessionTitle ? '会话:' + body.sessionTitle + ' · ' : '')
3573
3587
  + (sessionId ? '盯办 + 主动办:仓库有动静就叫醒本会话' : '(在会话里打开本面板,才能把仓库绑到会话上)'))),
@@ -3662,16 +3676,16 @@ window.__ModuleLoader__.load({
3662
3676
  onClick: () => copyText(AGENTS_SNIPPET, '规则已复制,粘贴到 AGENTS.md 末尾即可'),
3663
3677
  }, '复制这段规则'),
3664
3678
  h(Btn, { size: 'sm', variant: 'ghost', onClick: () => setGlossary(false) }, '关闭'))) : null,
3665
- h(PanelModal, { open: glossary === true, title: '主理鱼术语表', onClose: () => setGlossary(false) },
3679
+ h(PanelModal, { open: glossary === true, title: BRAND + '术语表', onClose: () => setGlossary(false) },
3666
3680
  h(KeyValues, { rows: [
3667
- ['主理鱼', '一条「盯办」绑定:某个仓库 → 某个会话'],
3681
+ [BRAND, '一条「盯办」绑定:某个仓库 → 某个会话'],
3668
3682
  ['盯', '轮询 issue/PR、按水位去重、冷却期吸收自己的操作'],
3669
3683
  ['办', '唤醒会话后按仓库 AGENTS.md 主动处理,完成后 watch_ack 打标签'],
3670
- ['唤醒', '只在会话空闲(idle)时注入一条【主理鱼】消息'],
3684
+ ['唤醒', '只在会话空闲(idle)时注入一条【' + BRAND + '】消息'],
3671
3685
  ['过滤', '标签白名单/黑名单、只看已指派、跳过机器人/草稿/已关闭'],
3672
3686
  ['时段', 'activeHours,比如 09:00-23:00,时段外只攒不唤醒'],
3673
3687
  ['隔离', 'isolated:每次唤醒开一次性 git worktree,改副本不碰主工作区'],
3674
- ['ack', '处理完给条目打「主理鱼:已处理」标签,轮询直接跳过'],
3688
+ ['ack', '处理完给条目打「' + (ACK_DEFAULTS && ACK_DEFAULTS.github ? ACK_DEFAULTS.github : '主理鱼:已处理') + '」标签,轮询直接跳过'],
3675
3689
  ['goal', '会话目标(ctx.goals),和 /goal 命令同一份状态'],
3676
3690
  ['凭证', 'token 存在服务端 secrets.json,面板只显示是否已配置'],
3677
3691
  ['上限', '两种:单条守每小时最多 6 次、整条会话 12 次(面板里可调);和 GitHub 的限流不是一回事'],
@@ -0,0 +1,65 @@
1
+ # 重启之后:三条命令 + 三个动作
2
+
3
+ > 服务端改动只有**重启宿主**才生效。重启完照这个清单走一遍,5 分钟。
4
+ > 现在线上是 0.8.38,仓库已到 0.8.92 —— 也就是说下面这些"新特性"**一次都还没在真机跑过**。
5
+
6
+ ## 一、三条命令
7
+
8
+ ### 1. 一条命令看全貌
9
+
10
+ ```bash
11
+ node scripts/verify-live.mjs # 默认 http://127.0.0.1:65466
12
+ node scripts/verify-live.mjs http://127.0.0.1:<其它端口>
13
+ ```
14
+
15
+ 会逐项打印 PASS/FAIL。**重启前**在本机实测的输出是:
16
+
17
+ ```
18
+ PASS /state 可达 HTTP 200,26ms
19
+ FAIL 版本对齐 线上 0.8.38 ≠ 仓库 0.8.91 —— 需要重启宿主(不是重装)
20
+ FAIL 响应带 ETag 没有 etag 头:这个版本早于 0.8.85
21
+ FAIL 条件请求可用(304) 跳过:没有 ETag
22
+ FAIL /diagnose 可用 HTTP 404
23
+ PASS /update 可用 current=0.8.38 latest=0.8.90
24
+ PASS 守的投影完整 1 条,其中隔离执行 1 条
25
+ ```
26
+
27
+ **重启后预期**:7 项全 PASS,其中「版本对齐」「ETag」「304」「/diagnose」四项会翻绿。
28
+
29
+ ### 2. 手工看重定向是否安全(可选)
30
+
31
+ ```bash
32
+ curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:65466/session-superagent/state
33
+ # 期望 200
34
+ ```
35
+
36
+ ### 3. 确认没有编译/挂载级别的问题
37
+
38
+ ```bash
39
+ node scripts/preflight.mjs
40
+ # 期望 9 项全 PASS(含「离线挂载冒烟」与「契约快照」)
41
+ ```
42
+
43
+ ## 二、三个界面动作
44
+
45
+ | 动作 | 期望 |
46
+ |---|---|
47
+ | 打开主理鱼面板 → 设置 → **诊断** → 复制诊断信息 | 剪贴板里出现「主理鱼诊断 · 时间 / 插件版本 0.8.9x / 挂载: routes=8 failed=0」 |
48
+ | 面板 → 设置 → **来源** → 看「权限范围」 | 显示 token 的 scope 列表(不是一直「正在探测…」) |
49
+ | 「总览」里找一条守 → 点行标题展开 → 看有没有「**隔离区保留天数**」 | 有输入框;保存后刷新仍在 |
50
+
51
+ ## 三、如果哪一项没翻绿
52
+
53
+ | 症状 | 原因 | 处理 |
54
+ |---|---|---|
55
+ | 版本对齐仍是旧值 | 宿主没真重启(只是关窗口) | 用托盘退出再启动;不是重装 |
56
+ | `/diagnose` 404 | 同上(旧代码) | 同上 |
57
+ | ETag 缺失 | 同上 | 同上 |
58
+ | preflight 的「离线挂载冒烟」红 | 新增文件没同步进 profile | `node scripts/sync-profile.mjs --repair` 后重启 |
59
+ | preflight 的「契约快照」红 | 有人改了工具/路由形状 | 确认是有意改动后 `node scripts/contract.mjs --update` |
60
+
61
+ ## 四、验证完请回填(一行就够)
62
+
63
+ ```
64
+ 重启后核对:0.8.92 / routes=8 / etag=有 / diagnose=有 —— 通过 or 哪项没过
65
+ ```