fix(schedule): 修复任务变更后 Dashboard 状态不同步 - #1352
Open
Rememorio wants to merge 5 commits into
Open
Conversation
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.
飞书或 CLI 删除、暂停定时任务后,daemon 已使用新状态,Dashboard 却可能继续显示旧任务或旧状态;手动触发后的执行时间也会滞留。文件监听器使用业务缓存作为比较基准,而本进程写入或抢先发生的读取已经刷新了该缓存,导致变更事件被跳过。
生产代码仅调整任务存储的通知逻辑:使用独立、不可变的公开任务快照比较已提交状态,统一覆盖本进程写入与外部文件变更。移除的可选字段通过显式 null 清除,避免 JSON/SSE 丢弃 undefined 后残留旧错误信息。重复文件通知不重复发布差异,同步复合操作及回滚只发布最终状态,前置条件引用不进入事件。已被 Dashboard 创建入口提前发布的任务按更新合并,保留机器人名称等展示信息。
影响范围:所有 CLI、会话后端及 IM 共用的定时任务状态展示;不改变任务执行位置、排期、权限或存储格式。现有启动及重连快照同步保留。
同时修复两个现有测试的时序竞争:标题超时测试先通过协议往返确认已进入生成阶段,再推进测试时钟,严格验证中断、取消订阅及进程回收;环境隔离测试仍使用真实 PTY 启动子进程,但从临时文件读取检查结果,避免终端数据与退出事件竞争。改动仅涉及测试,不改变运行时行为。
验证:
bun run build通过;git diff --check通过。回归覆盖删除、创建、启停、执行状态、自动删除、跨机器人隔离、回滚、重复文件事件和清空可选字段。实验使用隔离的临时任务数据,未部署到运行中的服务。
测试稳定性验证:
bun test test/codex-app-threads.test.ts test/child-env.test.ts test/tmux-startup-storm-recovery.test.ts:Bun 1.4.2 下 65 项通过。node node_modules/vitest/vitest.mjs run --project unit test/codex-app-threads.test.ts test/child-env.test.ts test/tmux-startup-storm-recovery.test.ts:65 项通过。