Skip to content

fix(desktop): stabilize Runtime Host Session lifecycle races - #2548

Merged
M4n5ter merged 2 commits into
mainfrom
fix/desktop-runtime-host-lifecycle-races
Aug 9, 2026
Merged

M4n5ter merged 2 commits into
mainfrom
fix/desktop-runtime-host-lifecycle-races

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 9, 2026

Copy link
Copy Markdown
Member
English

Summary

Stabilize two Desktop lifecycle paths that could race with Runtime Host Session revision changes:

  • stop an active side-conversation Turn before retiring its durable Session copy, instead of relying on later catalog reads to recover cleanup;
  • allow Session updates and removals a larger but still bounded CAS resynchronization window, rebuilding each request from a fresh Host projection.

The side-chat E2E now dismisses a Turn that deliberately remains active, so it verifies the production stop-before-retire contract. The Session client regression crosses four consecutive revision conflicts before committing, which reproduces the window that exceeded the previous three-attempt bound.

Fixes #2543
Fixes #2545

Verification

  • npx biome check on all changed files
  • npm run typecheck --workspace @maka/desktop --if-present
  • npm run build:test
  • focused Desktop unit tests: 50 passed
  • complete Desktop unit suite: 1,131 passed
  • affected Desktop E2E tests: 20/20 repeated runs passed, then 2/2 passed after rebasing onto current main

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
中文

摘要

修复两条会与 Runtime Host Session revision 变化发生竞态的 Desktop 生命周期路径:

  • 关闭侧边对话时,先停止仍在运行的 Turn,再退休其持久化 Session 副本,不再依赖后续 catalog 读取碰巧驱动清理;
  • 为 Session 更新与删除提供更大的、但仍有界的 CAS 重同步窗口,并在每次重试时从 Host 的最新投影重建请求。

侧边对话 E2E 现在会关闭一个刻意保持运行的 Turn,因此能验证生产路径的“先停止、后退休”契约。Session client 回归测试则会连续经历四次 revision conflict 后再提交,覆盖原三次尝试上限不足的窗口。

修复 #2543
修复 #2545

验证

  • 对全部改动文件运行 npx biome check
  • npm run typecheck --workspace @maka/desktop --if-present
  • npm run build:test
  • Desktop 定点单测:50 项通过
  • Desktop 完整单测:1,131 项通过
  • 相关 Desktop E2E:重复运行 20/20 通过;rebase 到最新 main 后再次运行 2/2 通过

检查清单

  • 测试覆盖改动,并会在缺少修复时失败
  • lint、format、typecheck 与相关测试套件均已在本地通过

此 PR 是否包含行为变化?

  • 是——已在摘要中说明

@M4n5ter
M4n5ter marked this pull request as ready for review August 9, 2026 03:24
@M4n5ter
M4n5ter merged commit 26fb404 into main Aug 9, 2026
12 checks passed
@M4n5ter
M4n5ter deleted the fix/desktop-runtime-host-lifecycle-races branch August 9, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant