Skip to content

fix(projects): removing a project on this computer stops its chats, pages and every terminal on the host - #30728

Merged
nwparker merged 3 commits into
mainfrom
nwparker/r4-5b-desktop-project-removal
Oct 19, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/r4-5b-desktop-project-removal

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

ELI5

When you removed a project from this computer (a local folder, or an SSH project the desktop connects to itself), Orca only closed the terminals this window happened to know about. AI chats, browser pages opened by agents, and terminals from another window or a restart kept running with no project left to show them. Now the removal asks the part of Orca that actually runs those sessions to stop all of them, the same way removing a project from a paired server already did.

What Changed

Before. The desktop's repos:removeForHost only dropped the store row. The renderer's removeProject then sent pty.kill for the PTYs in its own tab list. Native chats, host browser pages and failed-launch records were never released. PTYs the window didn't list kept running.

After.

  • When this process owns the exact (repoId, hostId) row and the host is not a paired runtime: server, repos:removeForHost calls runtime.removeProject(row). This is the same RuntimeRepositorySettingsController.remove that repo.rm uses.
  • The 10 s budget no longer means "some terminals are never asked to stop". Before, once one slow stop spent the budget, the sweep skipped every remaining PTY. Now project removal passes requestStopsPastDeadline, so each remaining PTY still gets a non-waiting stop. It is never counted as stopped. This also fixes repo.rm on headless servers. Worktree removal keeps its old behaviour.
  • Paired-server residue rows (runtime: stamps) no longer count as same-fence twins. A local project whose id matches a residue row used to have its whole host-side sweep skipped.
  • The renderer's kill loop stays as a backstop, since a reloading graph can still abort the host sweep.

Why

The host owns execution (AGENTS.md), so the sweep belongs where the session tables are, not in a window's partial view. Reusing the repo.rm controller keeps one removal path for local and paired clients.

Alternatives considered:

  • Calling the runtime with a selector string. That is ambiguous for twins.
  • Deleting the renderer loop outright. Codex and Opus both showed a spent budget or a graph reload would then leave shells running. Asking past the deadline fixes the budget case for every client.

ref-oss check: not needed (2 review rounds).

Linked Issue

Round 4 hardening R4-5, the renderer/desktop half (internal tracker); no GitHub issue.

Visual Proof

N/A: no UI change. Removing a project now takes as long as repo.rm already did on a paired server: up to the 10 s terminal budget plus the chat close.

Testing

All of these fail before the fix:

  • src/main/ipc/repos/repo-remove-for-host-teardown.test.ts:
    • this computer's SSH row is removed through runtime.removeProject(row);
    • a runtime: residue row is only dropped.
  • src/main/runtime/project-removal-structured-sessions.test.ts:
    • a local project's chats close even though a runtime: residue row shares its id;
    • with the budget already spent, both of a project's PTYs still get kill.

Local runs:

  • unit tests in src/main/runtime/terminal/stop, worktree-teardown, owned-session-teardown-policy, src/main/ipc/repos and the renderer repo-removal and twin tests: 27 files, 224 tests;
  • tc:node and tc:web;
  • static job.

Not verified live; the Docker lane is advisory.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

  • Codex (gpt-6.1-sol, high), round 1, P2: the deleted renderer loop left PTYs unasked once the budget was spent. Fixed by asking past the deadline and restoring the loop as a backstop.
  • Opus, round 1, no P1:
    • P2, residue rows read as twins: fixed.
    • P2, unasked PTYs: fixed as above.
    • P3s noted:
      • removal now waits for the host sweep, about 13 s worst case per offline project, which is what repo.rm already does;
      • a WSL-move fence landing mid-removal now refuses after the stop, also as repo.rm does.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: an SSH project the desktop owns is now swept on its connection fence. A local twin keeps its sessions.
  • Wire: no change. repo.rm params are unchanged, and older clients get the past-deadline stops for free.
  • Folder workspaces take the same path as git projects.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9af84602-1525-4798-a513-abcb5b8da723
📥 Commits

Reviewing files that changed from the base of the PR and between 27ac689 and 90e15e0.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Repo removal now routes matching non-runtime-host rows through the runtime and synchronizes the worktree watcher. Runtime-host rows and missing rows retain the store removal path. Terminal teardown excludes runtime-host rows from local session checks and can request stops for remaining PTYs after the deadline without waiting. The runtime repository settings controller accepts either a selector or a resolved Repo.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 27ac6

A terminal can start after its local project has been removed. Fix spawn admission before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly states the primary user-facing change: project removal now stops chats, pages, and terminals on the host.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility considerations, and checklist. It states that no GitHub issue exists, but this i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility considerations, and checklist. It states that no GitHub issue exists, but this is acceptable if the contributor is an internal maintainer under the template's special case.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b02f2b3-ea21-441e-861c-f2f8f3c35c41
📥 Commits

Reviewing files that changed from the base of the PR and between 2b60778 and 27ac689.

📒 Files selected for processing: 11
  • src/main/ipc/repos.ts
  • src/main/ipc/repos/project-host-setup-wsl-move-fence.test.ts
  • src/main/ipc/repos/repo-catalog-handlers.ts
  • src/main/ipc/repos/repo-ipc-wsl-move-fence.test.ts
  • src/main/ipc/repos/repo-remove-for-host-teardown.test.ts
  • src/main/runtime/project-removal-structured-sessions.test.ts
  • src/main/runtime/runtime-repository-settings-controller.ts
  • src/main/runtime/terminal/stop/project-terminal-stop.ts
  • src/main/runtime/terminal/stop/worktree-terminal-stop-options.ts
  • src/main/runtime/terminal/stop/worktree-terminal-stop.ts
  • src/renderer/src/store/repos/repo-removal.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

/** A paired server's row is residue here: its sessions run on that server, never in this process. */
private rowsRunHere(): Repo[] {
return (this.store?.getRepos?.() ?? []).filter(
(row) => parseExecutionHostId(getRepoExecutionHostId(row))?.kind !== 'runtime'

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Exclude residue rows from post-removal spawn admission.

If a local row and a runtime: residue row share an ID, removal records the local null connection fence but leaves the residue row. removedProjectAdmitsSpawn at Lines 237–241 still treats that residue as a surviving local owner. A local spawn waiting behind the removal can then pass acquireWorktreeTerminalSpawn and create a PTY after the project is removed. Apply the rowsRunHere() filter to spawn admission as well.

@nwparker
nwparker merged commit 3d91e9a into main Oct 19, 2026
58 checks passed
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