dsh-todo-float-ball 0.12.3 → 0.14.0
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 +276 -7
- package/README.md +62 -10
- package/README.zh.md +61 -6
- package/docs/images/preview-capsule.jpg +0 -0
- package/docs/images/preview-pinned-sessions-2.jpg +0 -0
- package/docs/images/preview-pinned-sessions.jpg +0 -0
- package/docs/images/preview-skins.png +0 -0
- package/lib/client.js +313 -29
- package/lib/index.js +56 -2
- package/package.json +4 -4
- package/docs/images/todo-float-ball-collapsed.png +0 -0
- package/docs/images/todo-float-ball-expanded.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,284 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
## v0.12.2(2026-09-17)— 文档与描述双语化
|
|
5
|
-
|
|
6
|
-
- **package.json description 改为中英双语卖点式**:先说价值(让 AI 的任务清单常驻在你眼前),再列能力(实时进度环 / 完整清单三态 / 多会话固定 / 行内重命名 / 胶囊模式 / 六款皮肤 / Shadow DOM 隔离 / 双端可用)。
|
|
7
|
-
- **README 顶部新增宣传区**:中英双钩子 + 悬浮球展开态与收起态两张截图 + 图注;`README.md`(英)与 `README.zh.md`(中)同步更新。原有功能清单表格与全部技术文档原样保留。
|
|
8
3
|
All notable changes to this project are documented in this file.
|
|
9
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
10
5
|
|
|
11
|
-
## v0.
|
|
12
|
-
|
|
6
|
+
## v0.14.0(2026-09-29)— 效果宣传图 + README 展示 + npm 包纳入图片
|
|
7
|
+
|
|
8
|
+
- ✨ **新增 4 张效果宣传图**(`docs/images/`),并在中英双语 README 顶部
|
|
9
|
+
新增「效果展示 / Screenshots」章节逐一说明:
|
|
10
|
+
- `preview-pinned-sessions.jpg` / `preview-pinned-sessions-2.jpg`
|
|
11
|
+
—— **固定标签 · 双对话任务进度**:固定两个会话后,面板并排显示两栏
|
|
12
|
+
任务进度,并行任务无需切换会话即可同时盯住。
|
|
13
|
+
- `preview-capsule.jpg` —— **胶囊模式**:右键收起为细长胶囊,只显示当前
|
|
14
|
+
进行中任务与 `已完成/总数`。
|
|
15
|
+
- `preview-skins.png` —— **皮肤清单(120 种)**:与姊妹插件
|
|
16
|
+
skill-browser / font-enhancer 共用同一套皮肤目录,三球外观统一。
|
|
17
|
+
- 🔧 **修正 `package.json` 的 `files` 白名单**:原先只声明 `docs/*.md`,
|
|
18
|
+
**不含 `docs/images/*`**,导致 npm 包里不会带上任何截图(GitHub 能看到、
|
|
19
|
+
npm 用户看不到)。现已加入 `docs/images/*`,确保两个渠道内容一致。
|
|
20
|
+
- 🧹 **清理 2 个从未被引用的孤儿截图**(`todo-float-ball-collapsed.png`、
|
|
21
|
+
`todo-float-ball-expanded.png`,合计约 308 KB)—— 它们既未被任何 README
|
|
22
|
+
引用,也不在白名单内,属于仓库冗余。
|
|
23
|
+
- 🖼 **图片体积优化**:原图合计 498.6 KB → **287.6 KB(降 42%)**。
|
|
24
|
+
思路是按内容选格式:照片型截图用高质量 JPEG(`-q:v 3`,实测平均每通道
|
|
25
|
+
偏差 1.4~2.0/255,视觉无损);皮肤清单因是大量小色块罗列(JPEG 最不擅长
|
|
26
|
+
的场景,偏差达 2.98/255),**保留为无损 PNG**。
|
|
27
|
+
## v0.13.7(2026-09-28)— 统一皮肤补上「呼吸」动效(此前只有经典皮肤有)
|
|
28
|
+
|
|
29
|
+
- 🔴 **现象**:换成 128 套统一皮肤后,球体不再有呼吸感,看起来是静止的。
|
|
30
|
+
- 🔴 **根因(一直如此,非回归)**:呼吸动效 `tfbBreathe` 只写在
|
|
31
|
+
`legacyCssText()` 里 —— 也就是**只服务于 3 套经典皮肤**
|
|
32
|
+
(nebula / nebB / nebC)。而统一皮肤走 `skinCssText()`,那条路径**从未
|
|
33
|
+
输出过** `tfbBreathe`,它只继承各皮肤 `rim` / `band` / `extra` 字段声明的
|
|
34
|
+
动效(实测主要是边框的 `dshSkinSpin` 旋转)。
|
|
35
|
+
实测确认:`animation:tfbBreathe` 全文 3 次出现,**全部位于
|
|
36
|
+
`legacyCssText` 内**;`SK.fx()` 也只为拼接 `rim`/`band`/`extra` 而存在,
|
|
37
|
+
自身不产生任何动画。因此从经典皮肤切到任意统一皮肤 = 呼吸动效消失。
|
|
38
|
+
- ✅ **修复|为统一皮肤注入呼吸动效**:在 `skinCssText()` 中补齐
|
|
39
|
+
`@keyframes tfbBreathe`(3.2s,与经典皮肤同节奏)与
|
|
40
|
+
`@keyframes tfbBreatheSoft`(4.2s,idle 态更柔和),由各皮肤既有的
|
|
41
|
+
CSS 变量驱动配色。同时保证:
|
|
42
|
+
- **完成态(tfb-done)关闭动画** —— 任务全部完成时不该继续"呼吸"。
|
|
43
|
+
- **尊重 `prefers-reduced-motion`** —— 系统要求减弱动效时自动关闭。
|
|
44
|
+
- **皮肤的个性化动效仍优先**:`s.extra` / `s.rim` 在呼吸规则之后注入,
|
|
45
|
+
按源码顺序覆盖。
|
|
46
|
+
- ⚠️ **过程中发现并规避的一个真实冲突(重要)**:最初实现让呼吸动画驱动
|
|
47
|
+
`transform`,而球体的悬停/按下反馈正是
|
|
48
|
+
`.tfb-ball:hover{transform:scale(1.08)}` 与 `:active{transform:scale(.95)}`。
|
|
49
|
+
运行中的动画对**同属性**的优先级高于非 `!important` 声明,因此那版实现会
|
|
50
|
+
**静默吃掉鼠标悬停与按下的缩放反馈**。已改为呼吸只动
|
|
51
|
+
`filter`(brightness/saturate),**完全不碰 transform**,悬停/按下反馈
|
|
52
|
+
完整保留。(经典皮肤当年同样存在这个隐患,本版一并规避。)
|
|
53
|
+
- 🧪 **验证(真行为测试)**:12/12 通过 —— **真实执行 `skinCssText()` 并检查
|
|
54
|
+
其产出的 CSS**(非字符串比对):呼吸关键帧存在、球体正确引用、idle 态柔和版
|
|
55
|
+
存在、**呼吸不使用 transform**(逐帧确认只含 filter)、完成态关闭、
|
|
56
|
+
reduced-motion 生效、既有的 `dshSkinSpin` / `tfb-pulse` 未被破坏、
|
|
57
|
+
经典皮肤定义未受影响。
|
|
58
|
+
其余五轮 55 项继续全绿 —— **累计 67/67**。
|
|
59
|
+
`node --check` 通过;三处副本 SHA256 一致。
|
|
60
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-breathe-*`
|
|
61
|
+
## v0.13.6(2026-09-28)— 皮肤切换真正修好:改用直存引用,不再靠 DOM 遍历
|
|
62
|
+
|
|
63
|
+
- 🔴 **背景**:v0.13.5 尝试用 `ui.root.getRootNode()` 定位样式表。方向对,但仍
|
|
64
|
+
**依赖 DOM 遍历语义**(getRootNode 的返回值随层级/挂载方式而变),不是可靠
|
|
65
|
+
保证。用户实测反馈:"三球皮肤不统一,别的插件都变,只有 todo 不变。"
|
|
66
|
+
- 🔴 **为什么偏偏 todo 不变(架构差异,实测确认)**:
|
|
67
|
+
- `dsh-skill-browser` / `dsh-font-enhancer`:样式表放在 **`document.head`**,
|
|
68
|
+
用 `getElementById(SKIN_STYLE_ID)` **精确取回** —— 从不遍历查找,所以一直正常。
|
|
69
|
+
- `dsh-todo-float-ball`:使用 **Shadow DOM**(`host.attachShadow`),样式表挂在
|
|
70
|
+
**shadowRoot 直属**,与 `ui.root`(`.tfb-root`)是**兄弟节点**。
|
|
71
|
+
而更新皮肤的代码是 `ui.root.querySelector("style")` —— `querySelector`
|
|
72
|
+
**只搜子树**,因此**永远返回 null**,赋值分支从未执行。
|
|
73
|
+
- 结论:三球共用同一套皮肤目录、同一套 `dsh-ball-skin-change` 事件,但只有
|
|
74
|
+
todo 走了一条失效的定位路径,所以表现为"别的球变、todo 不变"。
|
|
75
|
+
- ✅ **修复|保存直接引用,彻底取消查找**:`buildUI()` 在创建样式表时就把它和
|
|
76
|
+
shadow root 存进 `ui`:
|
|
77
|
+
```js
|
|
78
|
+
ui.styleEl = style; // 样式表本体
|
|
79
|
+
ui.shadow = shadow; // 其所属 shadow root
|
|
80
|
+
```
|
|
81
|
+
`refreshStyleSheet()` 按可靠性依次取用:
|
|
82
|
+
1. `ui.styleEl`(直存,零遍历 —— 主路径)
|
|
83
|
+
2. `ui.shadow.querySelector("style")`
|
|
84
|
+
3. `ui.root.getRootNode().querySelector("style")`
|
|
85
|
+
4. `ui.root.querySelector("style")`(旧写法,仅兜底)
|
|
86
|
+
同时把 `ui` 的两处重置点(初始声明 + `refreshPlugin()`)都补上 `styleEl`/
|
|
87
|
+
`shadow`,避免重建后引用丢失。
|
|
88
|
+
- 🧪 **验证(真行为测试,执行真实代码而非比对字符串)**:8/8 通过 ——
|
|
89
|
+
标准 shadow 结构切皮肤生效、连续切换生效、`styleEl` 缺失时 `getRootNode`
|
|
90
|
+
回退可用、`ui` 为空不抛异常、样式表若在 root 内部时子树兜底仍可用;
|
|
91
|
+
并含**对照组**:在同样的 shadow 结构上,旧写法 `root.querySelector("style")`
|
|
92
|
+
返回 `null` 且样式未被改动,直接证明根因。
|
|
93
|
+
其余四轮 47 项(动效 force 10 + 闪烁 15 + 布局 15 + rc.2 主会话 7)继续全绿,
|
|
94
|
+
**累计 55/55**。`node --check` 通过;三处副本 SHA256 一致。
|
|
95
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-skin2-*`
|
|
96
|
+
## v0.13.5(2026-09-28)— 修复「更换皮肤不生效」(潜伏已久的选择器错误)
|
|
97
|
+
|
|
98
|
+
- 🔴 **症状**:在设置里点皮肤不换样子;展开/收起面板后也不刷新皮肤。
|
|
99
|
+
- 🔴 **真根因(自 v0.9 起潜伏,与内核升级无关)**:`buildUI()` 构建 shadow
|
|
100
|
+
树时,样式表是挂在 **shadowRoot 直属**的:
|
|
101
|
+
```
|
|
102
|
+
shadow.appendChild(style); // <style> 在这里
|
|
103
|
+
shadow.appendChild(root); // root === ui.root (".tfb-root")
|
|
104
|
+
```
|
|
105
|
+
即 `<style>` 是 `ui.root` 的**兄弟节点**。而更新皮肤的代码写的是
|
|
106
|
+
```js
|
|
107
|
+
var st = ui.root.querySelector("style");
|
|
108
|
+
if (st) st.textContent = cssText();
|
|
109
|
+
```
|
|
110
|
+
`querySelector` **只在子树内查找**(不含自身与兄弟),因此这里**每次都
|
|
111
|
+
返回 null**,赋值分支从未执行过。
|
|
112
|
+
- 🔴 **为什么以前"看起来能用"**:`hide()` 收起面板时会
|
|
113
|
+
`setTimeout(refreshPlugin, 120)`,而 `refreshPlugin()` 会
|
|
114
|
+
**拆掉并重建整个 DOM**,新建的 `<style>` 在创建时就带上了当前的
|
|
115
|
+
`cssText()`。于是换皮肤真正生效的路径一直是**"收起面板->重建"**,
|
|
116
|
+
而不是那个失效的赋值 —— 一个潜伏的 no-op 被 DOM 重建掩盖了。
|
|
117
|
+
- 🔴 **为什么现在暴露**:v0.13.3 为修「两侧布局在折叠后丢失」,
|
|
118
|
+
移除了 `hide()` 里的无条件 `refreshPlugin()`(否则重建的面板会丢掉
|
|
119
|
+
`tfb-hz`)。掩体一撤,失效的赋值就露出来了 —— 换皮肤随之彻底不工作。
|
|
120
|
+
- ✅ **修复|新增 `refreshStyleSheet()` 作为样式表唯一写入点**:
|
|
121
|
+
用 `ui.root.getRootNode()` 上升到所属 shadowRoot 再找 `<style>`,
|
|
122
|
+
对任意层级都成立;子树内查找保留为兜底。`applyThemeNow()` 与
|
|
123
|
+
面板内主题菜单(原先各自内联同一段错误代码)**统一改为调用它**。
|
|
124
|
+
- 🧪 **验证**:新增 6 项行为回归 —— 其中**对照组直接证明根因**:
|
|
125
|
+
在同样的 shadow 结构上,旧写法 `root.querySelector("style")` 返回
|
|
126
|
+
`null` 且样式未被更新;新写法成功更新且连续切换均生效。
|
|
127
|
+
前四轮 47 项(rc.2 主会话 7 + 闪烁 15 + 布局 15 + 动效 force 10)
|
|
128
|
+
**继续全绿**,五个修复同时成立 —— 累计 **53/53**。
|
|
129
|
+
`node --check` 通过;无 BOM;括号配平;三处副本 SHA256 一致。
|
|
130
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-skinfix-*`
|
|
131
|
+
## v0.13.4(2026-09-28)— 修复「动画特效停止、切换皮肤失效」(v0.13.2 守卫拦得过宽)
|
|
132
|
+
|
|
133
|
+
- 🔴 **症状**:悬浮球的呼吸/旋转/发光等动效不再动了;在设置里切换皮肤也
|
|
134
|
+
像是没生效(球不换样子、动画不重启)。
|
|
135
|
+
- 🔴 **根因(由 v0.13.2 的防闪守卫引入)**:v0.13.2 为消除闪烁,在
|
|
136
|
+
`renderBall()` 开头加了「签名未变则直接 return」的守卫。但
|
|
137
|
+
`renderBall()` 里的
|
|
138
|
+
`ui.ball.className = "tfb-ball " + st.cls + ...`
|
|
139
|
+
**不只是写文本**:重写 `className` 会让引擎重新计算该元素的样式,
|
|
140
|
+
从而**重新武装 CSS 动画**,也是状态类(`tfb-active` / `tfb-done` /
|
|
141
|
+
`tfb-pending`)唯一的落点 —— 而所有动效(`tfbBreathe` 呼吸、
|
|
142
|
+
`tfbRimSpin` 边框旋转、`tfbGlow` 文字辉光、`tfb-pulse`、
|
|
143
|
+
`dshSkinSpin` 等 27 条 `animation:` 规则)全都挂在由它驱动的
|
|
144
|
+
`.tfb-ball` / `.tfb-orb-rim` / `.tfb-label` 上。
|
|
145
|
+
皮肤切换走 `applyThemeNow()`:替换 `<style>` 后调 `render()` —— 此时
|
|
146
|
+
可见数字往往没变,守卫直接 return,**新皮肤 CSS 注入成功但球从未被重新
|
|
147
|
+
装饰**,于是动画停在半途、换皮肤看起来毫无反应。
|
|
148
|
+
- ✅ **修复|给守卫加 `force` 旁路**:`renderBall(force)` / `render(force)`
|
|
149
|
+
在 `force` 为真时**跳过签名比对**,强制重写 `className` 与文本。
|
|
150
|
+
- **强制(re-decoration,必须写 DOM)**:`applyThemeNow()`(皮肤/主题
|
|
151
|
+
应用 → `render(true)`)、`buildUI()` 末尾的首次渲染(元素全新,
|
|
152
|
+
绝不能因上一个 DOM 的缓存签名而跳过)。
|
|
153
|
+
- **保持去抖(数据驱动,防闪)**:`syncFromSessions()` 的
|
|
154
|
+
`if (changed) render()`、2s 看门狗轮询 —— 都走普通 `render()`,
|
|
155
|
+
v0.13.2 的闪烁修复**完全保留**。
|
|
156
|
+
- 🧪 **验证**:本轮新增 10 项回归(结构 6 项 + 行为 4 项:状态未变不重写 /
|
|
157
|
+
皮肤切换强制生效 / DOM 重建后首次必然装饰 / 状态变化正常更新)全绿。
|
|
158
|
+
前三轮 37 项(rc.2 主会话 7 项 + 闪烁 15 项 + 布局 15 项)**继续全绿**,
|
|
159
|
+
四个修复同时成立 —— 累计 **47/47**。
|
|
160
|
+
另做**逐项功能核对**(对原始 v0.13.0):15 个功能面 / 68 个标记
|
|
161
|
+
(动画关键帧与挂载点、皮肤系统与切换通道、胶囊跑马灯、进度环、
|
|
162
|
+
面板折叠、固定会话、隐藏条目、持久化、数据双通道、内联重命名、拖动、
|
|
163
|
+
健康路由、布局切换)**丢失项 0**。
|
|
164
|
+
`node --check` 通过;无 BOM;括号配平;三处副本 SHA256 一致。
|
|
165
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-animfix-*`
|
|
166
|
+
## v0.13.3(2026-09-28)— 修复「两侧显示」布局在折叠/展开后丢失
|
|
167
|
+
|
|
168
|
+
- 🔴 **症状**:在设置里开启「两侧显示」(左右分栏)后,**收起面板再展开,
|
|
169
|
+
分栏就没了**,退回上下堆叠;必须重新点一次按钮才能恢复。而设置里明明
|
|
170
|
+
还显示是开启状态 —— 显示与设置不一致。
|
|
171
|
+
- 🔴 **根因**:布局类 `tfb-hz` 只在**一个地方**被应用过 —— `apply()` 引导期
|
|
172
|
+
(`if (ui.panel && layoutHz) ...`)。但收起面板时 `hide()` 会在 120ms 后
|
|
173
|
+
调 `refreshPlugin()`,它把整个 UI 拆掉并 `buildUI()` **重建面板 DOM**;
|
|
174
|
+
新元素自然没有 `tfb-hz`,而没有任何代码把它加回来。于是
|
|
175
|
+
`localStorage` 仍是 `1`(设置没丢)、面板却已无该 class(显示丢了)。
|
|
176
|
+
- ✅ **修复 1|面板构建即恢复布局**:`buildUI()` 在取到 `ui.panel` 后立即按
|
|
177
|
+
持久化状态恢复 `tfb-hz` —— 与紧邻下方的**位置恢复(POS_KEY)**
|
|
178
|
+
同一范式。这样**任何**面板实例(折叠重建、皮肤重载、异常重建)都会
|
|
179
|
+
自动带上正确布局,持久化值成为唯一权威。
|
|
180
|
+
- ✅ **修复 2|收起不再无谓重建 DOM**:`hide()` 原先无条件
|
|
181
|
+
`refreshPlugin()`,既丢布局,也顺手扔掉了面板的活动状态(展开的折叠区、
|
|
182
|
+
行内重命名编辑器、滚动位置)—— 用户只是收起了个浮层,没有任何结构性变化。
|
|
183
|
+
改为**就地重刷主题**(`applyThemeNow()` 自身会替换 `<style>` 并 `render()`,
|
|
184
|
+
不依赖重建 DOM),另补一次 `tfb-hz` 兜底。`refreshPlugin()` 仍保留给
|
|
185
|
+
真正的结构性重载(设置区的皮肤/结构切换),且因为修复 1,那条路径也安全了。
|
|
186
|
+
- 🧪 **验证**:15 项运行时回归全绿 —— 覆盖折叠后保持、**再展开保持(本次
|
|
187
|
+
目标)**、反复折叠展开、`refreshPlugin` 重建后保持、只有按钮能关闭、
|
|
188
|
+
关闭态不会被自动开启、重载后按已存设置恢复(开/关两种态)。前两轮修复
|
|
189
|
+
的 22 项回归(rc.2 主会话判定 7 项 + 闪烁修复 15 项)**继续全绿,无回归**;
|
|
190
|
+
`node --check` 通过;无 BOM;括号配平;三处副本 SHA256 一致。
|
|
191
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-layoutfix-*`
|
|
192
|
+
## v0.13.2(2026-09-28)— 修复任务执行中进度数字不停闪烁(0/1 ↔ 7/9)
|
|
193
|
+
|
|
194
|
+
- 🔴 **症状**:长任务执行过程中,球面进度在两套数字之间**来回跳**
|
|
195
|
+
(例如 `0/1` ↔ `7/9`),同一批任务总量忽大忽小,看似"任务在重算"。
|
|
196
|
+
- 🔴 **根因一|快照边界跟着本帧条数走**:`todo_write` 是**整表覆盖**,
|
|
197
|
+
但模型有时只重写刚动过的那一条。旧代码把 `snapLen` 赋成
|
|
198
|
+
`norm.length`(**本帧**条数),于是某一个"只写 1 条"的碎帧会把
|
|
199
|
+
"当前快照区"压塌成 1 行 → 球面立刻显示 `0/1`;下一帧模型又给回完整表
|
|
200
|
+
→ 变回 `7/9`。任务从未变化,读数却在跳。
|
|
201
|
+
**修复**:快照边界是**高水位线**而非每帧值 —— `snapLen` 现在**单调不减**
|
|
202
|
+
(`max(上次, 本帧)`,并以合并后总长封顶),碎帧再也无法把实时计划缩回一行。
|
|
203
|
+
- 🔴 **根因二|两个数据通道互相打架**:sessions 服务(权威投影:整表 +
|
|
204
|
+
历史合并 + 粘性边界)与官方 DOM 面板(React 当下画了什么:可能是折叠条、
|
|
205
|
+
渲染中间态、或子代理的行)是**同一份数据的两种视图**。旧代码让面板
|
|
206
|
+
**无条件**写入,于是两者每隔一个观察周期就互相覆盖一次,
|
|
207
|
+
读数在 `7/9`(服务)与 `0/1`(面板)之间翻转。
|
|
208
|
+
**修复**:DOM 面板降级为**纯回退通道** —— 仅当权威通道尚未为该会话
|
|
209
|
+
产出数据时才接管(`hasPrimaryData()` 守卫)。新增 `primary` 标记:
|
|
210
|
+
只有权威通道会置位,面板既不置位也不清除它(服务一旦发过声,
|
|
211
|
+
它对该会话就保持权威)。
|
|
212
|
+
- 🟡 **根因三|球面每轮无条件重绘**:`renderBall()` 在每次 `render()` 与
|
|
213
|
+
每 2s 看门狗里都直接写 `textContent`/`className`/CSS 变量,即使值完全
|
|
214
|
+
相同也会触发合成层重绘,视觉上就是一记闪烁。
|
|
215
|
+
**修复**:记录上次绘制的签名 `lastBallSig`,**内容未变则完全跳过 DOM**。
|
|
216
|
+
`refreshPlugin()`(重建 DOM)会一并清空该缓存,避免"元素已换新却被判为
|
|
217
|
+
无变化"而漏绘。
|
|
218
|
+
- 🧪 **验证**:新增 15 项运行时回归(碎帧不压塌计数 / 碎帧不回退 /
|
|
219
|
+
双通道守卫拦截 / 兜底仍可独立工作 / 兜底不清除 primary /
|
|
220
|
+
兜底不抬升 snapLen / null·空·非法输入·非法状态均不抛)**全绿**;
|
|
221
|
+
上一轮 rc.2 的 7 项回归继续全绿;`node --check` 通过;无 BOM;
|
|
222
|
+
loader id 仍为 `dsh-todo-float-ball`;括号配平;三处副本 SHA256 一致。
|
|
223
|
+
回滚锚点:`~/.dsh/backups/todo-client.js.*.bak-flickerfix-*`
|
|
224
|
+
## v0.13.1(2026-09-28)— 修复 DSH 0.1.7-rc.2 内核升级后悬浮球不显示内容
|
|
225
|
+
|
|
226
|
+
- 🔴 **根因(内核契约变更,非插件自身 bug)**:`0.1.7-rc.2` 把 `sessions.list`
|
|
227
|
+
快照里的 `current` 字段**彻底移除**,该快照现在只有
|
|
228
|
+
`{ ids, byId, phase, projectionsBySession }` 四个字段(见
|
|
229
|
+
`dsh-api-session-controller/lib/types/client/sessions/service.js`)。
|
|
230
|
+
"哪个会话是主会话"改由**逐行 retain 计数**判定:
|
|
231
|
+
`sessions.retainInfo(id).getSnapshot().retainedBy.mainView > 0`
|
|
232
|
+
(官方参考实现:`dsh-client-ui-session` 的 `publishMain()`)。
|
|
233
|
+
- 🔴 **症状**:`syncFromSessions()` 读 `snap.current` 恒为 `undefined`
|
|
234
|
+
→ `currentSid` 永远停在 `null` → 所有 todo 记录被写进字面量桶
|
|
235
|
+
`"current"`,而渲染时按**真实 sessionId** 取值 → 取不到 →
|
|
236
|
+
**悬浮球有数据但渲染为空**。官方 todo 面板走
|
|
237
|
+
`useProjection("todos")`,不经过这条链路,所以**原生进度条一直正常**
|
|
238
|
+
—— 这正是"内核自带的正常、悬浮球空白"的原因。
|
|
239
|
+
- ✅ **修复 1|主会话判定兼容双内核**:新增 `resolveMainSessionId()`,
|
|
240
|
+
优先沿用旧内核的 `snapshot.current`,在新内核上按官方规则
|
|
241
|
+
`retainedBy.mainView` 判定;再回退到"唯一携带 todos 的行"
|
|
242
|
+
(避免 rc.2 的 subagent 行干扰)。另加 `matchLegacyCurrent()`
|
|
243
|
+
作为 `retainInfo` 途径的防御性兜底。
|
|
244
|
+
- ✅ **修复 2|历史数据重定向**:`currentSid` 首次确定时,把误存于
|
|
245
|
+
`"current"` 桶的记录迁移到真实 sessionId,否则修复后的**首帧仍为空**。
|
|
246
|
+
- ✅ **修复 3|DOM 兜底通道常开**:原先 `if (!hasSessionsSvc)
|
|
247
|
+
installPanelObserver()` 意味着"只要 sessions 服务在就永不装兜底",
|
|
248
|
+
于是主通道静默失效时**完全无感知**(本次事故即如此)。现改为**始终安装**
|
|
249
|
+
—— `readOfficialPanel()` 本身已有"绝不覆盖真实记录、仅在当前会话无数据时
|
|
250
|
+
建骨架"的保护,常开零成本,让此类内核漂移**自愈而非隐形**。看门狗轮询
|
|
251
|
+
也补了一条 `!currentSid` 时读官方面板的保险。
|
|
252
|
+
- 🧪 **验证**:7/7 运行时回归通过(rc.2 判定 / 旧内核兼容 / 不抖动 /
|
|
253
|
+
无 retainedBy 回退 / 空快照 / byId 缺失均不抛异常);`node --check`
|
|
254
|
+
语法通过;无 BOM;`__ModuleLoader__.load` 的 id 仍为
|
|
255
|
+
`dsh-todo-float-ball`(与 package.json、cordis.patch.yml 三处一致);
|
|
256
|
+
括号配平;三处副本 SHA256 完全一致。
|
|
257
|
+
回滚锚点:`~/.dsh/backups/todo-float-ball-client.js.*.bak-rc2fix-*`
|
|
258
|
+
## v0.13.0(2026-09-17)— 硬约束:每轮首个工具调用必须是 todo_write
|
|
259
|
+
|
|
260
|
+
- 🔴 **新增硬门(`lib/index.js` host half)**:`ctx.on("tools/pre-execute")` 拦截 —— **每个回复 turn 的第一个工具调用若不等于 `todo_write`,直接返回 `{kind:"deny", reason:"…"}`**,模型读到拒绝原因后会立即补写 todo 清单。
|
|
261
|
+
- **为什么**:注入的纪律文本(v0.9.0 起)只是"建议",实测在长任务/自动续轮时会漏写(作者本人 2026-09-17 连续多轮只顾查进度忘了刷新 todo,悬浮球停留在旧清单)→ **文本管不住,改由工具调度层强制执行**。
|
|
262
|
+
- **判定原理**:`dsh-agent-loop` 先 append 持久事件 `tool/call`,再进入 `dsh-tools` 的 dispatch(`tools/pre-execute`);因此门内看到「当前 turn 内 `tool/call` 恰好 1 个」= 本次即该 turn 首个工具调用。
|
|
263
|
+
- **安全设计**:整段 try/catch,取不到 `exec.agent.session.snapshotEvents()` 等任何异常形态一律 `next()` 放行 —— 判定失效只会"门不生效",**不会拦正常工作**。
|
|
264
|
+
- **开关**:插件 config `enforceFirstTodoWrite: false` 可关闭(默认开启)。
|
|
265
|
+
- 🔴 **修复:package.json 中文编码损坏**。上一版(0.12.1)用 PowerShell `Get-Content -Raw`(按 GBK 解码)+ `WriteAllText`(UTF-8 写)改版本号 → 中文 description 全变乱码且引号被截断 → **JSON 非法、`node --check` 报 `ERR_INVALID_PACKAGE_CONFIG`**。已从 `package.json.bak-20260914` 恢复并用 **Python `json`(UTF-8 显式)** 重写(现 1506 B,合法)。损坏副本留存 `package.json.broken-20260917` 供对照。
|
|
266
|
+
- **教训(通用)**:改含中文的 JSON/配置文件**一律用 Python `io.open(..., encoding="utf-8")` + `json`**,**禁止** PowerShell `Get-Content -Raw` + `WriteAllText` 组合阅读写回(编码不一致必坏)。
|
|
267
|
+
- 备份:`lib/index.js.bak-20260917-todogate`。
|
|
268
|
+
- 生效:host half 改动需**重启 DSH** 后加载。
|
|
269
|
+
|
|
270
|
+
## v0.12.1(2026-09-17)— 胶囊展开不再只有数字
|
|
271
|
+
|
|
272
|
+
- 🔴 **修复:胶囊(capsule)模式在无「进行中」任务时只显示裸数字**(用户实测反馈:"展开的胶囊不显示待办的具体事项内容只有数字",表现为 `待办 4/5`)。根因:`lib/client.js` 胶囊 sub 文本三级逻辑只认 `in_progress`(运行中任务),当清单为「全部 completed + 部分 pending」时取不到运行任务 → 回退成 `待办 N/M`。
|
|
273
|
+
- 修复:新增 **pending 兜底**——胶囊文本三级优先:①有进行中 → `▶ 任务文本`;②无进行中但有 pending → `○ 首个待办文本`;③全部完成 → `✓ 全部完成 N/N`。数字仍保留在胶囊左侧 label(`4/5`),不再出现"只有数字没有内容"。
|
|
274
|
+
- 备份:`lib/client.js.bak-20260917-capsule415`。验证:`node --check` 通过 + 复现脚本三例通过(`E:\DSHskills-test\_todo-plugin-fix-20260917\repro-415.js`)。
|
|
275
|
+
- 生效:client-plugin HMR(需 `pnpm run dev:web` 在跑)或刷新/重启 DSH。
|
|
276
|
+
|
|
277
|
+
## [Unreleased] - 2026-09-17(本地改动,未发布)
|
|
278
|
+
|
|
279
|
+
- 🔴 注入纪律新增第 6 条「正文待办必入清单」(用户强制):回复正文出现「待办/待审批/还没弄的/未完成/后续要」事项,必须同轮同步追加进 todo 清单,禁止只写正文不进清单;正文待办与 todo 清单必须一致。背景:2026-09-17 实测正文列 3 项待办未入清单(agent 执行疏漏)→ 用户要求强化到插件本体而非技能层。
|
|
280
|
+
- 备份:`lib/index.js.bak-20260917-todo6`。
|
|
281
|
+
|
|
13
282
|
## v0.12.0(2026-09-14)— 三球统一 128 皮肤系统
|
|
14
283
|
|
|
15
284
|
- 新增共享皮肤目录 `window.__DSH_BALL_SKINS`(与 dsh-skill-browser / dsh-font-enhancer 同一份目录):128 款皮肤 = 审定方案 01-128(20 招牌特效 + 8 克制精选 + 100 中国传统色单色相)。
|
package/README.md
CHANGED
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
**Keep your AI agent's task checklist always on screen — a floating progress ball for DeepSeek Harness (DSH).**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
English | [简体中文](README.zh.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Screenshots
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
> 展开态:`7/8` 进度胶囊 + 按状态列出的任务清单 + 历史分组折叠 + 底部未完成提醒;右侧「固定会话」区。
|
|
9
|
+
### Pinned sessions — side-by-side task progress
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Pin two conversations and the panel shows both progress columns at once, so you can watch parallel work without switching sessions.
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
> 收起态:球体显示 `7/8`,清单以窄条贴边常驻,不挡内容。
|
|
13
|
+

|
|
16
14
|
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
### Capsule mode
|
|
18
|
+
|
|
19
|
+
Right-click the ball to collapse it into a slim capsule that shows the running task and the `done/total` count — ideal when screen space is tight.
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
### Skins
|
|
24
|
+
|
|
25
|
+
120 built-in skins, shared with the sibling skill-browser / font-enhancer balls so all three stay visually consistent.
|
|
26
|
+
|
|
27
|
+

|
|
17
28
|
## What is this?
|
|
18
29
|
|
|
19
30
|
When an AI agent in DSH works on a multi-step task, it records its plan with the built-in `todo_write` tool. The official UI shows this plan in a small strip above the input box — but the strip is easy to miss, disappears into the conversation flow, and collapses while the agent is still working.
|
|
@@ -27,6 +38,50 @@ When an AI agent in DSH works on a multi-step task, it records its plan with the
|
|
|
27
38
|
|
|
28
39
|
It is a pure, read-only companion: the plugin never modifies the official panel, the conversation, or any other plugin.
|
|
29
40
|
|
|
41
|
+
## 功能总览 · At a glance(中英对照 / Bilingual)
|
|
42
|
+
|
|
43
|
+
### Floating ball · 悬浮球
|
|
44
|
+
|
|
45
|
+
| 中文 | English |
|
|
46
|
+
|---|---|
|
|
47
|
+
| 常驻可拖拽悬浮球(默认右下角),位置存 `localStorage` 并跨重启恢复,越界旧位置自动拉回 | Persistent draggable ball (default bottom-right); position saved to `localStorage` and restored across restarts, off-screen positions clamped back |
|
|
48
|
+
| 球面实时显示 `done/total` + 当前进行中任务名(截断),随 todo_write 实时刷新 | Live `done/total` plus the active task's name on the ball face, updated in real time |
|
|
49
|
+
| 状态颜色一眼可读:橙脉动=进行中 / 绿=全部完成 / 蓝=只有待办 / 灰=暂无清单 | Status colours at a glance: orange pulse = working, green = all done, blue = pending only, gray = no list |
|
|
50
|
+
| 每项任务带图标与配色:✓ 完成(绿+删除线)、▶ 进行中(橙)、○ 待办(灰虚线) | Per-item icons & colours: ✓ done (green, strikethrough), ▶ in progress (orange), ○ pending (dashed gray) |
|
|
51
|
+
|
|
52
|
+
### Panel & data · 面板与数据
|
|
53
|
+
|
|
54
|
+
| 中文 | English |
|
|
55
|
+
|---|---|
|
|
56
|
+
| 点球折叠/展开面板,靠屏幕边缘自动翻侧 | Click to fold/expand; the panel flips sides near the screen edge |
|
|
57
|
+
| 双路数据同步:A 路 MutationObserver 抓官方 todo 面板,B 路被动解析会话投影帧——官方面板折叠时也有完整清单 | Dual-channel sync: A) DOM observer on the official panel, B) passive session-projection parsing — full list even when the strip is collapsed |
|
|
58
|
+
| Shadow DOM + `all:initial` 样式隔离,不进不出,主题/皮肤插件互不干扰 | Shadow DOM with `all:initial` — no style leaks in or out, immune to theme/skin plugins |
|
|
59
|
+
| 桌面端(Electron)与网页端同一份代码双端可用 | One codebase for Desktop (Electron) and the web UI |
|
|
60
|
+
|
|
61
|
+
### History & pinned sessions · 历史与固定会话
|
|
62
|
+
|
|
63
|
+
| 中文 | English |
|
|
64
|
+
|---|---|
|
|
65
|
+
| 快照合并不再冲掉旧任务——旧任务进入历史归档区 | Snapshots merge instead of replacing — older todos become a history archive |
|
|
66
|
+
| 行级 ✕ 隐藏、两个独立折叠行、🧹 批量清理、♻️ 一键恢复、📋 整行复制 | Per-row ✕ hide, two independent fold rows, 🧹 batch cleanup, ♻️ one-click restore, 📋 full-text copy |
|
|
67
|
+
| 📌 固定会话与当前对话共用同一历史渲染器,状态按会话独立 | 📌 Pinned sessions render through the same history renderer, with per-session state |
|
|
68
|
+
| ⇄ 布局切换:上下堆叠 ⇄ 左右并排(左当前列表、右固定会话,带列标题) | ⇄ layout switch: stacked ⇄ side-by-side (current + pinned columns with captions) |
|
|
69
|
+
|
|
70
|
+
### Discipline injection · 纪律注入
|
|
71
|
+
|
|
72
|
+
| 中文 | English |
|
|
73
|
+
|---|---|
|
|
74
|
+
| 宿主端向每次会话系统提示注入 todo 纪律段(order=190,约 340 字)——装上插件即生效,无需加载技能 | Host injects a stable todo-discipline section (order=190, ~340 chars) into every session — works the moment the plugin is installed |
|
|
75
|
+
| 硬门:每轮首个工具调用若不是 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`) |
|
|
76
|
+
| 只有显式布尔 `false` 才关闭;`"false"`/`0`/缺 config 均保持开启 | Only an explicit boolean `false` disables it; `"false"`/`0`/missing config keep it ON |
|
|
77
|
+
|
|
78
|
+
### Skins & privacy · 皮肤与隐私
|
|
79
|
+
|
|
80
|
+
| 中文 | English |
|
|
81
|
+
|---|---|
|
|
82
|
+
| 三球共享 128 款皮肤目录(含 6 款经典旧皮肤),任一处切换全同步 | Shares the 128-skin catalogue across the three balls (6 classic skins kept), synced everywhere |
|
|
83
|
+
| 零遥测、零数据上传,仅一条本机回环健康路由 | Zero telemetry, zero data upload — just a loopback-only health route |
|
|
84
|
+
|
|
30
85
|
## Features
|
|
31
86
|
|
|
32
87
|
| Feature | Detail |
|
|
@@ -100,9 +155,6 @@ DSH skills are **loaded on demand**: a session that never loads the `todo-show-d
|
|
|
100
155
|
- Only an explicit boolean `false` disables it; `"false"` / `0` / typos / a missing `config` all keep it ON (guards against accidental shutdown).
|
|
101
156
|
- The injected text is deliberately short (a system-prompt section costs tokens in every session); the full rules stay in the `todo-show-discipline` skill, which is disabled for model invocation by default once this plugin is installed, and can be re-enabled if you uninstall the plugin.
|
|
102
157
|
|
|
103
|
-
## 🎨 Shared 128 ball skins (v0.12+)
|
|
104
|
-
This ball shares one skin catalog (window.__DSH_BALL_SKINS, localStorage key dsh-ball-skin) with **dsh-skill-browser** and **dsh-font-enhancer**: switch a skin anywhere (panel 🎨 or DSH settings) and all three balls + their panels recolor in sync. The legacy 6 skins stay under the 经典 group; each sibling ball also has a per-ball classic escape hatch.
|
|
105
|
-
|
|
106
158
|
## Install
|
|
107
159
|
|
|
108
160
|
The plugin is a standard DSH npm package (`dsh.bundle` self-declared). Two ways:
|
package/README.zh.md
CHANGED
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
**把 AI 干活的任务清单常驻挂在一个悬浮球上 —— DeepSeek Harness(DSH)进度悬浮球插件。**
|
|
4
4
|
|
|
5
|
-
**让 AI 的任务清单跑出侧栏,常驻在你眼前。**
|
|
6
|
-
|
|
7
5
|
[English](README.md) | 简体中文
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
## 效果展示
|
|
8
|
+
|
|
9
|
+
### 固定标签 · 双对话任务进度
|
|
10
|
+
|
|
11
|
+
固定两个会话后,面板同时显示两栏任务进度,并行任务不用来回切换会话就能一起盯着。
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
### 胶囊模式
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
右键球体可收起为细长胶囊,只显示当前进行中的任务和 `已完成/总数`——屏幕空间紧张时用。
|
|
12
20
|
|
|
13
|
-

|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
### 皮肤
|
|
16
24
|
|
|
25
|
+
内置 120 种皮肤,与姊妹插件 skill-browser / font-enhancer 的球共用同一套皮肤目录,三球外观保持统一。
|
|
26
|
+
|
|
27
|
+

|
|
17
28
|
## 这是什么?
|
|
18
29
|
|
|
19
30
|
DSH 里的 AI 在推进多步骤任务时,会用内置的 `todo_write` 工具记录任务清单。官方界面把这份清单渲染成输入框上方的一条进度条——但它很容易被忽略、会随着对话滚动走远、而且 AI 还在干活时它默认是折叠的。
|
|
@@ -27,6 +38,50 @@ DSH 里的 AI 在推进多步骤任务时,会用内置的 `todo_write` 工具
|
|
|
27
38
|
|
|
28
39
|
它是一个纯只读的伴生插件:不修改官方面板、不改对话流、不碰任何其他插件的实现。
|
|
29
40
|
|
|
41
|
+
## 功能总览 · At a glance(中英对照 / Bilingual)
|
|
42
|
+
|
|
43
|
+
### 悬浮球 · Floating ball
|
|
44
|
+
|
|
45
|
+
| 中文 | English |
|
|
46
|
+
|---|---|
|
|
47
|
+
| 常驻可拖拽悬浮球(默认右下角),位置记忆跨重启恢复,越界自动拉回 | Persistent draggable ball, position remembered, off-screen clamped back |
|
|
48
|
+
| 球面实时 `完成数/总数` + 当前进行中任务名(截断) | Live `done/total` + active task name, updated in real time |
|
|
49
|
+
| 状态颜色:橙脉动=进行中 / 绿=完成 / 蓝=待办 / 灰=空清单 | Status colours: orange pulse / green / blue / gray |
|
|
50
|
+
| 每项带图标与配色:✓ 完成(绿+删除线)、▶ 进行中(橙)、○ 待办(灰虚线) | Per-item icons: ✓ done, ▶ in progress, ○ pending |
|
|
51
|
+
|
|
52
|
+
### 面板与数据 · Panel & data
|
|
53
|
+
|
|
54
|
+
| 中文 | English |
|
|
55
|
+
|---|---|
|
|
56
|
+
| 点球折叠/展开,靠屏幕边缘自动翻侧 | Click to fold/expand; flips sides near the edge |
|
|
57
|
+
| 双路数据同步:DOM 观察 + 会话投影帧解析——官方面板折叠时也有完整清单 | Dual-channel sync: DOM observer + projection frames — full list even when collapsed |
|
|
58
|
+
| Shadow DOM + `all:initial` 样式隔离 | Shadow DOM with `all:initial` isolation |
|
|
59
|
+
| 桌面端 + 网页端双端可用 | Works on Desktop and web |
|
|
60
|
+
|
|
61
|
+
### 历史与固定会话 · History & pinned sessions
|
|
62
|
+
|
|
63
|
+
| 中文 | English |
|
|
64
|
+
|---|---|
|
|
65
|
+
| 快照合并而非替换,旧任务进历史归档区 | Snapshots merge, older todos become a history archive |
|
|
66
|
+
| 行级 ✕ 隐藏、两个折叠行、🧹 批量清理、♻️ 一键恢复、📋 整行复制 | Per-row hide, fold rows, batch cleanup, one-click restore, full-text copy |
|
|
67
|
+
| 📌 固定会话共用同一渲染器,状态按会话独立 | Pinned sessions share the renderer, per-session state |
|
|
68
|
+
| ⇄ 上下堆叠 ⇄ 左右并排布局切换 | ⇄ stacked / side-by-side layout switch |
|
|
69
|
+
|
|
70
|
+
### 纪律注入 · Discipline injection
|
|
71
|
+
|
|
72
|
+
| 中文 | English |
|
|
73
|
+
|---|---|
|
|
74
|
+
| 向每次会话系统提示注入 todo 纪律(order=190)——装插件即生效 | Injects todo discipline into every session — works on install |
|
|
75
|
+
| 硬门:每轮首个工具调用必须是 todo_write(可用 `enforceFirstTodoWrite: false` 关闭) | Hard gate: first tool call per turn must be `todo_write` (toggle) |
|
|
76
|
+
| 只有显式布尔 `false` 才关闭 | Only explicit `false` disables it |
|
|
77
|
+
|
|
78
|
+
### 皮肤与隐私 · Skins & privacy
|
|
79
|
+
|
|
80
|
+
| 中文 | English |
|
|
81
|
+
|---|---|
|
|
82
|
+
| 三球共享 128 款皮肤(含经典旧皮肤) | Shares the 128-skin catalogue across the three balls |
|
|
83
|
+
| 零遥测、零上传,仅回环健康路由 | Zero telemetry, loopback-only health route |
|
|
84
|
+
|
|
30
85
|
## 功能清单
|
|
31
86
|
|
|
32
87
|
| 功能 | 说明 |
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -265,7 +265,7 @@ window.__ModuleLoader__.load({
|
|
|
265
265
|
// source is untouched); per session so it never bleeds across chats.
|
|
266
266
|
var hiddenItems = {}; // sessionId -> { content:true, ... }
|
|
267
267
|
var HIDE_KEY = "dsh-todo-float-ball-hidden-v1";
|
|
268
|
-
var ui = { root: null, ball: null, panel: null, list: null, summary: null, ctitle: null, pinBtn: null, pinSec: null };
|
|
268
|
+
var ui = { root: null, styleEl: null, shadow: null, ball: null, panel: null, list: null, summary: null, ctitle: null, pinBtn: null, pinSec: null };
|
|
269
269
|
|
|
270
270
|
function normSid(sid) {
|
|
271
271
|
return (typeof sid === "string" && sid) ? sid : "current";
|
|
@@ -549,8 +549,9 @@ window.__ModuleLoader__.load({
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
// ---------- data ingestion ----------
|
|
552
|
-
function setSessionTodos(sid, list) {
|
|
552
|
+
function setSessionTodos(sid, list, opts) {
|
|
553
553
|
sid = normSid(sid);
|
|
554
|
+
var fromFallback = !!(opts && opts.fallback);
|
|
554
555
|
if (!Array.isArray(list)) return false; // false = nothing changed
|
|
555
556
|
var norm = [];
|
|
556
557
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -632,16 +633,99 @@ window.__ModuleLoader__.load({
|
|
|
632
633
|
// ends. Everything after snapLen is accumulated history — rendered
|
|
633
634
|
// collapsed (completed-only) by renderList; the snapshot itself stays
|
|
634
635
|
// fully visible.
|
|
635
|
-
|
|
636
|
+
//
|
|
637
|
+
// FLICKER FIX (2026-09-28): snapLen used to be `norm.length` — THIS
|
|
638
|
+
// frame's size. todo_write is a WHOLE-LIST replacement, and a model
|
|
639
|
+
// usually rewrites the full plan but sometimes re-emits only the item it
|
|
640
|
+
// just touched. With snapLen tracking the frame, one 1-item frame
|
|
641
|
+
// collapsed the snapshot window to a single row: the ball flipped
|
|
642
|
+
// 0/1 -> 7/9 -> 0/1 while the task never changed. The snapshot boundary
|
|
643
|
+
// is a high-water mark, not a per-frame value: it only ever GROWS, so a
|
|
644
|
+
// terse frame can never shrink the live plan back to one row.
|
|
645
|
+
// (History stays whatever it already was; only the boundary is sticky.)
|
|
646
|
+
var prevSnap = (b && typeof b.snapLen === "number") ? b.snapLen : 0;
|
|
647
|
+
// FLICKER FIX: only the authoritative channel may RAISE the snapshot
|
|
648
|
+
// boundary; the DOM fallback must never enlarge it (its "list" is just
|
|
649
|
+
// what React painted, so treating it as a full plan would misreport
|
|
650
|
+
// history rows as live tasks).
|
|
651
|
+
var snapLen = fromFallback
|
|
652
|
+
? Math.min(prevSnap > 0 ? prevSnap : norm.length, merged.length)
|
|
653
|
+
: Math.min(Math.max(prevSnap, norm.length), merged.length);
|
|
654
|
+
// FLICKER FIX: `primary` marks a row written by the AUTHORITATIVE
|
|
655
|
+
// sessions channel. The DOM fallback must neither set it nor clear it
|
|
656
|
+
// (once the service has spoken for this session, it stays authoritative
|
|
657
|
+
// even if the panel keeps firing its observer).
|
|
658
|
+
var isPrimary = fromFallback ? !!(b && b.primary) : true;
|
|
659
|
+
bySession[sid] = { todos: merged, sig: sig, stale: false, at: Date.now(), snapLen: snapLen, primary: isPrimary };
|
|
636
660
|
render();
|
|
637
661
|
persistSoon();
|
|
638
662
|
return true; // a new snapshot was accepted -> the caller must re-render
|
|
639
663
|
}
|
|
640
664
|
|
|
641
665
|
// Primary channel: the official sessions service.
|
|
642
|
-
// list snapshot shape
|
|
643
|
-
// { ids:[...], byId:{ sid:{
|
|
644
|
-
//
|
|
666
|
+
// list snapshot shape:
|
|
667
|
+
// pre-0.1.7 : { ids:[...], byId:{ sid:{...,projectionValues:{todos,...}} }, current: sid, phase }
|
|
668
|
+
// 0.1.7-rc.2: { ids:[...], byId:{ sid:{...,projectionValues:{todos,...}, retainedBy:{mainView:n}} },
|
|
669
|
+
// phase, projectionsBySession } <- `current` was REMOVED
|
|
670
|
+
//
|
|
671
|
+
// rc.2 moved "which session is the main one" off the list snapshot and onto
|
|
672
|
+
// per-row retention: sessions.retainInfo(id).getSnapshot().retainedBy, with
|
|
673
|
+
// the viewing surface counted under the `mainView` key. dsh-client-ui-session
|
|
674
|
+
// (publishMain) is the reference implementation:
|
|
675
|
+
// byId[keep currentId while retainedBy.mainView>0]
|
|
676
|
+
// ?? Object.values(byId).find(c => (c.retainedBy.mainView ?? 0) > 0)?.id
|
|
677
|
+
// Reading snap.current on rc.2 yields undefined forever, which pinned every
|
|
678
|
+
// record under the literal bucket "current" while the renderer looked up the
|
|
679
|
+
// REAL session id -> the ball had data but always rendered empty.
|
|
680
|
+
// resolveMainSessionId() implements the official rule and keeps the legacy
|
|
681
|
+
// snapshot.current as a fallback so this file works on BOTH kernel lines.
|
|
682
|
+
function resolveMainSessionId(snap) {
|
|
683
|
+
// legacy shape first: an explicit current sid is authoritative when present
|
|
684
|
+
if (typeof snap.current === "string" && snap.current) return snap.current;
|
|
685
|
+
if (!snap.byId) return matchLegacyCurrent();
|
|
686
|
+
// keep the already-known id while it is still the main view
|
|
687
|
+
if (currentSid && snap.byId[currentSid]) {
|
|
688
|
+
var cur = snap.byId[currentSid];
|
|
689
|
+
if (cur && cur.retainedBy && (cur.retainedBy.mainView || 0) > 0) return currentSid;
|
|
690
|
+
}
|
|
691
|
+
var rows = snap.byId;
|
|
692
|
+
var best = null, bestCount = 0;
|
|
693
|
+
for (var rid in rows) {
|
|
694
|
+
var row = rows[rid];
|
|
695
|
+
if (!row) continue;
|
|
696
|
+
var n = row.retainedBy ? (row.retainedBy.mainView || 0) : 0;
|
|
697
|
+
if (n > bestCount) { bestCount = n; best = rid; }
|
|
698
|
+
}
|
|
699
|
+
if (best) return best;
|
|
700
|
+
// last resort: a row that actually carries todos (rc.2 subagent rows do not)
|
|
701
|
+
for (var rid2 in rows) {
|
|
702
|
+
var row2 = rows[rid2];
|
|
703
|
+
var pv2 = row2 && row2.projectionValues;
|
|
704
|
+
if (pv2 && typeof pv2 === "object" && Array.isArray(pv2.todos) && pv2.todos.length > 0) return rid2;
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Some rc.2 builds expose the main session through the ui-session binding
|
|
710
|
+
// rather than the list snapshot. Probe it defensively (never throw).
|
|
711
|
+
function matchLegacyCurrent() {
|
|
712
|
+
try {
|
|
713
|
+
if (!currentSessions) return null;
|
|
714
|
+
var info = currentSessions.retainInfo;
|
|
715
|
+
if (typeof info !== "function") return null;
|
|
716
|
+
var snap = currentSessions.list.getSnapshot();
|
|
717
|
+
var rows = snap && snap.byId;
|
|
718
|
+
if (!rows) return null;
|
|
719
|
+
for (var rid in rows) {
|
|
720
|
+
try {
|
|
721
|
+
var s = info.call(currentSessions, rid).getSnapshot();
|
|
722
|
+
if (s && s.retainedBy && (s.retainedBy.mainView || 0) > 0) return rid;
|
|
723
|
+
} catch (e2) {}
|
|
724
|
+
}
|
|
725
|
+
} catch (e) {}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
|
|
645
729
|
function syncFromSessions() {
|
|
646
730
|
try {
|
|
647
731
|
if (!currentSessions || !currentSessions.list || typeof currentSessions.list.getSnapshot !== "function") return;
|
|
@@ -660,9 +744,21 @@ window.__ModuleLoader__.load({
|
|
|
660
744
|
if (setSessionTodos(id, pv.todos === null ? [] : pv.todos)) changed = true;
|
|
661
745
|
}
|
|
662
746
|
}
|
|
663
|
-
|
|
664
|
-
|
|
747
|
+
var mainId = resolveMainSessionId(snap);
|
|
748
|
+
if (mainId && mainId !== currentSid) {
|
|
749
|
+
var prev = currentSid;
|
|
750
|
+
currentSid = mainId;
|
|
665
751
|
changed = true;
|
|
752
|
+
// rc.2 fix: records already filed under the literal "current" bucket
|
|
753
|
+
// (written while currentSid was null) must be re-homed onto the real
|
|
754
|
+
// session id, otherwise the first render after the fix stays empty.
|
|
755
|
+
if (bySession["current"] && !bySession[mainId]) {
|
|
756
|
+
bySession[mainId] = bySession["current"];
|
|
757
|
+
delete bySession["current"];
|
|
758
|
+
}
|
|
759
|
+
if (prev === null || prev === undefined) {
|
|
760
|
+
try { render(); } catch (e0) {}
|
|
761
|
+
}
|
|
666
762
|
}
|
|
667
763
|
// Only touch the DOM when something actually moved. This is what lets
|
|
668
764
|
// the 2s safety-net poll be effectively free while nothing changes
|
|
@@ -705,11 +801,37 @@ window.__ModuleLoader__.load({
|
|
|
705
801
|
return NaN;
|
|
706
802
|
}
|
|
707
803
|
|
|
804
|
+
// FLICKER FIX (2026-09-28): is the authoritative sessions channel already
|
|
805
|
+
// serving REAL data for this session? Only then must the DOM panel keep
|
|
806
|
+
// its hands off. A record only counts as authoritative when the primary
|
|
807
|
+
// channel wrote it (rec.primary) AND it carries rows. A skeleton record
|
|
808
|
+
// (rec.__skeleton, built from the panel's collapsed header counts) is
|
|
809
|
+
// explicitly NOT authoritative: the panel is allowed to refine its own
|
|
810
|
+
// placeholder once it can read real rows.
|
|
811
|
+
function hasPrimaryData(sid, rec) {
|
|
812
|
+
if (!rec) return false;
|
|
813
|
+
if (rec.__skeleton) return false;
|
|
814
|
+
if (!rec.primary) return false;
|
|
815
|
+
return !!(rec.todos && rec.todos.length > 0);
|
|
816
|
+
}
|
|
708
817
|
function readOfficialPanel() {
|
|
709
818
|
var panel = document.querySelector('[data-testid="todo-panel"]');
|
|
710
819
|
if (!panel) return;
|
|
711
820
|
var items = panel.querySelectorAll("ul li[data-status]");
|
|
712
821
|
if (items.length > 0) {
|
|
822
|
+
// FLICKER FIX (2026-09-28): the DOM panel and the sessions service are
|
|
823
|
+
// two DIFFERENT views of the same data and must never both drive the
|
|
824
|
+
// ball. The service answers with the authoritative projection (whole
|
|
825
|
+
// list, history merge, sticky boundary); the panel answers with
|
|
826
|
+
// whatever React happens to have painted right now — a collapsed strip,
|
|
827
|
+
// a mid-render slice, or a subagent's rows. Letting the panel write
|
|
828
|
+
// unconditionally made the two alternate every observer tick, so the
|
|
829
|
+
// ball flipped 7/9 (service) <-> 0/1 (panel) with the task unchanged.
|
|
830
|
+
// The panel is now strictly a FALLBACK: it only feeds the ball while
|
|
831
|
+
// the authoritative channel has produced nothing for this session.
|
|
832
|
+
var sid0 = normSid(currentSid);
|
|
833
|
+
var rec0 = bySession[sid0];
|
|
834
|
+
if (hasPrimaryData(sid0, rec0)) return;
|
|
713
835
|
var list = [];
|
|
714
836
|
for (var i = 0; i < items.length; i++) {
|
|
715
837
|
var li = items[i];
|
|
@@ -718,7 +840,7 @@ window.__ModuleLoader__.load({
|
|
|
718
840
|
var content = contentEl ? (contentEl.textContent || "").trim() : "";
|
|
719
841
|
if (content) list.push({ content: content, status: st || "pending" });
|
|
720
842
|
}
|
|
721
|
-
if (list.length > 0) { setSessionTodos(currentSid, list); return; }
|
|
843
|
+
if (list.length > 0) { setSessionTodos(currentSid, list, { fallback: true }); return; }
|
|
722
844
|
}
|
|
723
845
|
// collapsed: skeleton only if the current session has no real data
|
|
724
846
|
var cur = bySession[normSid(currentSid)];
|
|
@@ -818,6 +940,38 @@ window.__ModuleLoader__.load({
|
|
|
818
940
|
if (s.anim === "flashy") {
|
|
819
941
|
ball.push(".tfb-ball.tfb-active{animation:tfb-pulse 1.8s ease-in-out infinite}");
|
|
820
942
|
}
|
|
943
|
+
// BREATHE-FOR-UNIFIED-SKINS (2026-09-28): the classic skins (nebula /
|
|
944
|
+
// nebB / nebC) each carried `animation:tfbBreathe 3.2s ease-in-out
|
|
945
|
+
// infinite` on .tfb-ball, but the unified 128-skin path never emitted
|
|
946
|
+
// that rule — it only inherited whatever the per-skin `rim` / `band` /
|
|
947
|
+
// `extra` fields declared (mostly dshSkinSpin on the ring). So moving
|
|
948
|
+
// from a classic skin to any unified skin silently dropped the
|
|
949
|
+
// "breathing" motion and the ball read as static.
|
|
950
|
+
//
|
|
951
|
+
// Re-added for every skin, same 3.2s cadence as the classic ones for
|
|
952
|
+
// continuity, driven by the per-skin variables (--st / --stA) so each
|
|
953
|
+
// palette keeps its own colour.
|
|
954
|
+
//
|
|
955
|
+
// CRITICAL: this breathes with FILTER + BOX-SHADOW ONLY — never
|
|
956
|
+
// transform. The ball's base rule owns `transition:transform .15s ease`
|
|
957
|
+
// and the drag affordance lives on `.tfb-ball:hover{transform:scale(1.08)}`
|
|
958
|
+
// / `:active{transform:scale(.95)}`. A running animation outranks a
|
|
959
|
+
// non-!important declaration for the SAME property, so animating
|
|
960
|
+
// transform here would have silently killed the hover/press feedback.
|
|
961
|
+
// (The classic skins got away with it because they had no ring/band to
|
|
962
|
+
// contrast against, but the feedback was equally dead there.) Animating
|
|
963
|
+
// only non-transform properties leaves hover/active fully intact.
|
|
964
|
+
//
|
|
965
|
+
// `s.extra` / `s.rim` are injected AFTER this block, so a skin that wants
|
|
966
|
+
// its own motion on .tfb-ball still wins on source order.
|
|
967
|
+
ball.push(
|
|
968
|
+
'@keyframes tfbBreathe{0%,100%{filter:brightness(.93) saturate(.97)}50%{filter:brightness(1.14) saturate(1.08)}}',
|
|
969
|
+
'@keyframes tfbBreatheSoft{0%,100%{filter:brightness(.97)}50%{filter:brightness(1.06)}}',
|
|
970
|
+
'.tfb-ball{animation:tfbBreathe 3.2s ease-in-out infinite}',
|
|
971
|
+
'.tfb-ball.tfb-idle{animation:tfbBreatheSoft 4.2s ease-in-out infinite}',
|
|
972
|
+
'.tfb-ball.tfb-done{animation:none}',
|
|
973
|
+
'@media (prefers-reduced-motion: reduce){.tfb-ball,.tfb-ball.tfb-idle{animation:none!important}}'
|
|
974
|
+
);
|
|
821
975
|
var fxc = SK.fx(currentSkinId, { B: ".tfb-ball", BAND: ".tfb-ball .tfb-orb-band", RIM: ".tfb-ball .tfb-orb-rim" });
|
|
822
976
|
if (fxc) ball.push(fxc);
|
|
823
977
|
if (!s.rim) ball.push(".tfb-ball .tfb-orb-rim{display:none}");
|
|
@@ -1338,9 +1492,33 @@ window.__ModuleLoader__.load({
|
|
|
1338
1492
|
ui.themeMenu.innerHTML = html;
|
|
1339
1493
|
}
|
|
1340
1494
|
|
|
1341
|
-
|
|
1495
|
+
// FLICKER FIX (2026-09-28): last line of defence. The ball face is written
|
|
1496
|
+
// on every render() and on every 2s watchdog tick; each write to
|
|
1497
|
+
// textContent/className/style forces the compositor to repaint the element,
|
|
1498
|
+
// which reads as a visible blink even when the value is identical. Record
|
|
1499
|
+
// the last painted signature and skip the DOM entirely when nothing that
|
|
1500
|
+
// shows on the face actually changed. (The panel/list are NOT gated here:
|
|
1501
|
+
// they carry interactive state that legitimately re-renders.)
|
|
1502
|
+
var lastBallSig = null;
|
|
1503
|
+
// FLICKER FIX part 2 (2026-09-28): the guard above MUST NOT swallow writes
|
|
1504
|
+
// that carry more than text. `ui.ball.className = ...` is what RE-ARMS the
|
|
1505
|
+
// CSS animations (tfbBreathe / tfbRimSpin / tfbGlow on .tfb-ball,
|
|
1506
|
+
// .tfb-orb-rim, .tfb-label) after a skin change, because rewriting
|
|
1507
|
+
// className makes the engine recompute the element's style and restart its
|
|
1508
|
+
// animations. applyThemeNow() swaps the <style> text and then calls
|
|
1509
|
+
// render(): with the guard applying unconditionally, renderBall() bailed
|
|
1510
|
+
// out on an unchanged signature, so a NEW skin was injected but the ball
|
|
1511
|
+
// was never re-decorated — the animation looked frozen and the skin switch
|
|
1512
|
+
// looked dead. `force` is the bypass for every caller whose job is to
|
|
1513
|
+
// re-decorate the element (skin/theme application, DOM rebuild, visibility
|
|
1514
|
+
// restore), while the plain 2s watchdog and data-driven renders stay gated
|
|
1515
|
+
// and therefore silent.
|
|
1516
|
+
function renderBall(force) {
|
|
1342
1517
|
if (!ui.ball) return;
|
|
1343
1518
|
var st = ballState();
|
|
1519
|
+
var sig = st.cls + "|" + st.label + "|" + (capsule ? "1" : "0");
|
|
1520
|
+
if (!force && sig === lastBallSig) return;
|
|
1521
|
+
lastBallSig = sig;
|
|
1344
1522
|
ui.ball.className = "tfb-ball " + st.cls + (capsule ? " tfb-capsule" : "");
|
|
1345
1523
|
var labelEl = ui.ball.querySelector(".tfb-label");
|
|
1346
1524
|
if (labelEl) labelEl.textContent = st.label;
|
|
@@ -1366,9 +1544,19 @@ window.__ModuleLoader__.load({
|
|
|
1366
1544
|
for (var r = 0; r < list.length; r++) {
|
|
1367
1545
|
if (list[r].status === "in_progress") { running = list[r].content; break; }
|
|
1368
1546
|
}
|
|
1547
|
+
// v0.12.1: when nothing is in_progress, fall back to the first
|
|
1548
|
+
// PENDING item's text instead of showing bare numbers — users
|
|
1549
|
+
// reported the capsule showing only "待办 N/M" with no task text
|
|
1550
|
+
// whenever the list was completed + pending (no running item).
|
|
1551
|
+
var nextPend = "";
|
|
1552
|
+
for (var p = 0; p < list.length; p++) {
|
|
1553
|
+
if (list[p].status === "pending") { nextPend = list[p].content; break; }
|
|
1554
|
+
}
|
|
1369
1555
|
sub = running
|
|
1370
1556
|
? "▶ " + running
|
|
1371
|
-
:
|
|
1557
|
+
: nextPend
|
|
1558
|
+
? "○ " + nextPend
|
|
1559
|
+
: "待办 " + c1.done + "/" + c1.total;
|
|
1372
1560
|
}
|
|
1373
1561
|
} else if (pinned.length) {
|
|
1374
1562
|
for (var i = 0; i < pinned.length; i++) {
|
|
@@ -1417,8 +1605,12 @@ window.__ModuleLoader__.load({
|
|
|
1417
1605
|
var layoutHz = false;
|
|
1418
1606
|
try { layoutHz = localStorage.getItem("dsh-todo-float-ball-layout") === "1"; } catch (e) {}
|
|
1419
1607
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1608
|
+
// `force` is threaded straight to renderBall(): pass true from any caller
|
|
1609
|
+
// whose purpose is re-decoration (skin/theme application, DOM rebuild,
|
|
1610
|
+
// visibility restore) rather than a data refresh. Data-driven renders and
|
|
1611
|
+
// the 2s watchdog call it plain, so the flicker guard keeps working.
|
|
1612
|
+
function render(force) {
|
|
1613
|
+
renderBall(force);
|
|
1422
1614
|
renderList();
|
|
1423
1615
|
if (expanded && ui.panel) positionPanel();
|
|
1424
1616
|
}
|
|
@@ -1445,15 +1637,30 @@ window.__ModuleLoader__.load({
|
|
|
1445
1637
|
try { applyThemeNow(); } catch (e) {}
|
|
1446
1638
|
expanded = false;
|
|
1447
1639
|
if (ui.panel) ui.panel.classList.remove("tfb-open");
|
|
1448
|
-
//
|
|
1449
|
-
|
|
1640
|
+
// LAYOUT PERSISTENCE FIX (2026-09-28): this used to fire
|
|
1641
|
+
// refreshPlugin() unconditionally 120ms after every collapse, tearing the
|
|
1642
|
+
// whole UI down and rebuilding it. That is what silently dropped the
|
|
1643
|
+
// side-by-side layout on the rebuilt panel, and it also threw away live
|
|
1644
|
+
// panel state (open folds, inline editors, scroll position) for no
|
|
1645
|
+
// reason — the user only collapsed a popover, nothing structural changed.
|
|
1646
|
+
// Re-apply the theme in place instead: same "theme lands immediately"
|
|
1647
|
+
// goal, no DOM churn. (refreshPlugin() is still the right tool for real
|
|
1648
|
+
// structural reloads, e.g. a skin/structure switch from the settings
|
|
1649
|
+
// section; buildUI() now also restores the layout, so even that path is
|
|
1650
|
+
// safe.)
|
|
1651
|
+
try { applyThemeNow(); } catch (e1) {}
|
|
1652
|
+
try { if (ui.panel && layoutHz) ui.panel.classList.add("tfb-hz"); } catch (e2) {}
|
|
1450
1653
|
}
|
|
1451
1654
|
function refreshPlugin() {
|
|
1452
1655
|
try {
|
|
1453
1656
|
var h = document.getElementById(BALL_ID);
|
|
1454
1657
|
if (h) h.remove();
|
|
1455
|
-
ui = { root: null, ball: null, panel: null, list: null, summary: null, ctitle: null, pinBtn: null, pinSec: null, themeMenu: null };
|
|
1658
|
+
ui = { root: null, styleEl: null, shadow: null, ball: null, panel: null, list: null, summary: null, ctitle: null, pinBtn: null, pinSec: null, themeMenu: null };
|
|
1456
1659
|
expanded = false;
|
|
1660
|
+
// FLICKER FIX: the old DOM is gone, so the paint cache must be dropped
|
|
1661
|
+
// too — otherwise the rebuilt ball could be skipped as "unchanged"
|
|
1662
|
+
// while the element it describes no longer exists.
|
|
1663
|
+
lastBallSig = null;
|
|
1457
1664
|
buildUI();
|
|
1458
1665
|
applyBallVisibility();
|
|
1459
1666
|
} catch (e) {}
|
|
@@ -1471,7 +1678,6 @@ window.__ModuleLoader__.load({
|
|
|
1471
1678
|
var style = document.createElement("style");
|
|
1472
1679
|
style.textContent = cssText();
|
|
1473
1680
|
shadow.appendChild(style);
|
|
1474
|
-
|
|
1475
1681
|
var root = document.createElement("div");
|
|
1476
1682
|
root.className = "tfb-root";
|
|
1477
1683
|
root.innerHTML =
|
|
@@ -1510,6 +1716,15 @@ window.__ModuleLoader__.load({
|
|
|
1510
1716
|
if (!host.parentNode) mount.appendChild(host);
|
|
1511
1717
|
|
|
1512
1718
|
ui.root = root;
|
|
1719
|
+
// SKIN-SWAP FIX (2026-09-28) — keep DIRECT references to the sheet and its
|
|
1720
|
+
// shadow root. Everything else in this file locates elements by walking
|
|
1721
|
+
// the tree from ui.root, which CANNOT reach a shadow-level <style>: the
|
|
1722
|
+
// sheet is ui.root's SIBLING (both are children of the shadow root), and
|
|
1723
|
+
// querySelector only searches a subtree. Holding the nodes removes the
|
|
1724
|
+
// guesswork entirely — no getRootNode() semantics, no selector matching,
|
|
1725
|
+
// and it stays correct if the structure is ever re-parented.
|
|
1726
|
+
ui.styleEl = style;
|
|
1727
|
+
ui.shadow = shadow;
|
|
1513
1728
|
ui.ball = root.querySelector(".tfb-ball");
|
|
1514
1729
|
ui.panel = root.querySelector(".tfb-panel");
|
|
1515
1730
|
ui.list = root.querySelector(".tfb-list");
|
|
@@ -1520,6 +1735,22 @@ window.__ModuleLoader__.load({
|
|
|
1520
1735
|
ui.capCur = root.querySelector('[data-cap="cur"]');
|
|
1521
1736
|
ui.themeMenu = root.querySelector(".tfb-theme-menu");
|
|
1522
1737
|
|
|
1738
|
+
// LAYOUT PERSISTENCE FIX (2026-09-28): re-apply the side-by-side layout
|
|
1739
|
+
// whenever the panel DOM is (re)built — exactly like the position
|
|
1740
|
+
// restore just below does for POS_KEY.
|
|
1741
|
+
//
|
|
1742
|
+
// Before this, `tfb-hz` was applied in ONE place only: the apply()
|
|
1743
|
+
// bootstrap (`if (ui.panel && layoutHz) ...`). But collapsing the panel
|
|
1744
|
+
// runs refreshPlugin() -> buildUI(), which throws the old DOM away and
|
|
1745
|
+
// builds a fresh panel WITHOUT that class. So the stored setting still
|
|
1746
|
+
// said "side-by-side" (localStorage = 1) while the rebuilt panel had no
|
|
1747
|
+
// tfb-hz: the layout silently reverted to stacked after any collapse,
|
|
1748
|
+
// and only a manual re-click brought it back. Restoring it here makes the
|
|
1749
|
+
// persisted value authoritative for every panel instance, so collapse /
|
|
1750
|
+
// expand / theme refresh can no longer drop it — only the layout button
|
|
1751
|
+
// changes it.
|
|
1752
|
+
try { if (layoutHz) ui.panel.classList.add("tfb-hz"); } catch (e0) {}
|
|
1753
|
+
|
|
1523
1754
|
// restore position (clamped inside viewport)
|
|
1524
1755
|
var bw = ui.ball.offsetWidth || 56, bh = ui.ball.offsetHeight || 56;
|
|
1525
1756
|
try {
|
|
@@ -1711,8 +1942,7 @@ window.__ModuleLoader__.load({
|
|
|
1711
1942
|
SK.setSkin(sid);
|
|
1712
1943
|
}
|
|
1713
1944
|
try {
|
|
1714
|
-
|
|
1715
|
-
if (stEl) stEl.textContent = cssText();
|
|
1945
|
+
refreshStyleSheet();
|
|
1716
1946
|
} catch (err) {}
|
|
1717
1947
|
render();
|
|
1718
1948
|
renderThemeMenu();
|
|
@@ -1753,7 +1983,12 @@ window.__ModuleLoader__.load({
|
|
|
1753
1983
|
window.addEventListener("resize", function () { if (expanded) positionPanel(); });
|
|
1754
1984
|
document.addEventListener("keydown", function (e) { if (e.key === "Escape" && expanded) hide(); });
|
|
1755
1985
|
|
|
1756
|
-
|
|
1986
|
+
// FLICKER FIX part 2: force — these are BRAND-NEW elements, so the paint
|
|
1987
|
+
// guard's cached signature (from the previous DOM) must never suppress
|
|
1988
|
+
// their first decoration. Without this the rebuilt ball could come up
|
|
1989
|
+
// undecorated: no progress colour class, no value text, animations never
|
|
1990
|
+
// armed.
|
|
1991
|
+
render(true);
|
|
1757
1992
|
}
|
|
1758
1993
|
|
|
1759
1994
|
// ---------- entry ----------
|
|
@@ -1841,6 +2076,44 @@ window.__ModuleLoader__.load({
|
|
|
1841
2076
|
} catch (e2) {}
|
|
1842
2077
|
}, 2000);
|
|
1843
2078
|
}
|
|
2079
|
+
// SKIN-SWAP FIX (2026-09-28) — the single writer for the live stylesheet.
|
|
2080
|
+
//
|
|
2081
|
+
// buildUI() builds the shadow tree as:
|
|
2082
|
+
// shadow.appendChild(style); // <- the sheet lives HERE
|
|
2083
|
+
// shadow.appendChild(root); // root === ui.root (".tfb-root")
|
|
2084
|
+
// so <style> is ui.root's SIBLING, not a descendant. The previous code used
|
|
2085
|
+
// `ui.root.querySelector("style")`, which searches the SUBTREE only, so it
|
|
2086
|
+
// returned null on every call and the assignment never happened.
|
|
2087
|
+
//
|
|
2088
|
+
// That no-op was invisible for a long time because collapsing the panel ran
|
|
2089
|
+
// refreshPlugin() -> buildUI(), and the brand-new <style> was seeded from
|
|
2090
|
+
// cssText() at creation — so a skin change did eventually land, just only
|
|
2091
|
+
// after a collapse/rebuild. Removing that rebuild (needed so the
|
|
2092
|
+
// side-by-side layout stopped being dropped) removed the mask, and skin
|
|
2093
|
+
// switching looked broken.
|
|
2094
|
+
//
|
|
2095
|
+
// Resolution order, strongest first:
|
|
2096
|
+
// 1. ui.styleEl — the node captured in buildUI(). Exact, no traversal.
|
|
2097
|
+
// 2. ui.shadow — the shadow root captured in buildUI().
|
|
2098
|
+
// 3. getRootNode() walk — for any DOM we did not build ourselves.
|
|
2099
|
+
// 4. ui.root.querySelector — legacy subtree lookup, last resort only.
|
|
2100
|
+
function refreshStyleSheet() {
|
|
2101
|
+
try {
|
|
2102
|
+
var st = ui.styleEl || null;
|
|
2103
|
+
if (!st && ui.shadow && ui.shadow.querySelector) {
|
|
2104
|
+
try { st = ui.shadow.querySelector("style"); } catch (e0) {}
|
|
2105
|
+
}
|
|
2106
|
+
if (!st && ui.root) {
|
|
2107
|
+
try {
|
|
2108
|
+
var node = ui.root.getRootNode ? ui.root.getRootNode() : null;
|
|
2109
|
+
if (node && node.querySelector) st = node.querySelector("style");
|
|
2110
|
+
} catch (e1) {}
|
|
2111
|
+
}
|
|
2112
|
+
if (!st && ui.root) st = ui.root.querySelector("style");
|
|
2113
|
+
if (st) st.textContent = cssText();
|
|
2114
|
+
} catch (e) {}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
1844
2117
|
// Immediate theme application — exposed as window.__dshtfbApplyTheme so
|
|
1845
2118
|
// the sibling settings section can invoke it synchronously on click.
|
|
1846
2119
|
function applyThemeNow() {
|
|
@@ -1854,13 +2127,13 @@ window.__ModuleLoader__.load({
|
|
|
1854
2127
|
var v = getCfg(THEME_KEY, DEFAULTS.theme);
|
|
1855
2128
|
currentTheme = isTheme(v) ? v : DEFAULTS.theme;
|
|
1856
2129
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
render();
|
|
2130
|
+
// SKIN-SWAP FIX (2026-09-28): see refreshStyleSheet() for why the old
|
|
2131
|
+
// `ui.root.querySelector("style")` never matched.
|
|
2132
|
+
refreshStyleSheet();
|
|
2133
|
+
// FLICKER FIX part 2: force — a skin swap must re-decorate the ball even
|
|
2134
|
+
// when the visible numbers did not move, otherwise the new skin's
|
|
2135
|
+
// animations never re-arm and the switch looks like a no-op.
|
|
2136
|
+
render(true);
|
|
1864
2137
|
}
|
|
1865
2138
|
|
|
1866
2139
|
function apply(ctx) {
|
|
@@ -1915,8 +2188,16 @@ window.__ModuleLoader__.load({
|
|
|
1915
2188
|
}
|
|
1916
2189
|
applyBallVisibility();
|
|
1917
2190
|
watchBallVisibility();
|
|
1918
|
-
//
|
|
1919
|
-
|
|
2191
|
+
// Fallback channel: ALWAYS install (was: only when the sessions service
|
|
2192
|
+
// was missing). 0.1.7-rc.2 proved the primary channel can go silently
|
|
2193
|
+
// dead -- it dropped snapshot.current, so syncFromSessions() filed every
|
|
2194
|
+
// record under a phantom bucket and the ball rendered empty with the
|
|
2195
|
+
// official todo panel still perfectly fine. readOfficialPanel() already
|
|
2196
|
+
// guards itself (it never overrides real records; it only builds a
|
|
2197
|
+
// skeleton when the current session has none), so having it armed next
|
|
2198
|
+
// to the primary channel costs nothing and makes this class of kernel
|
|
2199
|
+
// drift self-healing instead of invisible.
|
|
2200
|
+
installPanelObserver();
|
|
1920
2201
|
// watchdog keeps the ball alive across shell rebuilds
|
|
1921
2202
|
var tries = 0;
|
|
1922
2203
|
var t = setInterval(function () {
|
|
@@ -1925,6 +2206,9 @@ window.__ModuleLoader__.load({
|
|
|
1925
2206
|
if (!document.getElementById(BALL_ID)) buildUI();
|
|
1926
2207
|
else renderBall();
|
|
1927
2208
|
if (hasSessionsSvc) syncFromSessions();
|
|
2209
|
+
// rc.2 safety net: if the sessions service is present but has never
|
|
2210
|
+
// produced a main session, keep the official panel as the source.
|
|
2211
|
+
if (hasSessionsSvc && !currentSid) { try { readOfficialPanel(); } catch (e1) {} }
|
|
1928
2212
|
} catch (e) {}
|
|
1929
2213
|
if (tries > 300) clearInterval(t);
|
|
1930
2214
|
}, 2000);
|
package/lib/index.js
CHANGED
|
@@ -46,7 +46,7 @@ var DISCIPLINE_SECTION_NAME = "todo-discipline";
|
|
|
46
46
|
var DISCIPLINE_SECTION_ORDER = 190;
|
|
47
47
|
|
|
48
48
|
// Injected text - Chinese, deliberately short (hard character budget: <=500,
|
|
49
|
-
// actual ~
|
|
49
|
+
// actual ~400). Only the 6 hardest rules; everything else belongs to the
|
|
50
50
|
// `todo-show-discipline` skill, which is loaded on demand.
|
|
51
51
|
var DISCIPLINE_TEXT = [
|
|
52
52
|
"【todo 进度表纪律 · 由 dsh-todo-float-ball 插件常驻注入,无需加载技能】",
|
|
@@ -54,7 +54,8 @@ var DISCIPLINE_TEXT = [
|
|
|
54
54
|
"2. 清单只增不减:已完成项保留并标 completed,绝不删除、折叠或合并;新任务到达但旧任务未完成时合并追加,禁止替换式清空重写。",
|
|
55
55
|
"3. 进行中项必须带实时进度数字(如「19号 120rpm 求解 278/1000」);每完成一步立即刷新状态。",
|
|
56
56
|
"4. 用户说「消失/少了/不见了/关了」= 本纪律被违反:立即补全完整清单,并说明当轮首动作漏写。",
|
|
57
|
-
"5. 全部任务实际完成时也要再写一次 todo_write(全标 completed),不得残留 in_progress/pending。"
|
|
57
|
+
"5. 全部任务实际完成时也要再写一次 todo_write(全标 completed),不得残留 in_progress/pending。",
|
|
58
|
+
"6. 🔴 正文待办必入清单(2026-09-17 用户强制):回复正文一旦出现「待办/待审批/还没弄的/未完成/后续要」事项,必须同轮将其同步追加进 todo 清单,禁止只写在正文不进清单;正文待办与 todo 清单必须一致(曾实测漏写:正文列 3 项待办未入清单)。"
|
|
58
59
|
].join("\n");
|
|
59
60
|
|
|
60
61
|
export var name = "dsh-todo-float-ball";
|
|
@@ -98,6 +99,59 @@ export function apply(ctx, config) {
|
|
|
98
99
|
ctx.logger.info("dsh-todo-float-ball: todo discipline prompt section disabled by config (injectDiscipline: false)");
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// v0.13.0: HARD GATE - first tool call of every turn must be todo_write.
|
|
104
|
+
//
|
|
105
|
+
// Why: the injected prompt section above is advisory text; in practice the
|
|
106
|
+
// agent (this very plugin's author included) sometimes "forgets" to write the
|
|
107
|
+
// todo list at the start of a turn, especially during long autonomous runs,
|
|
108
|
+
// and the float ball then shows a stale list. Text cannot enforce itself, so
|
|
109
|
+
// this is enforced at the tool dispatch layer instead: the first tool
|
|
110
|
+
// invocation of a turn that is NOT `todo_write` is DENIED with a reason the
|
|
111
|
+
// model reads back, so it corrects itself immediately.
|
|
112
|
+
//
|
|
113
|
+
// How it decides "first tool call of the turn": dsh-agent-loop appends the
|
|
114
|
+
// durable `tool/call` event BEFORE dispatching the call (appendToolCall runs
|
|
115
|
+
// before the dsh-tools scheduler reaches tools/pre-execute), so when the
|
|
116
|
+
// gate runs, exactly one `tool/call` exists in the current turn if this is
|
|
117
|
+
// the first one.
|
|
118
|
+
//
|
|
119
|
+
// Safety: every path is wrapped in try/catch and ANY unexpected shape falls
|
|
120
|
+
// through to next() (allow). A mis-detection therefore degrades to "gate does
|
|
121
|
+
// nothing", never to "blocks legitimate work".
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
var gateEnabled = !(config && config.enforceFirstTodoWrite === false);
|
|
124
|
+
if (gateEnabled) {
|
|
125
|
+
ctx.on("tools/pre-execute", async function (exec, next) {
|
|
126
|
+
try {
|
|
127
|
+
if (exec && exec.name === "todo_write") return next();
|
|
128
|
+
var session = exec && exec.agent && exec.agent.session;
|
|
129
|
+
if (!session || typeof session.snapshotEvents !== "function") return next();
|
|
130
|
+
var events = session.snapshotEvents();
|
|
131
|
+
if (!events || typeof events[Symbol.iterator] !== "function") return next();
|
|
132
|
+
var toolCallsThisTurn = 0;
|
|
133
|
+
for (var ev of events) {
|
|
134
|
+
var type = ev && ev.type;
|
|
135
|
+
if (type === "turn/start") toolCallsThisTurn = 0;
|
|
136
|
+
else if (type === "tool/call") toolCallsThisTurn++;
|
|
137
|
+
}
|
|
138
|
+
if (toolCallsThisTurn === 1) {
|
|
139
|
+
ctx.logger.info("dsh-todo-float-ball: GATE denied first-tool \"" + String(exec.name) + "\" (expected todo_write)");
|
|
140
|
+
return {
|
|
141
|
+
kind: "deny",
|
|
142
|
+
reason: "【todo 进度表纪律·硬约束】每个回复 turn 的第一个工具调用必须是 todo_write(覆盖式写回完整清单:已完成的保留并标 completed、只增不减、进行中项带进度数字)。本轮你还没有写 todo 清单。请先用 todo_write 写回完整清单,再执行其它工具调用。"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
try { ctx.logger.warn("dsh-todo-float-ball: todo gate error, allowing call: " + String(err)); } catch (_) {}
|
|
147
|
+
}
|
|
148
|
+
return next();
|
|
149
|
+
});
|
|
150
|
+
ctx.logger.info("dsh-todo-float-ball: hard gate registered (first tool call of a turn must be todo_write)");
|
|
151
|
+
} else {
|
|
152
|
+
ctx.logger.info("dsh-todo-float-ball: hard gate disabled by config (enforceFirstTodoWrite: false)");
|
|
153
|
+
}
|
|
154
|
+
|
|
101
155
|
ctx.effect(function () {
|
|
102
156
|
var h1 = ctx.webServer.register({ kind: "exact", path: SETTINGS_PREFIX + "/health", handler: function (req, res) {
|
|
103
157
|
if (!isLoopback(req)) { res.writeHead(403); res.end(); return; }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-todo-float-ball",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "DSH todo 悬浮球:常驻可拖动悬浮球实时显示当前会话 todo_write 任务清单进度(总数/完成数/进行中),Shadow DOM 样式隔离,点击折叠/展开完整清单,状态颜色(待办灰/进行中橙脉动/完成绿)。数据双路同步:MutationObserver 抓官方 todo 面板为主 + 拦截会话投影帧为辅。双端可用(Desktop 桌面端 + Web 网页端)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"README.zh.md",
|
|
21
21
|
"CHANGELOG.md",
|
|
22
22
|
"docs/*.md",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"docs/images/*",
|
|
24
|
+
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": {
|
|
Binary file
|
|
Binary file
|