Skip to content

fix(sidebar): resolve the card menu's project on the clicked workspace's host - #30882

Closed
jbamlee wants to merge 1 commit into
stablyai:mainfrom
jbamlee:fix-card-menu-project-host
Closed

jbamlee wants to merge 1 commit into
stablyai:mainfrom
jbamlee:fix-card-menu-project-host

Conversation

@jbamlee

@jbamlee jbamlee commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

The same project can be added on two connected computers, and both copies can have the same id. A workspace card's right-click menu found its project by that id alone. So when you right-clicked a workspace from the other computer, the menu could show and change the project on the computer you were working on. Now it uses the project on the clicked workspace's own computer.

What Changed

Before: a Mac is paired with another Orca host, and both have the same project (same repo id). The paired host's row is in one of its groups; the Mac's row is not. With a Mac workspace active, the right-click menu of a paired-host workspace card:

After: the card menu reads the clicked workspace's own row. Remove from group shows, the current group is marked, and Move to group moves the paired host's row. A workspace from older local metadata with no host stamp uses this Mac's row.

Mechanism:

  • New use-worktree-menu-repo.ts (useWorktreeMenuRepo): looks the row up with findIndexedRepoOwnerForHost on the workspace's host. That is the runtime owner when there is one, otherwise getWorktreeExecutionHostId(worktree, undefined) (the host stamp, or local). This is the same rule WorktreeMetaDialogDraft uses.
  • use-worktree-context-menu-model.tsx uses it instead of useRepoById, which resolves on the active workspace's host. Everything in the menu that reads the project uses the new row: group state, moves, and the Remove Project and Delete Worktree choices.

Why

Root cause: repo ids repeat across hosts. useRepoById (selectRepoByIdForActiveWorkspace) picks the row on the active workspace's host, and a card menu can be opened on any workspace, not only the active one.

Alternatives considered:

Linked Issue

Fixes #30881

Split from #29863 at the maintainer's request.

Visual Proof

N/A: this changes which project row an existing menu reads. Nothing is drawn differently. The menu tests below use the real Radix context menu and check the rendered items and the store call.

Testing

  • I manually tested these changes locally

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

  • New WorktreeContextMenu.move-to-group-host.test.tsx (real Radix menu, two rows with the same repo id):

    • a paired-host card moves the paired host's row;
    • an unstamped local card keeps this Mac's row while the id-keyed selector would return the paired twin;
    • a paired-host card shows Remove from group from its own row.
    • All three fail with main's useRepoById lookup.
  • WorktreeContextMenu.delete-shortcut.test.tsx: the fixture's state.repos now holds the rows its cards name, since the menu reads the store's rows.

  • pnpm test src/renderer/src/components/sidebar src/renderer/src/store/slices (7031 passed), pnpm tc, pnpm lint (full), pnpm run check:code-quality:changed.

  • pnpm build: typecheck, the desktop bundles and the web client projection pass. Its mobile web bundle step needs a mobile/ install that this worktree does not have, so CI covers that step. This PR touches no mobile code.

  • Platforms: macOS (unit tests). The change is renderer-only with no platform branches.

AI Disclosure

Implemented with Claude Code (Claude Opus 5.5). It carries over the card-menu part of #29863. That part was reviewed there by GPT-6 Astra (xhigh reasoning) through Codex CLI and by CodeRabbit; CodeRabbit's unstamped-workspace finding is covered by the second 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

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • No IPC, RPC or persisted-state change, so mixed-version peers are unaffected.
  • SSH: a direct-SSH workspace is stamped ssh:<target> and resolves to that row; a managed or paired server's workspace resolves through its runtime owner.
  • Folder workspace cards carry folder-workspace:<groupId> as their repo id, which no repo row has, so they find no row before or after.
  • Cost: one indexed repo lookup per card menu.

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)

🤖 Generated with Claude Code

@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: 5c8a1c77-88eb-45ca-9cbe-f0c197bf47fa
📥 Commits

Reviewing files that changed from the base of the PR and between 2f9d26807ca30beb66adf56c6b7aefd9b501720f and 98c0724.

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

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: ff8541c1-4212-403a-8a45-4f0410570c25
📥 Commits

Reviewing files that changed from the base of the PR and between b03ac56 and 32193048edb56960b2777668e92820a1ccc37d39.

📒 Files selected for processing: 4
  • src/renderer/src/components/sidebar/WorktreeContextMenu.delete-shortcut.test.tsx
  • src/renderer/src/components/sidebar/WorktreeContextMenu.move-to-group-host.test.tsx
  • src/renderer/src/components/sidebar/use-worktree-context-menu-model.tsx
  • src/renderer/src/components/sidebar/use-worktree-menu-repo.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

The context-menu model now gets its repository row through useWorktreeMenuRepo, which resolves the row using the worktree’s host. Added tests cover host-specific group actions, unstamped worktrees, and grouped repository rows.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 32193

The menu lookup now distinguishes duplicate repository IDs by the clicked workspace’s host, while unstamped workspaces resolve to the local row. No concrete merge-blocking risk is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 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 and concisely describes the main change: resolving the card menu's project on the clicked workspace's host.
Linked Issues check Passed The changes meet the coding requirements in [#30881]. useWorktreeMenuRepo resolves the clicked worktree's repoId on its runtime-owner host, or on the host stamp/local host when no runtime owner ex…
Out of Scope Changes check Passed The changes stay within [#30881]. The new lookup hook, the menu integration, and the related fixture and menu tests directly support host-correct project-row selection. No unrelated product behavior o…
Description check Passed The pull request description is complete and follows the repository template. It explains the user impact, implementation, root cause, alternatives, linked issue, testing, platform considerations, AI …
Full details: Linked Issues check

Explanation

The changes meet the coding requirements in [#30881]. useWorktreeMenuRepo resolves the clicked worktree's repoId on its runtime-owner host, or on the host stamp/local host when no runtime owner exists. useWorktreeContextMenuModel uses this row for menu project actions, including group state, group moves, and removal decisions. The added Radix menu tests cover paired-host rows, unstamped local rows, and Remove from group.

Full details: Out of Scope Changes check

Explanation

The changes stay within [#30881]. The new lookup hook, the menu integration, and the related fixture and menu tests directly support host-correct project-row selection. No unrelated product behavior or unrelated files appear in the reviewed changes.

Full details: Description check

Explanation

The pull request description is complete and follows the repository template. It explains the user impact, implementation, root cause, alternatives, linked issue, testing, platform considerations, AI use, and checklist status. It also provides a valid N/A explanation for visual proof because the change does not alter rendered UI.

  • 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.

…e's host

Repo ids repeat across hosts, and useRepoById resolves on the active
workspace's host, so a card menu opened on another host's workspace showed
and moved the wrong host's project. The menu now looks its row up on the
workspace's own host (runtime owner, else host stamp, else local).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jbamlee
jbamlee force-pushed the fix-card-menu-project-host branch from 2f9d268 to 98c0724 Compare October 20, 2026 13:12
@jbamlee jbamlee closed this Oct 23, 2026
@jbamlee
jbamlee deleted the fix-card-menu-project-host branch October 23, 2026 03:07
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]: A workspace card's menu can act on another host's project when two hosts share its repo id

1 participant