Skip to content

refactor(runtime): extract lifecycle ownership and journal worktree creation - #286

Closed
johannesjo wants to merge 10 commits into
mainfrom
refactor/runtime-separation
Closed

johannesjo wants to merge 10 commits into
mainfrom
refactor/runtime-separation

Conversation

@johannesjo

Copy link
Copy Markdown
Owner

Task worktrees can outlive an interrupted creation before the task is saved. Record a worktree intent before provisioning, clear it after a saved state claims the path, and log remaining orphans at startup without deleting user work.

This also advances the runtime separation plan: PTY, Git, plan/steps watchers and the coordinator send UI updates through a notification function; remote transport and MCP lifecycle state move out of register.ts; MCP server path resolution is shared. A wiring test pins handler and listener registration across the extraction. The plan records the completed work and clarifies that desktop and phone task creation request an immediate save, while a crash window remains until the save completes.

Validation:

  • npm run check, npm run lint:dead, and npm run lint:arch passed on the PR branch.
  • Full npm test passed: 3,751 unit tests and 1,077 client tests passed; 33 tests skipped.
  • Documentation formatting and git diff --check passed.
  • Native Electron, packaged builds, and opt-in real-PTY/Docker/real-agent smoke tests were not run during this review.

@johannesjo johannesjo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

🗂️ Already on main, close instead of merging – 0 code issues at 38ffce01

  • All 10 commits are already on main. git cherry origin/main pr-286 marks every commit -, meaning a patch-equivalent commit is already upstream. They landed on Sep 25–26 under new SHAs: 403ec7b1, 5f4e0290, 2dfdd1c8, cc872335, 21a69aac, debb5293, 44c2485d, 357a69ab, 9d50e26a, 09989bc1. Main has also changed these files since: 462bd4c2 updated the plan, and #297/61ce6d01 touched register.ts, tasks.ts and pty.test.ts. Merging this branch now gives 8 conflicts (register.ts, mcp-runtime.ts, remote-transport.ts, register-wiring.test.ts, tasks.test.ts, pty.test.ts, register-mcp.test.ts, docs/runtime-separation-plan.md) and nothing to gain. Suggest closing the PR and deleting refactor/runtime-separation.
  • The content holds up. I traced it anyway, since it is now on main:
    • worktree-intents.ts: the intent is recorded before createWorktree. It is settled on every SaveAppState, matched by path.resolve against tasks[*].worktreePath. Collapsed tasks are stored in tasks too, so they count as claimed.
    • Startup reconcile runs before createWindow(), so the first task cannot race it. Intents whose directory is gone are dropped, so a failed createWorktree or a task deleted before its first save does not show up as an orphan. Nothing is deleted, and journal writes go through atomicWriteFileSync.
    • Arena and document-run worktrees go around createTask, so they are never journalled. That matches the doc comment.
    • remote-transport.ts: stopIfIdle, stopRemoteAccess and the rebind guard are a faithful move of the old register.ts closures. The flag ordering is unchanged, and wideBindInUse() replaces the inline wideBindAgents/delegation check.
    • The Semgrep filesystem-safety include was extended to mcp-runtime.ts as well.

Verification: compared patch-ids with git cherry, mapped commits by subject, ran git merge-tree against current main, and read the diff. I did not run npm ci, check or the tests locally: the code is already on main, and the PR's quality CI passed at this SHA.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Closing: all 10 commits already landed on main on Sep 25–26 under different commit IDs (git cherry shows every commit as already upstream). The branch now only conflicts with later changes.


Generated by Claude Code

@johannesjo johannesjo closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant