fix(tui): 跨 run 陈旧 todo 清单不再复活显示——「◇ 任务 (5/5) 不更新」的根因与修复 - #43
Open
yq04 wants to merge 1 commit into
Open
Conversation
问题定位(同步链路本身健全:todo/plan_task 工具结果即时刷新 + 120ms ticker 兜底 + 每帧直读 state.todos,「输出太快丢同步」不成立): 上一轮全部完成的清单在新 run 期间(phase≠idle)原样复活—— shouldShowTaskPanel 的隐藏条件只看 phase==='idle',新 run 一开始 phase 抬离 idle,旧 5/5 重新挂载,直到 AI 首次 todo write 才变化。 用户看到新任务已开工、计数停在上一轮终态,观感即「不更新」。 修复(todosWrittenThisRun 生命周期标志): - 用户提交的四处 run 启动点重置(handleInputSubmit / notifyRunSettled 补发 / submitText / slash 透传);守护中断自动续跑不重置(同一任务 的延续,旧清单继续显示是正确语义) - updateTodos 以清单签名(id:status:content)区分「真写入」与 ticker 同值轮询拉取,签名变化才置位 - 全完成清单 + 本 run 未写 → 任务面板(主区+侧栏)与 GlanceBar 徽章 均不显示;部分完成清单不受影响(AI 大概率续写);todoExpanded 强制 回看不变;本 run 内推进到全完成仍显示(完成态是本 run 有效信息) 新增 todo-stale.test.ts 5 条契约(含防空洞断言与对照帧), 干净基线 1 RED / 修复后 5 GREEN;todo-panel 既有 4 条契约无回归。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
「◇ 任务 (5/5) 有时候不会更新」。
根因分析(先排除同步问题)
同步链路本身健全,逐项核验:
handleToolResult即时refreshTodos+flushNowrefreshTodos(agent 活跃期间)isFinal前兜底refreshTodos,收尾 commit 触发渲染state.todos,无缓存「输出太快导致丢同步」不成立(事件驱动 + 轮询双保险,渲染合并不丢终态)。
真正的机制是跨 run 陈旧显示:
shouldShowTaskPanel的隐藏条件只看phase === 'idle'——上一轮全部完成的清单在 run 结束后被隐藏,但新 run 一开始 phase 抬离 idle,旧清单(如 5/5)重新挂载,直到 AI 首次写入新 todo 才变化。用户看到新任务已开工、计数却停在上一轮终态,观感即「不更新」。方案
todosWrittenThisRun生命周期标志:handleInputSubmit/notifyRunSettled补发 /submitText/ slash 透传)。守护中断(watchdog/convergence)的自动续跑不重置——续跑是同一任务的延续,旧清单继续显示是正确语义updateTodos以清单签名(id:status:content拼接)区分「AI 真写入」与 ticker 同值轮询拉取,签名变化才置位todoExpanded(ctrl+x t)强制回看不变测试
新增
todo-stale.test.ts5 条契约(含防空洞断言与对照帧设计,规避 LiveEngine「无变化短路」的空帧假绿):验证:干净基线 1 RED / 修复后 5 GREEN;引擎域 521 测试 519 通过(1 失败为预存在的
approval-key.test.tsWindows 路径问题,上游基线同样失败);既有todo-panel.test.ts4 条契约无回归;改动域 typecheck 零错误。