dsh-todo-float-ball 0.14.4 → 0.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +151 -0
- package/README.md +18 -13
- package/README.zh.md +10 -7
- package/docs/DATA-CHANNELS.md +32 -4
- package/lib/client.js +105 -21
- package/lib/index.js +28 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,156 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.6 — 2026-10-19
|
|
4
|
+
|
|
5
|
+
### 🔴 修复:悬浮球进度与官方 todo 面板不一致(球显示 9/18,官方只有 6 条 / 0 完成)
|
|
6
|
+
|
|
7
|
+
**症状**:官方面板显示 6 条任务(1 进行中 · 5 待处理,0 完成),悬浮球却显示 `9/18`;
|
|
8
|
+
完成数与总数双双偏大,且越用越离谱,重启也不恢复。
|
|
9
|
+
|
|
10
|
+
**根因**(`lib/client.js` 快照边界 `snapLen`):
|
|
11
|
+
2026-09-28 为避免球在 `0/1 -> 7/9 -> 0/1` 之间闪烁,把 `snapLen` 改成了
|
|
12
|
+
单调递增的高水位 `Math.min(Math.max(prevSnap, norm.length), merged.length)`。
|
|
13
|
+
它只增不减:一旦被某一轮长计划顶到 18,后续每一轮都把旧计划的行走当成
|
|
14
|
+
live 任务统计 —— `todos.slice(0, snapLen)` 里混进了上一轮 font-enhancer 的 12 条历史任务。
|
|
15
|
+
|
|
16
|
+
**修复**:权威通道的一帧就是当前计划的全部(`todo_write` 是整表替换),
|
|
17
|
+
因此 `snapLen = norm.length`,其后的合并项即为历史。DOM fallback 仍然不抬高边界,
|
|
18
|
+
且服务端已给出边界时不再用它。
|
|
19
|
+
|
|
20
|
+
当年那个闪烁的**真实来源**已被别处掐断:`readOfficialPanel()` 现在一开头就用
|
|
21
|
+
`hasPrimaryData()` 检查,权威通道已发声的会话直接 return,不会再往这里写一行的「plan」。
|
|
22
|
+
|
|
23
|
+
**验证**(真机探针,日志 `[tfb3]`):
|
|
24
|
+
```
|
|
25
|
+
FRAME norm=6 prevSnap=18 merged=100 snapLen=6 fallback=false
|
|
26
|
+
FINAL snapLen=6 merged=100 ball={"cls":"tfb-active","label":"0/6"}
|
|
27
|
+
official="1 进行中 · 5 待处理" -> done=0 total=6
|
|
28
|
+
MATCH=true
|
|
29
|
+
```
|
|
30
|
+
修复前同一探针输出为 `label:"9/18"`、`MATCH=false`。
|
|
31
|
+
|
|
32
|
+
> 顺带记录一次走错的路:第一版修复用「本帧内容是否为旧窗口的子集」判定计划是否更替。
|
|
33
|
+
> 该判据在**追加式合并**的数据结构上恒为真(旧窗口本已含有本帧的行),
|
|
34
|
+
> 实测完全无法收缩边界。已回退。
|
|
35
|
+
|
|
36
|
+
### 🔴 修复:热重载后新实例画不出 UI,屏幕上是已死实例留下的旧数字
|
|
37
|
+
|
|
38
|
+
**症状**:`snapLen` 修好、数据层实测 `ballState()` 已返回 `7/12`(与官方 12 条完全一致),
|
|
39
|
+
但屏幕上那个胶囊仍然显示 `11/18`,反复硬重载也不变。
|
|
40
|
+
|
|
41
|
+
**根因**(`lib/client.js` 的 `buildUI()`):
|
|
42
|
+
```js
|
|
43
|
+
if (document.getElementById(BALL_ID)) return; // ← 旧守卫
|
|
44
|
+
```
|
|
45
|
+
热重载(`Ctrl+Shift+R`)不会卸载上一次实例创建的那个 `#dsh-tfb-root` shadow host。
|
|
46
|
+
新实例进 `buildUI()` 时发现 id 已存在就直接 `return`,于是:
|
|
47
|
+
|
|
48
|
+
- `ui.ball` 恒为 `null`;
|
|
49
|
+
- `renderBall()` 第一行 `if (!ui.ball) return;` 使每次渲染都是空操作;
|
|
50
|
+
- 屏幕上留下的是**上一个已死实例**算出来的数字,而那个实例的数据早已不再更新。
|
|
51
|
+
|
|
52
|
+
实测取证(日志 `[tfb13]` / `[tfb12]`):
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
[tfb13] APPLY#1 at ...
|
|
56
|
+
[tfb13] inst1 t5 ballState=7/12 snapshotList=12 ballLabel=11/18 renderCalls=0 lastSig=null
|
|
57
|
+
[tfb12] HOSTS=1 [h0] label='11/18' cls='tfb-ball tfb-active tfb-capsule'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`renderCalls=0` 是最硬的证据:新实例一次都没画过,屏幕上的数字必然属于别人。
|
|
61
|
+
这与 `dsh-font-enhancer` 的 `#dsh-fe-root` 是同一类 bug(同源:`buildUI` 开头用
|
|
62
|
+
「id 已存在就跳过」来防重复建 UI,但没分清那个元素是不是自己的)。
|
|
63
|
+
|
|
64
|
+
**修复**:把「跳过」改成**归属判定** —— 只有当现存 host 的 shadow root 恰好是
|
|
65
|
+
本实例持有的 `ui.shadow` 时才短路;否则视为上一代残留,`remove()` 后重建、
|
|
66
|
+
并同步清空 `ui` 与 `lastBallSig`(否则重建后第一帧会被 `sig` 缓存判为「没变化」而跳过)。
|
|
67
|
+
|
|
68
|
+
**验证**(真机探针,日志 `[tfb14]`,修复后):
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
[tfb14] t5 hosts=1 ballState=5/10 snapshot=10 ballLabel=5/10
|
|
72
|
+
[tfb14] t5 OFFICIAL='任务5 已完成 · 1 进行中 · 4 待处理'
|
|
73
|
+
[tfb14] t5 dividers=1 divTxt='当前进度 · 5/10 完成'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`ballLabel` 与 `ballState` 终于一致;球数字 = 官方 10 条(5 完成 + 1 进行中 + 4 待处理)。
|
|
77
|
+
|
|
78
|
+
### ✨ 新增:展开清单里「历史」与「当前进度」之间的分界线
|
|
79
|
+
|
|
80
|
+
按「球上的数字只反映当前这一轮;展开的清单里既要有历史贡献、也要有官方最新清单,
|
|
81
|
+
两段之间要有明显且美观的分界」的要求,`historySectionHtml()` 现在按此顺序渲染:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
▾ 已完成历史 N 条 (可折叠,带 🧹)
|
|
85
|
+
▸ 被抛弃的历史任务 N 条 (可折叠,带 🧹)
|
|
86
|
+
───────── 当前进度 · 5/10 完成 ───────── ← 新增分界线
|
|
87
|
+
· 当前轮任务 1
|
|
88
|
+
· 当前轮任务 2
|
|
89
|
+
🧹 一键清理全部历史
|
|
90
|
+
♻️ 一键恢复全部隐藏的历史
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
分界线由三段组成(`.tfb-divider` / `.tfb-divider-line` / `.tfb-divider-txt`):
|
|
94
|
+
两侧是两端渐隐的 1px 细线,中间是圆角小胶囊标签,两套皮肤各自配色;
|
|
95
|
+
`pointer-events:none` 保证它不会挡住列表项点击。
|
|
96
|
+
|
|
97
|
+
### 修复:`primary` 未持久化 + 同签名帧不修正边界
|
|
98
|
+
|
|
99
|
+
两个配套缺陷,都会让「权威通道已生效」这件事在刷新后被忘掉:
|
|
100
|
+
|
|
101
|
+
1. `persistSoon()` 存 `{todos, sig, at, snapLen}` 时漏了 `primary`,
|
|
102
|
+
`restorePersisted()` 恢复时也不设它 → 页面一刷新 `primary` 恒 `undefined`
|
|
103
|
+
→ `hasPrimaryData()`(要求 `!!rec.primary`)恒 `false`
|
|
104
|
+
→ **DOM fallback 的闸门永久敞开**,面板文本又会跨界污染快照。
|
|
105
|
+
2. `setSessionTodos()` 的签名去重分支 `if (b && b.sig === sig) { b.stale = false; return false; }`
|
|
106
|
+
直接 early return,**不更新 `snapLen`** —— 被旧帧膨胀过的边界就此冻结,
|
|
107
|
+
即使之后每帧都是正确的权威数据也修不回来。
|
|
108
|
+
|
|
109
|
+
现在:持久化与恢复都带 `primary`;同签名帧只要发现 `snapLen` 或 `primary` 不对,
|
|
110
|
+
就地修正并重绘。
|
|
111
|
+
|
|
112
|
+
### 文档:修正与实际功能不一致的描述
|
|
113
|
+
|
|
114
|
+
- 皮肤数 `120` → **`128`**(实跑皮肤目录 IIFE:`ALL.length = 128`,另加「经典(旧版)」分组 6 款)
|
|
115
|
+
- 纪律注入 `约 340 字 / 5 条` → **实测 498 字符 / 6 条规则**(`order=190` 不变)
|
|
116
|
+
- 健康路由示例 `127.0.0.1:43120` → 改为「填你自己的端口」,并说明桌面端默认 `port: 0`
|
|
117
|
+
每次重启换端口、该路由只接受渲染进程请求(`curl` 会得到 `403 Browser access is disabled`)
|
|
118
|
+
- 「watchdog 10 分钟后停止」补全主语:停的是**球的复活看门狗**(300 × 2s),
|
|
119
|
+
皮肤/可见性轮询刻意常驻
|
|
120
|
+
|
|
121
|
+
## 0.14.5 — 2026-10-18
|
|
122
|
+
|
|
123
|
+
### 修复:首工具判定 gate 的三处缺陷(合并社区 PR #1,作者 @WanchengWildMan)
|
|
124
|
+
|
|
125
|
+
本次为**宿主侧纯 bug 修复**,客户端 `lib/client.js` 与上一版逐字节一致(悬浮球与数据同步逻辑未变)。
|
|
126
|
+
|
|
127
|
+
- **缺陷① 计数卡死导致整个 turn 死锁(最严重)**
|
|
128
|
+
旧判据 `toolCallsThisTurn === 1` 命中即 `deny`,而被基准拒绝的调用**不会**回写事件流,计数永久停在 1 → 本 turn 之后**每一个**工具调用都被拒。社区实测被拒 74 次,只能新开一轮才能恢复。
|
|
129
|
+
修复:改用 `dispatchedThisTurn > 1`(只统计**已实际发出**的调用),并在检测到 `todo_write` 后立即置 `hasTodoWriteThisTurn`,补写 todo 后立刻放行。
|
|
130
|
+
|
|
131
|
+
- **缺陷② `run_code` 包装调用无法识别**
|
|
132
|
+
旧代码只认 `exec.name === "todo_write"`。当 `todo_write` 被 `run_code` 包裹执行时,`exec.name` 是 `run_code`,判定必然失败。
|
|
133
|
+
修复:新增 `callArgs.indexOf("todo_write") !== -1` 兜底,脚本内调用 `todo_write` 也能识别。
|
|
134
|
+
|
|
135
|
+
- **缺陷③ 并行批次时序不保证**
|
|
136
|
+
旧判据依赖"本 turn 已有几个 `tool/call`"的顺序,并行批次的事件到达顺序不受保证。
|
|
137
|
+
修复:判定改为"已发出 > 1 且见过工具名 且 未见 todo_write",不再依赖到达顺序。
|
|
138
|
+
|
|
139
|
+
- **新增 fail-open 保护**:本 turn 有调用但一个 `name` 都读不到(宿主事件结构变更)时**放行**,宁可漏拦也不阻塞会话。
|
|
140
|
+
|
|
141
|
+
### 实测验证(2026-10-18)
|
|
142
|
+
|
|
143
|
+
`~/.dsh/logs/desktop-next.log` 中本次运行仅出现 **1 次** deny,补写 `todo_write` 后全部后续调用正常执行;旧版为"永久卡死"。
|
|
144
|
+
|
|
145
|
+
### Fix: three defects in the first-tool gate (merges community PR #1 by @WanchengWildMan)
|
|
146
|
+
|
|
147
|
+
Host-half bug fix only — `lib/client.js` is byte-identical to the previous version.
|
|
148
|
+
|
|
149
|
+
- **Defect 1 — counter deadlock (most severe)**: `toolCallsThisTurn === 1` denied a call that never got appended back, freezing the counter at 1 and rejecting every following call in the turn (74 rejections in the reported case). Now `dispatchedThisTurn > 1` counts only calls already dispatched, and `hasTodoWriteThisTurn` unblocks as soon as a `todo_write` appears.
|
|
150
|
+
- **Defect 2 — `run_code` wrapper not recognised**: only `exec.name === "todo_write"` was matched, so a wrapped call never qualified. Now `callArgs.indexOf("todo_write") !== -1` is checked as a fallback.
|
|
151
|
+
- **Defect 3 — parallel batch ordering**: the old rule depended on arrival order of `tool/call` events, which parallel batches do not guarantee. The new rule is order-independent.
|
|
152
|
+
- **Fail-open guard added**: when a turn has calls but no readable `name` (host event shape changed), the gate allows the call instead of blocking the session.
|
|
153
|
+
|
|
3
154
|
## 0.14.4 — 2026-10-14
|
|
4
155
|
|
|
5
156
|
### 合规性改进(无功能改动)
|
package/README.md
CHANGED
|
@@ -33,10 +33,10 @@ When you give an AI agent a multi-step job in DSH, it records the plan with the
|
|
|
33
33
|
|
|
34
34
|
- **Built for long unattended runs** — DSH agents continue across many turns; you may not look at the screen for ten minutes. The orange glow and `3/8` tell you at a glance that work is still moving, and how far.
|
|
35
35
|
- **Parallel sessions stop being guesswork** — pinning side-by-side columns puts two conversations' progress in one panel; no more clicking back and forth.
|
|
36
|
-
- **Visually consistent with its siblings** — shares one **
|
|
36
|
+
- **Visually consistent with its siblings** — shares one **128-skin** catalogue with the `dsh-skill-browser` and `dsh-font-enhancer` balls (plus the 6 classic skins kept as a separate "legacy" group), so all three switch together and match.
|
|
37
37
|
- **One codebase, two targets** — identical behaviour on Desktop (Electron) and the web UI.
|
|
38
38
|
- **Zero intrusion, zero config** — install and it works; no config files, no changes to the official UI. `Shadow DOM + all:initial` keeps styles isolated, so it cannot clash with your theme or skin plugins.
|
|
39
|
-
- **Reliable data** —
|
|
39
|
+
- **Reliable data** — three-tier sync: the runtime's `sessions` service (authoritative projection) drives the ball; a debounced `MutationObserver` on the official todo panel and a passive transport tap are fallbacks that only speak when the service has produced nothing for that session. **Even when the official strip is collapsed — or unrendered — the ball still has the full list.**
|
|
40
40
|
|
|
41
41
|
## Screenshots
|
|
42
42
|
|
|
@@ -56,7 +56,7 @@ Right-click the ball to collapse it into a slim capsule that shows the running t
|
|
|
56
56
|
|
|
57
57
|
### Skins
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
128 built-in skins (plus a separate "legacy" group holding the 6 pre-catalog skins), shared with the sibling skill-browser / font-enhancer balls so all three stay visually consistent. Groups: 招牌特效 28 / 浓郁深底 38 / 尘埃灰调 20 / 柔光深底 15 / 中性点缀 10 / 浅色纸面 17.
|
|
60
60
|
|
|
61
61
|

|
|
62
62
|
|
|
@@ -87,7 +87,7 @@ It is a pure, read-only companion: the plugin never modifies the official panel,
|
|
|
87
87
|
| 中文 | English |
|
|
88
88
|
|---|---|
|
|
89
89
|
| 点球折叠/展开面板,靠屏幕边缘自动翻侧 | Click to fold/expand; the panel flips sides near the screen edge |
|
|
90
|
-
|
|
|
90
|
+
| 三路数据同步:**主** = 运行时 `sessions` 服务的权威投影帧;**兜底 1** = MutationObserver 抓官方 todo 面板;**兜底 2** = 被动拦截传输帧。兜底仅在权威通道对该会话尚无数据时才发言,官方面板折叠时也有完整清单 | Three-tier sync: **primary** = the runtime `sessions` service (authoritative projection); **fallback 1** = DOM observer on the official panel; **fallback 2** = passive transport tap. Fallbacks only speak while the authoritative channel has produced nothing for that session — full list even when the strip is collapsed |
|
|
91
91
|
| Shadow DOM + `all:initial` 样式隔离,不进不出,主题/皮肤插件互不干扰 | Shadow DOM with `all:initial` — no style leaks in or out, immune to theme/skin plugins |
|
|
92
92
|
| 桌面端(Electron)与网页端同一份代码双端可用 | One codebase for Desktop (Electron) and the web UI |
|
|
93
93
|
|
|
@@ -96,6 +96,8 @@ It is a pure, read-only companion: the plugin never modifies the official panel,
|
|
|
96
96
|
| 中文 | English |
|
|
97
97
|
|---|---|
|
|
98
98
|
| 快照合并不再冲掉旧任务——旧任务进入历史归档区 | Snapshots merge instead of replacing — older todos become a history archive |
|
|
99
|
+
| **球上的数字只反映当前这一轮**(与官方进度条同口径),历史不会把分母撑大 | **The number on the ball covers the current round only** (same basis as the official strip); history never inflates the denominator |
|
|
100
|
+
| **展开清单分两段**:上面是可折叠的历史(已完成历史 / 被抛弃的历史任务),中间一道分界线 `── 当前进度 · 5/10 完成 ──`,下面才是当前轮的任务 | **The expanded list has two sections**: collapsible history on top, a divider `── Current · 5/10 done ──` in the middle, the current round's todos below |
|
|
99
101
|
| 行级 ✕ 隐藏、两个独立折叠行、🧹 批量清理、♻️ 一键恢复、📋 整行复制 | Per-row ✕ hide, two independent fold rows, 🧹 batch cleanup, ♻️ one-click restore, 📋 full-text copy |
|
|
100
102
|
| 📌 固定会话与当前对话共用同一历史渲染器,状态按会话独立 | 📌 Pinned sessions render through the same history renderer, with per-session state |
|
|
101
103
|
| ⇄ 布局切换:上下堆叠 ⇄ 左右并排(左当前列表、右固定会话,带列标题) | ⇄ layout switch: stacked ⇄ side-by-side (current + pinned columns with captions) |
|
|
@@ -104,7 +106,7 @@ It is a pure, read-only companion: the plugin never modifies the official panel,
|
|
|
104
106
|
|
|
105
107
|
| 中文 | English |
|
|
106
108
|
|---|---|
|
|
107
|
-
| 宿主端向每次会话系统提示注入 todo 纪律段(order=190
|
|
109
|
+
| 宿主端向每次会话系统提示注入 todo 纪律段(order=190,6 条规则,实测 498 字符)——装上插件即生效,无需加载技能 | Host injects a stable todo-discipline section (order=190, 6 rules, 498 chars measured) into every session — works the moment the plugin is installed |
|
|
108
110
|
| 硬门:每轮首个工具调用若不是 todo_write 会被拒绝并提示补写(可用 `enforceFirstTodoWrite: false` 关闭) | Hard gate: the first tool call of each turn must be `todo_write` or it is denied (disable with `enforceFirstTodoWrite: false`) |
|
|
109
111
|
| 只有显式布尔 `false` 才关闭;`"false"`/`0`/缺 config 均保持开启 | Only an explicit boolean `false` disables it; `"false"`/`0`/missing config keep it ON |
|
|
110
112
|
|
|
@@ -123,11 +125,11 @@ It is a pure, read-only companion: the plugin never modifies the official panel,
|
|
|
123
125
|
| Live progress | `done/total` on the ball face plus the first active task's content (truncated), updated in real time |
|
|
124
126
|
| Fold / expand | Click the ball to toggle the task panel; the panel opens next to the ball and flips sides when near the screen edge |
|
|
125
127
|
| Status colors | Per-item icons and colors: ✓ completed (green, strikethrough), ▶ in progress (orange), ○ pending (dashed gray); ball itself: orange pulse / green / blue / idle gray |
|
|
126
|
-
|
|
|
128
|
+
| Data sync (3 tiers) | **Primary**: `ctx.sessions.list.subscribe` — the runtime's authoritative `todos` projection, plus a 2 s pull as a safety net. **Fallback 1**: a debounced `MutationObserver` over `[data-testid="todo-panel"]`. **Fallback 2**: a passive tap on `window.fetch` and `WebSocket.onmessage` that only reacts to projection-shaped frames. Fallbacks are gated by `hasPrimaryData()` and stay silent once the service has spoken for a session |
|
|
127
129
|
| Shadow DOM isolation | All UI lives inside an open Shadow DOM with `all:initial` — no style leaks in or out, immune to theme/skin plugins |
|
|
128
130
|
| Dual-end support | Works in DSH Desktop (Electron window) and the web UI (browser) with the same code, because both render the same page; the UI mounts on `<html>` to dodge `transform`-related `position:fixed` breakage |
|
|
129
131
|
| Privacy-friendly | Zero telemetry, zero data upload. The only host-side surface is a loopback-only health route (`/dsh-todo-float-ball/health`) |
|
|
130
|
-
| **Discipline injection (v0.9.0)** | The host injects
|
|
132
|
+
| **Discipline injection (v0.9.0)** | The host injects a 6-rule todo discipline (498 chars measured, `order=190`) into the system prompt of **every session** — **works as soon as the plugin is installed, no skill needs to be loaded**; turn it off with `injectDiscipline: false` |
|
|
131
133
|
| **History archive & panel tools (v0.10.0)** | Merged snapshots no longer wipe older todos — they become a foldable history archive; per-row ✕ hide, two independent fold rows, 🧹 batch cleanup, ♻️ one-click restore, 📋 full-text copy; all counters reflect only the latest snapshot |
|
|
132
134
|
| **Pinned-panel parity & layout switch (v0.11.0)** | 📌 pinned sessions render through the *same* history renderer as the current view (folds, 🧹, ♻️, per-session state and per-session action scoping); the panel header gained a ⇄ button to flip between a stacked layout and a side-by-side layout (left = current list, right = pinned sessions) with per-column captions |
|
|
133
135
|
|
|
@@ -207,10 +209,12 @@ Copy this package folder into your profile's `node_modules` (a real copy — do
|
|
|
207
209
|
After the restart you should see the ball in the bottom-right corner. Verify the host half with:
|
|
208
210
|
|
|
209
211
|
```
|
|
210
|
-
http://127.0.0.1
|
|
212
|
+
http://127.0.0.1:<your DSH port>/dsh-todo-float-ball/health
|
|
211
213
|
→ {"ok":true,"plugin":"dsh-todo-float-ball","version":"<the installed package.json version>"}
|
|
212
214
|
```
|
|
213
215
|
|
|
216
|
+
**Use your actual port.** DSH Desktop defaults to `port: 0` (a fresh random port on every restart), so there is no fixed number to hardcode. Read it from the address bar of the DSH window, or pin it by setting `port` in `%USERPROFILE%\.dsh\desktop-preferences.json`. A fixed `43120` only applies if you set it yourself. The route is also loopback-only and refuses any non-renderer request with `403 Browser access is disabled`, so `curl` will not work unless you enable `browserAccess`.
|
|
217
|
+
|
|
214
218
|
## How it works
|
|
215
219
|
|
|
216
220
|
The official todo data is a **session projection**:
|
|
@@ -219,12 +223,13 @@ The official todo data is a **session projection**:
|
|
|
219
223
|
2. `@deepseek-ai/dsh-client-connection` broadcasts the current value as a control frame: `{type:"projection", sessionId, key:"todos", value:[{content,status}...]}`.
|
|
220
224
|
3. `@deepseek-ai/dsh-client-ui-conversation` renders it as the plan strip above the input box (`[data-testid="todo-panel"]`).
|
|
221
225
|
|
|
222
|
-
This plugin
|
|
226
|
+
This plugin reads from all three surfaces without touching any of them, in strict priority order:
|
|
223
227
|
|
|
224
|
-
- **
|
|
225
|
-
- **
|
|
228
|
+
- **Primary — `sessions` service**: the client half declares `inject: ["sessions"]` and subscribes to the runtime's global session registry (`ctx.sessions.list.subscribe`, with a 2 s pull as a safety net in case a callback stops firing after a shell rebuild). This channel is authoritative: it is the whole list, it carries history, and it wins every disagreement.
|
|
229
|
+
- **Fallback 1 — DOM panel**: a debounced (200 ms) `MutationObserver` watches `[data-testid="todo-panel"]`, reads `li[data-status]` items when the strip is expanded, and parses the localized count label (e.g. "1 完成 · 2 进行中") when it is collapsed. It returns immediately whenever `hasPrimaryData()` says the service has already spoken for that session — otherwise the two channels would alternate on every observer tick and the ball would flicker.
|
|
230
|
+
- **Fallback 2 — transport tap**: a one-time, defensive wrapper around `window.fetch` (cloning responses, text/json only) and `WebSocket.prototype.onmessage` (text frames) feeds every payload through a strict extractor that only reacts to objects shaped like projection frames, `todo/write` events, or `{todos:[...]}` snapshots. Malformed payloads are ignored; nothing is ever written back.
|
|
226
231
|
|
|
227
|
-
All channels funnel into one normalizer: items are filtered to the three known statuses, blank contents are dropped, and unchanged lists are no-ops (cheap signature comparison).
|
|
232
|
+
All channels funnel into one normalizer: items are filtered to the three known statuses, blank contents are dropped, and unchanged lists are no-ops (cheap signature comparison). The **snapshot boundary** is taken from the authoritative frame length — `todo_write` replaces the whole list, so that frame *is* the live plan and everything merged in behind it is archive. That single rule is what keeps `done/total` matching the official panel; the pre-0.14.6 code used a monotonic high-water mark that could never shrink and drifted further off with every round.
|
|
228
233
|
|
|
229
234
|
## FAQ
|
|
230
235
|
|
|
@@ -238,7 +243,7 @@ Yes — drag it anywhere. The position persists per browser/renderer profile. If
|
|
|
238
243
|
Yes. That is exactly why channel B exists: the official strip renders only a counts label when collapsed, while projection frames always carry the full list.
|
|
239
244
|
|
|
240
245
|
**Does it slow the UI down?**
|
|
241
|
-
No. The observer is debounced (200 ms), the transport tap only string-scans for `"todos"` before parsing, and the
|
|
246
|
+
No. The observer is debounced (200 ms), the transport tap only string-scans for `"todos"` before parsing, and the ball-respawn watchdog gives up after 300 × 2 s = 10 minutes (the visibility/sync poll is deliberately kept alive, because it is also how a skin switched from a sibling plugin reaches this ball).
|
|
242
247
|
|
|
243
248
|
## Compatibility
|
|
244
249
|
|
package/README.zh.md
CHANGED
|
@@ -33,10 +33,10 @@ DSH 里让 AI 干活时,它会用内置的 `todo_write` 记一份任务清单
|
|
|
33
33
|
|
|
34
34
|
- **专治"长任务失联"** —— DSH 的 AI 会自动续跑很多轮,你可能十几分钟不看屏幕。球上的橙灯和 `3/8` 让你一眼就知道**还在跑、跑到哪了**。
|
|
35
35
|
- **多会话并行不再瞎猜** —— 固定标签把两栏进度并排摆在同一个面板里,不用左点右点来回切。
|
|
36
|
-
- **三球视觉统一** —— 与姊妹插件 `dsh-skill-browser`、`dsh-font-enhancer` 共用同一套 **
|
|
36
|
+
- **三球视觉统一** —— 与姊妹插件 `dsh-skill-browser`、`dsh-font-enhancer` 共用同一套 **128 款皮肤**目录(另有「经典(旧版)」分组保留最初 6 款),三个球一起换肤、风格一致。
|
|
37
37
|
- **双端同一份代码** —— 桌面端(Electron)和网页端行为一致。
|
|
38
38
|
- **零侵入零配置** —— 装上即用,不写配置文件也不改官方 UI;`Shadow DOM + all:initial` 做样式隔离,与你其他主题/皮肤插件互不干扰。
|
|
39
|
-
- **数据来源可靠** ——
|
|
39
|
+
- **数据来源可靠** —— 三路同步:**主** = 运行时 `sessions` 服务的权威投影帧;**兜底 1** = 官方 todo 面板的 DOM 观察;**兜底 2** = 传输帧被动拦截。兜底只在权威通道对该会话尚无数据时才发言。**官方那一条折叠了、甚至没渲染,球上依然是完整清单**。
|
|
40
40
|
|
|
41
41
|
## 效果展示
|
|
42
42
|
|
|
@@ -56,7 +56,7 @@ DSH 里让 AI 干活时,它会用内置的 `todo_write` 记一份任务清单
|
|
|
56
56
|
|
|
57
57
|
### 皮肤
|
|
58
58
|
|
|
59
|
-
内置
|
|
59
|
+
内置 128 款皮肤(另有「经典(旧版)」分组保留最初 6 款:🌌 星云·流光 / 🌟 星云·宝石 / 🌙 星云·顶弧 / 💎 石墨版 / 🔵 蓝宝石版 / 🧊 玻璃版),与姊妹插件 skill-browser / font-enhancer 的球共用同一套皮肤目录,三球外观保持统一。分组:招牌特效 28 / 浓郁深底 38 / 尘埃灰调 20 / 柔光深底 15 / 中性点缀 10 / 浅色纸面 17。
|
|
60
60
|
|
|
61
61
|

|
|
62
62
|
|
|
@@ -87,7 +87,7 @@ DSH 里让 AI 干活时,它会用内置的 `todo_write` 记一份任务清单
|
|
|
87
87
|
| 中文 | English |
|
|
88
88
|
|---|---|
|
|
89
89
|
| 点球折叠/展开,靠屏幕边缘自动翻侧 | Click to fold/expand; flips sides near the edge |
|
|
90
|
-
|
|
|
90
|
+
| 三路数据同步:**主** = `sessions` 服务权威投影帧;**兜底** = DOM 观察 + 传输帧拦截(权威通道有数据时兜底自动静默)——官方面板折叠时也有完整清单 | Three-tier sync: primary = `sessions` service projection; fallbacks = DOM observer + transport tap (gated by `hasPrimaryData()`) — full list even when collapsed |
|
|
91
91
|
| Shadow DOM + `all:initial` 样式隔离 | Shadow DOM with `all:initial` isolation |
|
|
92
92
|
| 桌面端 + 网页端双端可用 | Works on Desktop and web |
|
|
93
93
|
|
|
@@ -123,11 +123,11 @@ DSH 里让 AI 干活时,它会用内置的 `todo_write` 记一份任务清单
|
|
|
123
123
|
| 实时进度 | 球面显示 `完成数/总数` + 当前第一个进行中任务的内容(超长截断),随 `todo_write` 实时刷新 |
|
|
124
124
|
| 折叠/展开 | 点球切换任务面板;面板在球旁边弹出,靠边时自动翻到另一侧 |
|
|
125
125
|
| 状态颜色 | 每项带状态图标与配色:✓ 已完成(绿色+删除线)、▶ 进行中(橙色)、○ 待办(灰色虚线圈);球本身:橙色脉动/绿/蓝/灰 |
|
|
126
|
-
|
|
|
126
|
+
| 数据三路同步 | **主路**:`ctx.sessions.list.subscribe` 订阅运行时权威投影帧(另有 2 秒轮询兜底,防 shell 重建后回调失联);**兜底一**:`MutationObserver` 监听官方 todo 面板 DOM;**兜底二**:包装 `fetch` 与 `WebSocket.onmessage`,被动捕获会话投影帧 `{type:"projection", key:"todos", ...}`。兜底由 `hasPrimaryData()` 把关,权威通道有数据即静默——**官方面板折叠时也能拿到完整清单** |
|
|
127
127
|
| Shadow DOM 样式隔离 | 全部 UI 在 open Shadow DOM 内并加 `all:initial`——样式不进不出,主题/皮肤插件互不干扰 |
|
|
128
128
|
| 双端可用 | DSH Desktop 桌面端(Electron 窗口)与网页端(浏览器)同一份代码通用;UI 挂载在 `<html>` 根节点,规避 `transform` 导致的 `position:fixed` 失效 |
|
|
129
129
|
| 隐私友好 | 零遥测、零数据上传。宿主端只注册一个仅限本机回环访问的健康检查路由(`/dsh-todo-float-ball/health`) |
|
|
130
|
-
| **纪律注入(v0.9.0)** | 宿主端向**每次会话的系统提示**注入
|
|
130
|
+
| **纪律注入(v0.9.0)** | 宿主端向**每次会话的系统提示**注入 6 条 todo 纪律(实测 498 字符,`order=190`)——**装上插件即生效,无需加载任何技能**;可用 `injectDiscipline: false` 关闭 |
|
|
131
131
|
| **历史归档与面板管理(v0.10.0)** | 快照合并不再冲掉旧任务——旧任务进入可折叠的历史归档;行级 ✕ 隐藏、两个独立折叠行、🧹 批量清理、♻️ 一键恢复、📋 整行复制;球面计数只反映最新快照 |
|
|
132
132
|
| **固定会话同款体验 + 面板布局切换(v0.11.0)** | 📌 固定会话与当前对话走**同一个历史渲染器**(两个折叠行、🧹、♻️、按会话独立的开合与操作归属);面板头部新增 ⇄ 按钮,可在【上下堆叠】与【左右并排】之间切换,并带列标题 |
|
|
133
133
|
|
|
@@ -152,6 +152,7 @@ DSH 里让 AI 干活时,它会用内置的 `todo_write` 记一份任务清单
|
|
|
152
152
|
- **统计口径 = 当前计划**——球面 `完成数/总数`、进度环、头部汇总、「还有 N 项未完成」提示全部只统计最新快照(`snapshotList()`);历史是纯档案,不进任何计数。
|
|
153
153
|
- **行级隐藏(✕)**——悬停历史行点 ✕ 即隐藏。隐藏记录按会话存在 `localStorage`(`dsh-todo-float-ball-hidden-v1`),数据层零改动。固定会话(📌)的行独立隐藏——会话 A 的隐藏记录绝不会隐藏会话 B 的行(`data-ownsid` 归属过滤)。
|
|
154
154
|
- **两个折叠行**——`▾ 已完成历史(N 条)` 与 `▸ 被抛弃的历史任务(M 条)` 是独立折叠行(默认收起);最新快照始终完整平铺。
|
|
155
|
+
- **分界线(v0.14.6)**——历史折叠区与当前轮清单之间有一道 `── 当前进度 · 5/10 完成 ──` 分界线:两侧渐隐细线 + 中间圆角胶囊标签,两套皮肤各自配色,`pointer-events:none` 不挡点击。它把「历史贡献」与「官方最新清单」在视觉上一刀切开,避免误把历史当成正在做的事。
|
|
155
156
|
- **批量清理(🧹)**——每个折叠行带 🧹 清本区按钮,另有 `🧹 一键清理全部历史(X 条)` 一行同时清两区。
|
|
156
157
|
- **一键恢复(♻️)**——`♻️ 一键恢复全部隐藏的历史(X 条)` 仅在有隐藏条目时出现,一次恢复本会话全部隐藏行。
|
|
157
158
|
- **整行复制(📋)**——复制**完整**任务文本(非 80 字显示截断),带真实 ✓/⚠ 反馈。
|
|
@@ -184,10 +185,12 @@ npm install dsh-todo-float-ball
|
|
|
184
185
|
重启后右下角应出现悬浮球。可用下面的地址验证宿主端已挂载:
|
|
185
186
|
|
|
186
187
|
```
|
|
187
|
-
http://127.0.0.1
|
|
188
|
+
http://127.0.0.1:<你当前的 DSH 端口>/dsh-todo-float-ball/health
|
|
188
189
|
→ {"ok":true,"plugin":"dsh-todo-float-ball","version":"<已安装 package.json 里的版本号>"}
|
|
189
190
|
```
|
|
190
191
|
|
|
192
|
+
**端口要填你自己的。** DSH 桌面端默认 `port: 0`(每次重启换一个随机端口),没有固定值可抄。可从 DSH 窗口地址栏读取,或在 `%USERPROFILE%\.dsh\desktop-preferences.json` 里把 `port` 固定下来。固定的 `43120` 只有你自己设置过才成立。该路由还只接受本机渲染进程的请求,其他请求一律回 `403 Browser access is disabled`,所以除非你打开 `browserAccess`,`curl` 是拿不到的。
|
|
193
|
+
|
|
191
194
|
## 实现原理
|
|
192
195
|
|
|
193
196
|
官方的 todo 数据是一条**会话投影(session projection)**:
|
package/docs/DATA-CHANNELS.md
CHANGED
|
@@ -12,7 +12,30 @@ so future maintainers can re-validate them against newer DSH versions.
|
|
|
12
12
|
| View | `@deepseek-ai/dsh-client-ui-conversation` | Renders the `todos` projection as the plan strip above the composer (`section[data-testid="todo-panel"]`), collapsible; expanded it renders `ul > li[data-status]` with a content span; collapsed it renders only a localized counts label |
|
|
13
13
|
| Tool row | `@deepseek-ai/dsh-client-ui-tool` | Renders the one-line `todo_write` conversation row (summary derived from call args) |
|
|
14
14
|
|
|
15
|
-
## Channel A —
|
|
15
|
+
## Channel A — `sessions` service (authoritative)
|
|
16
|
+
|
|
17
|
+
The client half declares `inject: ["sessions"]` and subscribes to the runtime's
|
|
18
|
+
global session registry (`ctx.sessions.list.subscribe`, plus a 2 s pull as a
|
|
19
|
+
safety net in case a callback stops firing after a shell rebuild).
|
|
20
|
+
|
|
21
|
+
- This is the **primary** channel and it wins every disagreement.
|
|
22
|
+
- `todo_write` is a **whole-list replacement**, so one frame from this channel is
|
|
23
|
+
the complete live plan. The snapshot boundary (`snapLen`) is therefore taken
|
|
24
|
+
from the frame length itself; everything merged in behind it is history and
|
|
25
|
+
must never be counted as live progress. (v0.14.6 removed the older monotonic
|
|
26
|
+
high-water mark, which never shrank and made the ball report `9/18` while the
|
|
27
|
+
official panel held 6 items.)
|
|
28
|
+
- Frames are normalized (statuses filtered to `pending | in_progress |
|
|
29
|
+
completed`, blank contents dropped) and a signature (`status|content` joined)
|
|
30
|
+
makes identical lists no-ops.
|
|
31
|
+
|
|
32
|
+
## Channel B — DOM panel (fallback only)
|
|
33
|
+
|
|
34
|
+
**Strictly a fallback**: it only feeds the ball while the authoritative channel
|
|
35
|
+
has produced nothing for this session (`hasPrimaryData(sid, rec)` returns early
|
|
36
|
+
otherwise). Without that guard the two channels alternate on every observer tick
|
|
37
|
+
and the ball flickers between the service's full list and whatever React has
|
|
38
|
+
painted mid-render.
|
|
16
39
|
|
|
17
40
|
- Selector: `[data-testid="todo-panel"]`
|
|
18
41
|
- Expanded: `panel.querySelectorAll("ul li[data-status]")` →
|
|
@@ -22,8 +45,10 @@ so future maintainers can re-validate them against newer DSH versions.
|
|
|
22
45
|
segments; both Arabic numerals and simple Chinese numerals (一/两/三…十) are
|
|
23
46
|
supported. Count-only data is used solely as a last resort when no
|
|
24
47
|
projection frame has been seen yet, because it cannot recover item contents.
|
|
48
|
+
- The panel can never raise the snapshot boundary, and never sets one at all
|
|
49
|
+
when the service already gave us one.
|
|
25
50
|
|
|
26
|
-
## Channel
|
|
51
|
+
## Channel C — transport tap (last resort)
|
|
27
52
|
|
|
28
53
|
- `window.fetch` is wrapped once (`window.__dshtfbFetchPatched` guard):
|
|
29
54
|
responses are cloned; binary-ish content types (javascript/font/image) are
|
|
@@ -42,13 +67,16 @@ so future maintainers can re-validate them against newer DSH versions.
|
|
|
42
67
|
|
|
43
68
|
## Normalization
|
|
44
69
|
|
|
45
|
-
|
|
70
|
+
All channels funnel into `setSessionTodos`:
|
|
46
71
|
|
|
47
72
|
- items are filtered to `pending | in_progress | completed`;
|
|
48
73
|
- blank/whitespace contents are dropped;
|
|
49
74
|
- a signature (`status|content` joined) detects no-op updates;
|
|
50
75
|
- rendering is fully re-computed from the normalized list (no incremental DOM
|
|
51
|
-
state)
|
|
76
|
+
state);
|
|
77
|
+
- the snapshot boundary is `norm.length` for authoritative frames only — see
|
|
78
|
+
Channel A. Statistics (`done/total` on the face, the ring, the header summary)
|
|
79
|
+
count only `todos.slice(0, snapLen)`; the rest is archive.
|
|
52
80
|
|
|
53
81
|
## Stability notes
|
|
54
82
|
|
package/lib/client.js
CHANGED
|
@@ -505,7 +505,7 @@ window.__ModuleLoader__.load({
|
|
|
505
505
|
for (var sid in bySession) {
|
|
506
506
|
var b = bySession[sid];
|
|
507
507
|
if (b && b.todos && b.todos.length) {
|
|
508
|
-
out[sid] = { todos: b.todos, sig: b.sig, at: b.at || 0, snapLen: b.snapLen || 0 };
|
|
508
|
+
out[sid] = { todos: b.todos, sig: b.sig, at: b.at || 0, snapLen: b.snapLen || 0, primary: !!b.primary };
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
511
|
localStorage.setItem(PERSIST_KEY, JSON.stringify(out));
|
|
@@ -543,7 +543,7 @@ window.__ModuleLoader__.load({
|
|
|
543
543
|
if (planKey(mem.todos) !== planKey(norm)) continue;
|
|
544
544
|
if (progressScore(norm, rec.at) <= progressScore(mem.todos, mem.at)) continue;
|
|
545
545
|
}
|
|
546
|
-
bySession[sid] = { todos: norm, sig: rec.sig || norm.map(function (t) { return t.status + "|" + t.content; }).join("\n"), stale: false, at: rec.at || 0, snapLen: rec.snapLen || norm.length };
|
|
546
|
+
bySession[sid] = { todos: norm, sig: rec.sig || norm.map(function (t) { return t.status + "|" + t.content; }).join("\n"), stale: false, at: rec.at || 0, snapLen: rec.snapLen || norm.length, primary: !!rec.primary };
|
|
547
547
|
}
|
|
548
548
|
} catch (e) {}
|
|
549
549
|
}
|
|
@@ -583,7 +583,26 @@ window.__ModuleLoader__.load({
|
|
|
583
583
|
// lists a previously hidden item again, that row is live again and
|
|
584
584
|
// un-hides. The ✕ keeps silencing rows that merely sit in the merged
|
|
585
585
|
// history / unchanged snapshot.
|
|
586
|
-
if (b && b.sig === sig) {
|
|
586
|
+
if (b && b.sig === sig) {
|
|
587
|
+
b.stale = false;
|
|
588
|
+
// v0.14.7: an identical snapshot still carries an authoritative
|
|
589
|
+
// verdict about where the live plan ends. Before this, a record whose
|
|
590
|
+
// snapLen had been inflated by an older frame kept the wrong boundary
|
|
591
|
+
// forever — the signature matched, we returned early, and the stale
|
|
592
|
+
// boundary kept counting merged history as live tasks. The signature
|
|
593
|
+
// dedupe exists to save work, NOT to freeze the boundary.
|
|
594
|
+
if (!fromFallback) {
|
|
595
|
+
var fixLen = Math.min(norm.length, (b.todos && b.todos.length) || 0);
|
|
596
|
+
if (b.snapLen !== fixLen || !b.primary) {
|
|
597
|
+
b.snapLen = fixLen;
|
|
598
|
+
b.primary = true;
|
|
599
|
+
b.at = Date.now();
|
|
600
|
+
render();
|
|
601
|
+
persistSoon();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
587
606
|
var hid0 = hiddenFor(sid);
|
|
588
607
|
for (var h0 in hid0) {
|
|
589
608
|
for (var ni0 = 0; ni0 < norm.length; ni0++) {
|
|
@@ -634,23 +653,36 @@ window.__ModuleLoader__.load({
|
|
|
634
653
|
// collapsed (completed-only) by renderList; the snapshot itself stays
|
|
635
654
|
// fully visible.
|
|
636
655
|
//
|
|
637
|
-
//
|
|
638
|
-
//
|
|
639
|
-
//
|
|
640
|
-
//
|
|
641
|
-
//
|
|
642
|
-
//
|
|
643
|
-
//
|
|
644
|
-
//
|
|
645
|
-
//
|
|
656
|
+
// History of this variable, because it has now been changed twice:
|
|
657
|
+
//
|
|
658
|
+
// 2026-09-28 (flicker fix) made it a monotonic high-water mark after the
|
|
659
|
+
// ball was seen flipping 0/1 -> 7/9 -> 0/1. The real cause of that
|
|
660
|
+
// flicker was the DOM panel writing a one-row "plan" in between the
|
|
661
|
+
// service's full snapshots.
|
|
662
|
+
//
|
|
663
|
+
// v0.14.6 (2026-10-19, user bug report) reverses the monotonic part. The
|
|
664
|
+
// mark never shrank, so once one long round had inflated it, every later
|
|
665
|
+
// round kept counting the older rows as live tasks. Measured: the
|
|
666
|
+
// official panel held 6 todos (0 done) while the ball reported 9/18 —
|
|
667
|
+
// done and total both wrong, and no later frame could repair it because
|
|
668
|
+
// the boundary only ever moved up.
|
|
669
|
+
//
|
|
670
|
+
// The flicker is prevented at its actual source now: readOfficialPanel()
|
|
671
|
+
// bails out via hasPrimaryData() whenever the authoritative channel has
|
|
672
|
+
// already spoken for the session, so that one-row frame can no longer
|
|
673
|
+
// reach this function at all.
|
|
674
|
+
//
|
|
675
|
+
// Rule: todo_write is a whole-list replacement, so an authoritative frame
|
|
676
|
+
// IS the live plan and everything merged in behind it is history. The DOM
|
|
677
|
+
// fallback never enlarges the boundary, and defers to an existing mark
|
|
678
|
+
// when the service already gave us one.
|
|
646
679
|
var prevSnap = (b && typeof b.snapLen === "number") ? b.snapLen : 0;
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
: Math.min(Math.max(prevSnap, norm.length), merged.length);
|
|
680
|
+
var snapLen;
|
|
681
|
+
if (fromFallback) {
|
|
682
|
+
snapLen = Math.min(prevSnap > 0 ? prevSnap : norm.length, merged.length);
|
|
683
|
+
} else {
|
|
684
|
+
snapLen = Math.min(norm.length, merged.length);
|
|
685
|
+
}
|
|
654
686
|
// FLICKER FIX: `primary` marks a row written by the AUTHORITATIVE
|
|
655
687
|
// sessions channel. The DOM fallback must neither set it nor clear it
|
|
656
688
|
// (once the service has spoken for this session, it stays authoritative
|
|
@@ -1016,6 +1048,13 @@ window.__ModuleLoader__.load({
|
|
|
1016
1048
|
".tfb-empty{color:var(--itm,#8b93a1);font-size:12px;text-align:center;padding:12px 0}",
|
|
1017
1049
|
".tfb-histoggle{list-style:none;display:flex;align-items:center;justify-content:center;gap:4px;margin:6px 0 2px;padding:5px 4px;border-radius:8px;color:var(--itm,#9aa3b2);font-size:11px;cursor:pointer;background:var(--chipBg,rgba(255,255,255,.03))}",
|
|
1018
1050
|
".tfb-histoggle:hover{color:var(--ptx,#e6e6e6);background:var(--chipBg,rgba(255,255,255,.06))}",
|
|
1051
|
+
// v0.14.7: divider between the archive (above) and the live plan
|
|
1052
|
+
// (below). Two hairlines fade toward the edges via a gradient mask so
|
|
1053
|
+
// it reads as a breath rather than a hard rule; the centred label
|
|
1054
|
+
// restates the ball's own numbers so they cannot be misread.
|
|
1055
|
+
".tfb-divider{list-style:none;display:flex;align-items:center;gap:8px;margin:12px 0 8px;padding:0 2px;pointer-events:none}",
|
|
1056
|
+
".tfb-divider-line{flex:1;height:1px;background:linear-gradient(90deg,transparent 0%,var(--pbd,rgba(255,255,255,.16)) 22%,var(--pbd,rgba(255,255,255,.16)) 78%,transparent 100%)}",
|
|
1057
|
+
".tfb-divider-txt{flex-shrink:0;font-size:10px;font-weight:600;letter-spacing:.02em;color:var(--hintC,#7f8896);white-space:nowrap;padding:1px 7px;border-radius:9px;background:var(--chipBg,rgba(255,255,255,.04))}",
|
|
1019
1058
|
".tfb-sep{margin:10px 0 6px;padding-top:8px;border-top:1px solid var(--pbd,rgba(255,255,255,.07));display:flex;align-items:center;justify-content:space-between}",
|
|
1020
1059
|
".tfb-sep-label{font-size:11px;color:var(--itm,#9aa3b2);font-weight:600}",
|
|
1021
1060
|
".tfb-pinrow{display:flex;align-items:center;gap:6px;padding:6px 4px;border-radius:8px;cursor:pointer}",
|
|
@@ -1216,6 +1255,10 @@ window.__ModuleLoader__.load({
|
|
|
1216
1255
|
// Plan-A3: history fold toggle row
|
|
1217
1256
|
".tfb-histoggle{list-style:none;display:flex;align-items:center;justify-content:center;gap:4px;margin:6px 0 2px;padding:5px 4px;border-radius:8px;color:#9aa3b2;font-size:11px;cursor:pointer;background:rgba(255,255,255,.03)}",
|
|
1218
1257
|
".tfb-histoggle:hover{color:#e6e6e6;background:rgba(255,255,255,.06)}",
|
|
1258
|
+
// v0.14.7: archive / live-plan divider (theme-2 palette, no CSS vars)
|
|
1259
|
+
".tfb-divider{list-style:none;display:flex;align-items:center;gap:8px;margin:12px 0 8px;padding:0 2px;pointer-events:none}",
|
|
1260
|
+
".tfb-divider-line{flex:1;height:1px;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.16) 22%,rgba(255,255,255,.16) 78%,transparent 100%)}",
|
|
1261
|
+
".tfb-divider-txt{flex-shrink:0;font-size:10px;font-weight:600;letter-spacing:.02em;color:#7f8896;white-space:nowrap;padding:1px 7px;border-radius:9px;background:rgba(255,255,255,.04)}",
|
|
1219
1262
|
".tfb-sep{margin:10px 0 6px;padding-top:8px;border-top:1px solid rgba(255,255,255,.07);display:flex;align-items:center;justify-content:space-between}",
|
|
1220
1263
|
".tfb-sep-label{font-size:11px;color:#9aa3b2;font-weight:600}",
|
|
1221
1264
|
".tfb-pinrow{display:flex;align-items:center;gap:6px;padding:6px 4px;border-radius:8px;cursor:pointer}",
|
|
@@ -1291,7 +1334,12 @@ window.__ModuleLoader__.load({
|
|
|
1291
1334
|
// every action row carries data-ownsid so the dispatcher can scope
|
|
1292
1335
|
// toggle/🧹/♻️ to THIS session (continuation of Plan-A2.2)
|
|
1293
1336
|
var ownAttr = ' data-ownsid="' + esc(sid) + '"';
|
|
1294
|
-
|
|
1337
|
+
// v0.14.7 (user requirement, m07623): the expanded panel must show BOTH
|
|
1338
|
+
// the archived completed work AND the live plan, separated by an
|
|
1339
|
+
// explicit, good-looking divider. The ball face keeps reporting the
|
|
1340
|
+
// OFFICIAL numbers only (snapshot slice); the archive lives here, below
|
|
1341
|
+
// the divider, so nothing inflates the counters but nothing is lost.
|
|
1342
|
+
var html = "";
|
|
1295
1343
|
// Plan-A5: batch-clear affordance — one click hides every archive row
|
|
1296
1344
|
// (both folds), same ✕ semantics as single-row hides, snapshot rows
|
|
1297
1345
|
// and data layer untouched.
|
|
@@ -1307,6 +1355,21 @@ window.__ModuleLoader__.load({
|
|
|
1307
1355
|
'<button class="tfb-btn" data-act="clearHistoryOpen"' + ownAttr + ' type="button" title="一键隐藏本区全部条目(✕ 同款,仅显示层)">🧹</button></li>';
|
|
1308
1356
|
if (historyOpenOpen[osid]) html += listHtml(histOpen_);
|
|
1309
1357
|
}
|
|
1358
|
+
// ── divider: archive vs live plan ─────────────────────────────────
|
|
1359
|
+
// Shown only when there IS an archive above, so a first-round list
|
|
1360
|
+
// stays clean. The right-hand count restates what the BALL shows, so
|
|
1361
|
+
// the number cannot be misread as panel-wide.
|
|
1362
|
+
if (snapRows.length || anyHist) {
|
|
1363
|
+
var liveC = countsOf(snapRows);
|
|
1364
|
+
var liveTxt = snapRows.length
|
|
1365
|
+
? (liveC.done + "/" + liveC.total + " 完成")
|
|
1366
|
+
: "无进行中任务";
|
|
1367
|
+
html += '<li class="tfb-divider" data-ownsid="' + esc(sid) + '">' +
|
|
1368
|
+
'<span class="tfb-divider-line"></span>' +
|
|
1369
|
+
'<span class="tfb-divider-txt">当前进度 · ' + liveTxt + '</span>' +
|
|
1370
|
+
'<span class="tfb-divider-line"></span></li>';
|
|
1371
|
+
}
|
|
1372
|
+
html += listHtml(snapRows);
|
|
1310
1373
|
if (anyHist) {
|
|
1311
1374
|
html += '<li class="tfb-histoggle" data-act="clearAll"' + ownAttr + ' title="一键隐藏两个历史区全部条目">🧹 一键清理全部历史(' + anyHist + ' 条)</li>';
|
|
1312
1375
|
}
|
|
@@ -1667,7 +1730,28 @@ window.__ModuleLoader__.load({
|
|
|
1667
1730
|
}
|
|
1668
1731
|
|
|
1669
1732
|
function buildUI() {
|
|
1670
|
-
|
|
1733
|
+
// HOT-RELOAD FIX (v0.14.6) — a host left behind by a PREVIOUS instance
|
|
1734
|
+
// must never block this one.
|
|
1735
|
+
//
|
|
1736
|
+
// Symptom this repairs: after a client hot reload (Ctrl+Shift+R) the old
|
|
1737
|
+
// `#dsh-tfb-root` shadow host is still in the DOM, so the old guard
|
|
1738
|
+
// `if (getElementById(BALL_ID)) return;` made this instance bail out
|
|
1739
|
+
// before it ever built its own UI. `ui.ball` stayed null, so every
|
|
1740
|
+
// `renderBall()` was a no-op (`if (!ui.ball) return;`) and the ball on
|
|
1741
|
+
// screen kept showing the numbers the DEAD instance computed. Measured
|
|
1742
|
+
// on 2026-10-19: authoritative data was 7/12 while the visible capsule
|
|
1743
|
+
// still read 11/18, and `renderCalls=0` on the new instance.
|
|
1744
|
+
//
|
|
1745
|
+
// Ownership test: only OUR OWN host may short-circuit. A host whose
|
|
1746
|
+
// shadow root is not `ui.shadow` belongs to somebody else (or to a
|
|
1747
|
+
// previous incarnation) and gets removed so we can build cleanly.
|
|
1748
|
+
var existing = document.getElementById(BALL_ID);
|
|
1749
|
+
if (existing) {
|
|
1750
|
+
if (ui.shadow && ui.shadow.host === existing) return;
|
|
1751
|
+
try { existing.remove(); } catch (eRm) {}
|
|
1752
|
+
ui = { root: null, styleEl: null, shadow: null, ball: null, panel: null, list: null, summary: null, ctitle: null, pinBtn: null, pinSec: null, themeMenu: null };
|
|
1753
|
+
lastBallSig = null;
|
|
1754
|
+
}
|
|
1671
1755
|
if (!document.body) return;
|
|
1672
1756
|
try { fetch("/dsh-todo-float-ball/client-alive").catch(function () {}); } catch (e) {}
|
|
1673
1757
|
|
package/lib/index.js
CHANGED
|
@@ -129,14 +129,37 @@ export function apply(ctx, config) {
|
|
|
129
129
|
if (!session || typeof session.snapshotEvents !== "function") return next();
|
|
130
130
|
var events = session.snapshotEvents();
|
|
131
131
|
if (!events || typeof events[Symbol.iterator] !== "function") return next();
|
|
132
|
-
|
|
132
|
+
// v0.13.2 修复(2026-10-10):并行竞态 + run_code 包装 + 计数卡死。
|
|
133
|
+
// 原判定 toolCallsThisTurn === 1 有三个致命问题:
|
|
134
|
+
// 1) append 时序假设相反:第一个调用到达 gate 时计数为 0(放行),放行后计数变 1,
|
|
135
|
+
// 而被拒的调用不 append——计数永久卡在 1,此后每个调用都命中 "=== 1" 被拒 → 死循环锁死;
|
|
136
|
+
// 2) AI 常用 run_code 包装调用(await tools.todo_write(...)),exec.name 是 run_code,
|
|
137
|
+
// 原 name 检查认不出,包装的 todo_write 永远触发不了放行分支;
|
|
138
|
+
// 3) 并行批次 append/dispatch 顺序不保证。
|
|
139
|
+
// 新判定:本 turn 第一个调用一律放行(给 todo_write 执行机会);从第二个起,
|
|
140
|
+
// 用「本 turn 是否已有 todo/write 会话事件」判断(无论直接调用还是 run_code 包装,
|
|
141
|
+
// todo_write 真正执行过必有该事件,比检查调用名可靠),辅以调用名/参数兜底识别。
|
|
142
|
+
var dispatchedThisTurn = 0;
|
|
143
|
+
var hasTodoWriteThisTurn = false;
|
|
144
|
+
var sawToolName = false;
|
|
133
145
|
for (var ev of events) {
|
|
134
146
|
var type = ev && ev.type;
|
|
135
|
-
if (type === "turn/start")
|
|
136
|
-
else if (type === "
|
|
147
|
+
if (type === "turn/start") { dispatchedThisTurn = 0; hasTodoWriteThisTurn = false; sawToolName = false; }
|
|
148
|
+
else if (type === "todo/write") { hasTodoWriteThisTurn = true; }
|
|
149
|
+
else if (type === "tool/call") {
|
|
150
|
+
dispatchedThisTurn++;
|
|
151
|
+
var callName = (ev.data && ev.data.name) || ev.name;
|
|
152
|
+
if (typeof callName === "string" && callName) {
|
|
153
|
+
sawToolName = true;
|
|
154
|
+
if (callName === "todo_write") hasTodoWriteThisTurn = true;
|
|
155
|
+
var callArgs = (ev.data && ev.data.arguments) || ev.arguments;
|
|
156
|
+
if (typeof callArgs === "string" && callArgs.indexOf("todo_write") !== -1) hasTodoWriteThisTurn = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
137
159
|
}
|
|
138
|
-
|
|
139
|
-
|
|
160
|
+
// fail-open:本 turn 有调用但一个 name 都读不到(事件结构不符)→ 放行,绝不阻塞
|
|
161
|
+
if (dispatchedThisTurn > 1 && sawToolName && !hasTodoWriteThisTurn) {
|
|
162
|
+
ctx.logger.info("dsh-todo-float-ball: GATE denied \"" + String(exec.name) + "\" (no todo_write in this turn yet)");
|
|
140
163
|
return {
|
|
141
164
|
kind: "deny",
|
|
142
165
|
reason: "【todo 进度表纪律·硬约束】每个回复 turn 的第一个工具调用必须是 todo_write(覆盖式写回完整清单:已完成的保留并标 completed、只增不减、进行中项带进度数字)。本轮你还没有写 todo 清单。请先用 todo_write 写回完整清单,再执行其它工具调用。"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-todo-float-ball",
|
|
3
|
-
"version": "0.14.
|
|
4
|
-
"description": "DSH todo 悬浮球:常驻可拖动悬浮球实时显示当前会话 todo_write
|
|
3
|
+
"version": "0.14.6",
|
|
4
|
+
"description": "DSH todo 悬浮球:常驻可拖动悬浮球实时显示当前会话 todo_write 任务清单进度(完成数/总数/进行中任务名),带百分比进度环;Shadow DOM 样式隔离,点击折叠/展开完整清单,右键胶囊模式;状态颜色(待办蓝/进行中橙脉动/完成绿)。数据双路同步:权威会话投影帧为主 + MutationObserver 抓官方 todo 面板为辅,旧计划自动归档为历史不会被误算进进度。可固定多会话并排查看,128 款共享皮肤+6 款经典皮肤。宿主端每轮注入 todo 纪律并硬性要求首个工具调用为 todo_write。双端可用(Desktop 桌面端 + Web 网页端)。零遥测,仅一条本机回环健康路由。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"sideEffects": false,
|