Skip to content

fix(runtime): tell open windows when the CLI changes a project setup - #26564

Closed
sotashimozono wants to merge 1 commit into
stablyai:mainfrom
sotashimozono:sotashimozono/cli-project-setup-notify
Closed

sotashimozono wants to merge 1 commit into
stablyai:mainfrom
sotashimozono:sotashimozono/cli-project-setup-notify

Conversation

@sotashimozono

@sotashimozono sotashimozono commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

orca project setup-delete removes a project from Orca. The removal worked, but the Orca window that was open at the time was never told, so its sidebar kept showing a project that was already gone. This PR makes the CLI path send the same "the project list changed" notice that the window's own buttons already send.

What Changed

Before: after orca project setup-delete --setup <id>, orca project setups no longer lists the entry, but an open window keeps the project in the sidebar until it is restarted. setup-create and setup-update have the same gap, and paired clients are not told either.

After: the open window and paired clients refresh their project list as soon as the command returns. For a removal, the project header disappears.

Mechanism: these commands call the runtime RPC methods projectHostSetup.create, .update and .delete, which RuntimeProjectHostSetupController handles. The controller wrote to the store and returned. It now calls notifyReposChanged after each successful write, which is what the desktop handlers for the same three operations (projectHostSetups:* in project-host-setup-handlers.ts) already do.

Removing a setup that has a repo behind it now also drops three caches, the ones the repo.rm RPC drops after removing the same row: resolved worktrees, the worktree scan for that repo, and authorized roots. The controller's rollback path already ran exactly this sequence, so both now share one private method.

The production change is about 20 lines in one file. No RPC method, parameter or event is added.

Why

I found this while removing 48 projects of one host with a script. The CLI is the only scripted way to remove many projects today (#24542), and it is the one path that leaves an open window out of date.

Alternatives I considered:

  • Notify from the RPC method wrapper instead of the controller. The neighbouring controllers (repo.rm, project groups) notify inside the controller, and this controller's rollback path already did, so that is where it belongs.
  • Copy all of repo.rm's cleanup, including its terminal-topology reset. Left out on purpose. That counter is keyed by repo id, which two hosts can share, while deleteSetup removes one host's row. A leftover counter entry is a small leak, not a visible bug, so this change stops at what the existing rollback path does.
  • Also fix the leftover described below. That is renderer work with its own risk (closing tabs and terminals during a list refresh), and it exists today for repo.rm as well.

Known leftover, not changed here: once the window is told, it removes the project header but keeps that project's workspaces under an "Unknown" heading until restart. The same happens on main after repo.rm; I checked by swapping the call in the e2e test. The window does not drop the workspaces of a project that was removed outside it. The second screenshot shows this state.

Linked Issue

Fixes #26562

Visual Proof

From the new e2e test (tests/e2e/cli-project-setup-delete-sidebar.spec.ts). The app has one project, and the test removes its setup over the local runtime socket, the transport the CLI uses.

Before (main): 15 seconds after the removal, the sidebar still lists the project After: the project header is gone
before after

In the second screenshot the removed project's two workspaces remain under "Unknown". That is the leftover described under Why. The UI language in the screenshots is Japanese (my OS locale).

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • runtime-project-host-setup-controller.test.ts, 6 new cases:

    • Deleting a setup with a repo notifies once and drops the three caches for that repo id.
    • Deleting a setup with no repo behind it notifies once and drops no cache.
    • Deleting a setup that does not exist throws and notifies nothing.
    • Creating a setup notifies once; updating a setup notifies once.
    • The rollback path (a folder registered for a project it does not match) removes the repo and runs the same cleanup. This pins the small refactor.
    • Four of these fail on main.
  • tests/e2e/cli-project-setup-delete-sidebar.spec.ts (Playwright, ORCA_BACKGROUND_LAUNCH=1): opens the app with one project, calls projectHostSetup.delete over the local runtime socket, and expects the project header to leave the sidebar within 15 seconds. It fails on main with "the window still lists the removed project" and passes with this change.

  • Ran the src/main/runtime vitest folder under Node, because the pinned Bun is not installed on my machine: 1088 files pass. Six files (16 tests, all agent-session-* and agent-launch-*) fail, and they fail identically with this change stashed.

  • pnpm tc:node, pnpm run check:code-quality:changed and pnpm run check:max-lines-ratchet pass.

  • Not run locally: full pnpm lint / pnpm test / pnpm build; relying on CI.

  • Platforms: macOS only. Not tried with a paired client or with a setup on an SSH host.

AI Disclosure

Built with Claude Code (Claude Opus 5.5). It noticed the gap while scripting a project cleanup I had asked for, wrote the tests first and confirmed they fail without the change, wrote the fix, and ran a separate review pass that led to the rollback test.

Review

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

  • Security: no new access. A removal now also invalidates the authorized-roots cache, as repo.rm already does, so the removed folder stops counting as a registered root without waiting for another invalidation.
  • Cross-platform: main-process TypeScript with no platform-specific code.
  • SSH: deleteSetup already removes only the row of the setup's own host. The notice and the cache invalidation are not host-specific. Not exercised against a real SSH host.
  • Folder workspaces: a setup without a repo row takes the notify-only branch, which has its own unit test.
  • Mobile and paired clients: they receive the existing reposChanged event. Nothing new to decode.
  • Backwards compatibility: no wire change. The event type already exists and no parameter is added.
  • Performance: one extra notice per CLI call. A script that removes N setups causes N list refreshes in an open window, the same as N calls to repo.rm.

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)

`orca project setup-create`, `setup-update` and `setup-delete` change the
store through the runtime RPC, but an open window and paired clients were
never told, so a removed project stayed in the sidebar until restart. The
desktop IPC handlers for the same operations already send that notice.

The three RPC paths now send it too. Removing a setup that has a repo also
drops the caches `repo.rm` drops for the same row: resolved worktrees, the
worktree scan and authorized roots.

Fixes stablyai#26562
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71b15db1-4a79-4927-9812-e05249afa41f
📥 Commits

Reviewing files that changed from the base of the PR and between 1e76c87 and b4dbc93.

📒 Files selected for processing (3)
  • src/main/runtime/runtime-project-host-setup-controller.test.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • tests/e2e/cli-project-setup-delete-sidebar.spec.ts

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


📝 Walkthrough

Walkthrough

The runtime controller now notifies repo listeners after successful setup creation and update. When setup deletion removes a repo, the controller invalidates related caches and notifies listeners. Failed folder linking uses the same cleanup helper. Unit tests and an end-to-end test cover notifications, cleanup, and project-header removal from the open window.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b4dbc

The change is ready for normal merge checks; no actionable issue was identified.

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ 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 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The description links the change to issue #26562 with Fixes #26562, and the issue matches the stated objectives.
Out of Scope Changes check ✅ Passed The changes match the stated scope. The separate renderer issue that leaves workspaces under Unknown is documented as excluded, and the production changes do not add unrelated functionality.
Linked Issues check ✅ Passed Issue #26562 requires runtime project setup create, update, and delete operations to notify open windows and paired clients. The controller now calls notifyReposChanged() after each successful opera…
Out of Scope Changes check ✅ Passed The changes stay within issue #26562. Production changes add the required notifications, cache cleanup, and shared rollback cleanup. Unit and end-to-end tests verify these changes. No unrelated produc…
Title check ✅ Passed The title clearly identifies the main change: notifying open windows when the CLI changes a project setup. It is concise and specific.
Description check ✅ Passed The description follows the required template and explains the user impact, mechanism, rationale, linked issue, visual proof, tests, limitations, and checklist status. It clearly notes that full lint,…
  • Fix all pre-merge checks with AI
  • Autopilot · 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.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks for tracking this down, @sotashimozono! This is already fixed on main by #26941 (d56c0fb), which also closed #26562. RuntimeProjectHostSetupController now calls notifyReposChanged() after successful createSetup, updateSetup, and deleteSetup writes, so open windows and paired clients refresh their project list when orca project setup-* changes a setup. If a deleted project still stays in the sidebar on the latest build, please comment or reopen.

@nwparker nwparker closed this Oct 26, 2026
@sotashimozono

Copy link
Copy Markdown
Contributor Author

thank you for your response.

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.

[Bug]: Project setup changes made from the CLI do not reach the open window

2 participants