Skip to content

fix(sidebar): offer only the project host's groups in Move to group - #29863

Closed
jbamlee wants to merge 4 commits into
stablyai:mainfrom
jbamlee:fix-cross-host-move-to-group
Closed

jbamlee wants to merge 4 commits into
stablyai:mainfrom
jbamlee:fix-cross-host-move-to-group

Conversation

@jbamlee

@jbamlee jbamlee commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Each project group is saved on one computer, and a project can only join a group saved on the same computer. The Move to group menu lists every group from every connected computer. Since #30127, picking a group from another computer shows an error instead of failing silently, but the menu still offers it. Now the menu only lists groups the project can actually join.

What Changed

Before (current main): on a Mac paired with a Linux host, the Move to group submenu of a Linux project also lists the Mac's groups. Picking one shows "Could not move project to group" (#30127). On a workspace card's right-click menu, when two hosts have a project with the same repo id, the menu can act on the active workspace's host instead of the clicked workspace's host.

After: both submenus list only groups stored on the project's own host. When that host has no groups, the submenu is hidden. New group from project already creates the group on the project's host, so that remains the way to start a group there. The card menu uses the clicked workspace's own project row.

Mechanism:

  • project-group-owner-routing.ts: new getProjectGroupsForRepoHost(projectGroups, repo). It keeps a group only when the group and the project resolve to the same catalog (ipcOrRuntimeTargetForHostId): this app's IPC for local and direct ssh: projects, the paired server for runtime: projects. isProjectGroupJoinableFromCatalog (fix(project-groups): say so when a project cannot join a group on another host #30127) now shares the same catalogHostIdFor lookup, so the menu and the store's guard cannot disagree.
  • repo-header-project-actions.tsx (project header … menu) builds its submenu from that list.
  • New use-worktree-menu-project-groups.ts: the card menu's project row is looked up on the clicked workspace's host (findIndexedRepoOwnerForHost), not through the active-workspace selector, and its groups come from the same filter. A workspace row from older local metadata has no host stamp; like the worktree owner index, no runtime owner and no host stamp means local. use-worktree-context-menu-model.tsx uses it.

Why

Root cause: group membership is projectGroupId on the project's own row, and each group is stored on exactly one host. The project's host clears a group id it does not hold. #30127 now refuses such a move in the store with a toast, but both menus still build their list from every host's groups, so the user is offered choices that always fail.

Alternatives considered:

Linked Issue

Fixes #29862 (same bug as #13699)

Visual Proof

The Orca app ran in the background with a project on this Mac, one of this Mac's groups, and a group stamped as owned by a paired host. Text below is what the real app rendered.

# old base be033c2ab2 (before #30127)
[evidence] Move to group submenu: ["E2E Local Group","E2E Paired Host Group"]
[evidence] after choosing the paired-host group: projectGroupId=null toasts=[]

# this branch, rebased onto main 9f37fcdf70 (code since then: one lookup fix, covered by unit tests)
[evidence] Move to group submenu: ["E2E Local Group"]

On current main without this PR, the paired-host group is still listed; choosing it shows the #30127 error toast.

Testing

  • I manually tested these changes locally

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

  • New repo-header-project-actions.test.tsx: paired-host projects see only their host's groups; local and direct-SSH projects see this app's groups (including a folder-backed SSH-root group); the submenu is hidden when the host has none.

  • New WorktreeContextMenu.move-to-group-host.test.tsx (real Radix menu): the same filter on the card menu, plus two hosts sharing a repo id; the move is sent with the clicked workspace's host. An unstamped local workspace keeps this Mac's groups while a paired twin is active (fails on the active-workspace lookup).

  • WorktreeContextMenu.delete-shortcut.test.tsx: the fixture's mocked useRepoById returned a project missing from state.repos, which the real store cannot do. It now reads from state.repos.

  • Rebased onto main 90e99c48f4: pnpm test src/renderer/src/components/sidebar src/renderer/src/store/slices src/renderer/src/lib (14420 passed), pnpm tc, oxlint, pnpm run check:code-quality:changed.

  • Platforms: macOS (unit tests and a background Electron E2E). The change is renderer-only with no platform branches.

AI Disclosure

Implemented with Claude Code (Claude Opus 5.5). Independent review by GPT-6 Astra (xhigh reasoning) through Codex CLI before the rebase; its one finding, the card menu's repo lookup, is fixed in this PR. CodeRabbit's unstamped-workspace finding on that lookup is fixed too.

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. Mobile has no Move to group.
  • Cost: one filter over the group list per menu render, plus one indexed repo lookup per card.

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 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Project group menus now show groups that match the repository’s catalog host. The worktree context menu resolves the repository using the worktree’s execution host. Both menus hide the move-to-group submenu when no matching groups are available. Tests cover host-specific group options and move actions.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to 142bd

For an unstamped worktree whose repository exists on multiple hosts, Move to group may offer the wrong host’s groups. Resolve ambiguous ownership before merging unless this behavior is explicitly accepted.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #29862 requires both Move to group menus to offer only groups held by the project's host. getProjectGroupsForRepoHost matches group and project catalog hosts through the existing runtime targe…
Out of Scope Changes check Passed The changed production files directly implement issue #29862. The added tests verify the two affected menus and host-specific routing. The delete-shortcut fixture correction makes its mocked repositor…
Title check Passed The title clearly and concisely describes the main change: limiting the Move to group menu to groups on the project host.
Description check Passed The description is complete and closely follows the repository template. It explains the user impact, mechanism, rationale, linked issue, testing, platform considerations, and scope. It provides textu…
Full details: Linked Issues check

Explanation

Issue #29862 requires both Move to group menus to offer only groups held by the project's host. getProjectGroupsForRepoHost matches group and project catalog hosts through the existing runtime target routing. The project-header menu uses the filtered list and hides the submenu when it is empty. The workspace-card menu uses the clicked worktree's host-specific repo before applying the same filter. The added tests cover paired hosts, local and direct SSH projects, no matching groups, and duplicate repo IDs.

Full details: Out of Scope Changes check

Explanation

The changed production files directly implement issue #29862. The added tests verify the two affected menus and host-specific routing. The delete-shortcut fixture correction makes its mocked repository lookup match store behavior and supports test validity. No unrelated production behavior or data-model change is shown.

Full details: Description check

Explanation

The description is complete and closely follows the repository template. It explains the user impact, mechanism, rationale, linked issue, testing, platform considerations, and scope. It provides textual visual evidence, although it does not include attached screenshots or videos, and the final command checklist remains unchecked.

  • Fix all pre-merge checks with AI
  • 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: 8f1a523a-103d-4df6-91bb-f98eb693c46a
📥 Commits

Reviewing files that changed from the base of the PR and between c31712f and 142bd2ecfa474a68f9a78ef3f8bf41e7df47d865.

📒 Files selected for processing: 6
  • 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/worktree-list/rows/repo-header-project-actions.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/rows/repo-header-project-actions.tsx
  • src/renderer/src/store/slices/project-group-owner-routing.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.

jbamlee and others added 4 commits October 19, 2026 22:05
Both Move to group submenus listed every project group in the all-host
catalog. Group membership lives on the project's own row, so the move goes
to the project's host, which replaces a group id it does not store with
null. Picking a group from another host left the project ungrouped, or
took it out of its current group, with no error.

Filter the submenu to groups whose catalog is the project's catalog: this
app's catalog for local and direct-SSH projects, the paired server's for
its projects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e's host

The workspace card menu looked the project up by id through the
active-workspace selector. Repo ids repeat across hosts, so right-clicking
a paired host's workspace while this Mac's same-id project was active
filtered and moved with the wrong row. Look the row up on the workspace's
own host, as the edit dialog already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… rebasing onto main

- isProjectGroupJoinableFromCatalog (stablyai#30127) reuses catalogHostIdFor instead of a second copy.
- The card menu's host-aware repo and group lookup moves to use-worktree-menu-project-groups.ts so the menu model stays under max-lines.
- The menu test fixture gains unifiedTabsByWorktree, which main's sleep check now reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A workspace row from older local metadata has no host stamp. The card menu
fell back to the active workspace's project row, so with a paired twin
active it offered the twin host's groups. Follow the owner index instead:
no runtime owner and no host stamp means local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jbamlee

jbamlee commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 90e99c48f4, still a draft.

@nwparker since #30127 the store refuses a move into another host's group and says so. This PR keeps that guard. What it still adds on top:

  1. Both Move to group menus list only groups the project can join, so they no longer offer choices that always end in the fix(project-groups): say so when a project cannot join a group on another host #30127 error.
  2. The workspace card's menu resolves the project row on the clicked workspace's host. On main it uses the active workspace's row, so with the same repo id on two hosts it can show and move the other host's project.

Is the menu filter wanted on top of #30127? If not, I'll close this and keep only (2) as a smaller PR.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @jbamlee, and thanks for rebasing. Please go with the smaller PR: keep only (2), resolving the card menu's project row on the clicked workspace's host. That one is a real twin bug: with the same repo id on two hosts, the menu can show or move the wrong host's project. It matches the host-scoping we've been tightening across the sidebar.

For (1) we'd rather not add the menu filter on top of #30127. The store guard already refuses a cross-host move and says why. A second filter in the menu is one more place that has to agree with the store's host rules, and it hides groups people may expect to see.

Please close this one and open the (2)-only PR; I'll review it.

@jbamlee

jbamlee commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @nwparker. Closing as agreed. The card-menu row fix is now #30882 (fixes #30881), rebased onto current main, and the Move to group filter is dropped.

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]: Move to group lists other hosts' groups, and picking one leaves the project ungrouped

2 participants