Skip to content

fix: 稳定运行中任务的优先级排序 - #3314

Open
dashhuang wants to merge 10 commits into
mainfrom
dash/fix-running-task-priority-order
Open

fix: 稳定运行中任务的优先级排序#3314
dashhuang wants to merge 10 commits into
mainfrom
dash/fix-running-task-priority-order

Conversation

@dashhuang

@dashhuang dashhuang commented Aug 24, 2026

Copy link
Copy Markdown
Member

这次改了什么

摘要

修复多个任务都在运行时,用户点击或切换任务会改变它们相对排序的问题。

  • 统一共享优先级规则:等待处理 > 纯完成未读 > 当前运行中 > 其他;同一任务同时存在上一轮完成未读和当前运行时,以当前运行状态为准。
  • Desktop 与 Mobile 在任务进入新一轮运行后释放旧的未读/等待查看 hold,避免切走时跨档重排;运行中重新进入等待处理时仍会正常升档。
  • Desktop 完成通知的 500ms 延迟到期时重新检查当前选中、运行、等待处理和终态错误;starting 只负责视觉运行态,不再吞掉上一轮完成提示,真正进入 running 仍会取消旧 timer。用户在窗口内点进任务会直接取消待落地 done,避免切走后补回过期未读。
  • 增加桌面、手机与共享排序回归测试,覆盖运行中互点、旧未读共存、查看过程中完成、等待处理升档和 debounce 竞态。
  • 删除 review 轮次里长出的 deferred completion、发送准备错误投影和 starting 清 scheduler marker 等跨 run 补偿机制,最终范围回到排序与 done attention 落点。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:运行中任务在点击切换时不应改变相对排序
  • 本 PR 包含:共享优先级尺子、Desktop/Mobile 查看态 hold、Desktop 完成通知 debounce 落点与回归测试
  • 明确不包含:任务列表视觉样式调整、稳定 ID 次级排序、整表冻结、hover 冻结、发送准备错误通知机制
  • 用户可见变化:多条运行中任务之间点击切换时,列表不再因为旧未读/查看态残留而跳位
  • 是否存在 breaking change:无

UI 变化

无新增组件、样式、布局或文案,也没有可供截图对比的静态视觉变化;交互变化仅为消除运行中任务切换时的无意义列表跳动。

  • 引用的设计规范:docs/design-rules/DESIGN.md §1 Visual Theme & Atmosphere(保持工作界面安静、克制,只让有意义的状态变化吸引注意);本次不新增视觉元素,仅让排序变化与真实任务状态一致。

怎么验证的

自动验证

Desktop/Mobile/maker-shared 聚焦 Vitest
结果:原始排序与 debounce 回归 58/58 通过;最新启动失败/终态错误收敛后 Desktop 聚焦 25/25 通过

pnpm --filter desktop run --if-present typecheck
pnpm --filter mobile run --if-present typecheck
pnpm --filter @cindy/maker-shared run --if-present typecheck
结果:全部通过(maker-shared 无 typecheck script,按规则跳过)

pnpm check:dco
结果:通过,10/10 commits 已签名

pnpm test:unit:related
bash /Users/dash/Code/XD/dash/Skills/git/scripts/run-unit-gate.sh /Users/dash/Code/Cindy/cindy-fix-running-task-priority-order
结果:除 apps/mobile/src/__tests__/startupSplashOverlay.test.ts 的 Expo introspect 约 6–7 秒、超过既有 5 秒上限外,其余 workspace 全部通过;Mobile 为 3852 passed、1 timeout。
      同一超时已在干净 main@dc4f23194 上等价复现;该 main SHA 的 GitHub 全量 client-ci 为通过,确认不是本 PR 引入,未混入本 PR 修复。

git diff --check
结果:通过

手工验证

不涉及:未启动 Desktop 或 Mobile 实机/模拟器进行交互验证。

未执行的验证

  • 本地完整 unit gate 未达到全绿:仅被已在干净 main 复现的 startupSplashOverlay.test.ts 5 秒时限阻塞;当前 PR 新一轮 GitHub CI 正在运行。
  • 未执行 Desktop 实机和 Mobile 模拟器验证;本次依靠状态模型单测覆盖排序与 debounce 竞态。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:任务列表状态排序和完成提示时序变化

影响与回滚

  • 影响范围:Desktop 侧栏、Mobile 首页以及共享活任务优先级;Desktop 完成未读提示的延迟判定。
  • 回滚 / 降级方式:回退本 PR,即恢复原先未读优先和查看态 hold 行为;无数据迁移或持久化格式变化。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档(本次无需新增文档,已补充代码注释与回归测试)
  • 已确认测试结果或说明未执行原因

@dashhuang
dashhuang requested a review from a team as a code owner August 24, 2026 00:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 846f69117c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/mobile/src/session/homeListPriority.ts
@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 统一了 Desktop、Mobile 与共享层的活任务优先级,并调整 Desktop 完成提示的延迟结算逻辑,以避免运行中任务因旧未读状态或查看态残留而重排。

  • 当前运行状态优先于上一轮完成未读,同时保留等待用户处理状态的最高优先级
  • Desktop 与 Mobile 会在新一轮运行后释放旧的查看态优先级 hold
  • Desktop 在完成 debounce 到期时重新检查当前选中、运行、错误和等待处理状态
  • 新增共享排序、桌面通知时序及移动端查看态的回归测试

Confidence Score: 5/5

当前 HEAD 未发现仍需在合并前修复的阻塞性故障,看来可以安全合并。

当前代码已阻断此前线程描述的过期完成角标、启动期间完成提示丢失以及错误被延迟 done 覆盖的路径,没有仍然成立的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts 完成 debounce 现在基于最新活动会话、运行状态、终止错误和等待处理状态结算,并在用户进入会话时取消过期 done。
apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts Desktop 查看态 hold 在任务进入新一轮运行时降至 running 档,避免旧未读状态重新抬升任务。
apps/mobile/src/session/homeListPriority.ts Mobile 使用相同的运行态优先规则,并支持详情页打开期间持续推进当前任务的查看态 hold。
apps/mobile/app/devices/index.tsx 首页在留存于导航栈期间响应任务状态变化并按需刷新优先级排序。
packages/maker-shared/src/liveTaskPriority.ts 共享优先级规则明确为 waiting、纯 unread、running、rest,运行状态覆盖同任务的旧完成未读。
apps/desktop/src/renderer/tests/useSessionRunningStatusSilence.test.ts 回归测试覆盖 debounce 内查看、重新运行、终止错误和 starting 交错场景。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[任务上一轮结束] --> B[启动 500ms done debounce]
  B --> C{期间进入会话?}
  C -- 是 --> D[取消 pending done]
  C -- 否 --> E{到期时仍运行或存在错误/等待处理?}
  E -- 是 --> F[不写入旧 done]
  E -- 否 --> G[写入 done attention 并按所有权触发通知]
  H[新一轮进入 running] --> I[释放旧 unread / waiting hold]
  I --> J[按 running 档参与排序]
Loading

Reviews (10): Last reviewed commit: "fix(desktop): preserve completion across..." | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按维护者指示批准;合并仍需通过 review-pr 的代码审查与其余安全门。

@MagicLizi MagicLizi added the touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) label Aug 24, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(mainListModel / useSessionRunningStatus / mobile devices)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面,便于确认界面符合 DESIGN.md 设计规范。本条不阻断合并。

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

必须修改

P1×1。debounce 到期只看「此刻是否仍选中」,丢掉了「完成当时已经在看」的门闩,会在 500ms 内切走时给刚看完的任务补橙点并抬进 unread。

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts
@MagicLizi MagicLizi added the status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) label Aug 24, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi
MagicLizi dismissed their stale review August 25, 2026 01:02

这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。

@MagicLizi MagicLizi added status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) and removed status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) labels Aug 25, 2026
@dashhuang
dashhuang force-pushed the dash/fix-running-task-priority-order branch from 3687a8b to d7de6bc Compare August 25, 2026 01:44
Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated
@dashhuang
dashhuang force-pushed the dash/fix-running-task-priority-order branch from d7de6bc to 1f09db7 Compare August 25, 2026 02:08
Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f09db76dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added the status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) label Aug 25, 2026
@dashhuang
dashhuang force-pushed the dash/fix-running-task-priority-order branch from 1f09db7 to f6fd4a5 Compare August 25, 2026 02:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6fd4a5e9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated
@dashhuang

dashhuang commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

收敛检查点(运行中任务排序)

  • 不变量:跨任务仍保持「等待处理 > 纯完成未读 > 当前运行中 > 其他」;同一任务当前轮 running 必须压过上一轮遗留 unread。用户选择、查看或切走任务,不得改变同档运行中任务的相对顺序。
  • 唯一 owner:liveTaskPriorityRank 统一 Desktop/Mobile 的自然档位;两端 viewed hold 只负责查看期间稳定位置,自然档进入 running 后把旧 unread/waiting hold 推进到 running;useSessionRunningStatus 只负责现有 done debounce 的最终落点。
  • debounce 判据:完成瞬间已在查看、到期时仍在查看、已 running、正在等待处理或已有 terminal error,均不补 done attention;用户在 500ms 窗口内点进任务会直接取消待落地 timer,随后切走也不会再补橙点。starting 只负责侧栏视觉运行态,不再吞掉上一轮完成提示;真正进入 running 时沿用既有 new-turn 路径取消 timer。系统通知 callback 保持原有独立 owner 口径,terminal error 不再误发旧 done。
  • 对称路径:覆盖多个纯 running 互点、unread → 查看 → 新一轮 running → 切走、running + 旧 schedule unread、running 中途变 waiting、完成瞬间 active 后切走、完成后 500ms 内点进再切走、到期前已 running / awaiting、下一轮停在 starting 后失败、debounce 期间出现 terminal error。
  • 技术收敛:已删除 review 轮次里长出的 deferred starting completion、发送准备错误投影、starting 边界清 scheduler marker 等跨 run 补偿机制;scheduler marker 生命周期回到 main 既有 owner,不再由本 PR 扩展。
  • 验证:原始聚焦回归 58/58;最新启动失败/终态错误收敛后 Desktop 聚焦 25/25;Desktop typecheck 通过;DCO 10/10。related 与统一 unit gate 仍只失败于 apps/mobile/src/__tests__/startupSplashOverlay.test.ts 的 Expo introspect 在本机约 6–7 秒、超过既有 5 秒上限;已在干净 main@dc4f23194 等价复现,同一 main SHA 的 GitHub 全量 CI 为通过,未把该基线时限问题混入本 PR。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbef0a4248

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated
@dashhuang
dashhuang force-pushed the dash/fix-running-task-priority-order branch from bbef0a4 to e931077 Compare August 25, 2026 03:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e931077653

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/lib/makerChatStore.ts Outdated
Comment thread apps/desktop/src/renderer/lib/sessionStartingStore.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/makerChatStore.ts / apps/desktop/src/renderer/lib/sessionStartingStore.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added the status:ci-failed CI 失败(review-pr 自动维护,仅展示) label Aug 25, 2026
@MagicLizi MagicLizi removed the status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) label Aug 25, 2026
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang
dashhuang force-pushed the dash/fix-running-task-priority-order branch from e931077 to 4438d52 Compare August 25, 2026 05:56
Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated
Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4438d52cf8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts
@MagicLizi MagicLizi added status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) and removed status:ci-failed CI 失败(review-pr 自动维护,仅展示) labels Aug 25, 2026
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@MagicLizi MagicLizi removed the status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants