Skip to content

fix(sidebar): stabilize cross-host project grouping - #11805

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/investigate-worktree-split-cause
Jul 31, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/investigate-worktree-split-cause

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

Keep one logical project grouped under one sidebar identity across local, SSH, and Orca-server checkouts, even when a remote server goes offline or the setup catalog contains duplicate/folder projection rows.

Also show a retryable warning toast when a previously connected Orca server becomes unavailable.

Before

One execution surface with multiple setup rows marked the entire project as ambiguous. This included:

  • derived and authoritative catalog rows describing the same checkout directory
  • non-Git folder workspaces associated with the project
  • genuinely separate Git checkouts on only one host

Once marked ambiguous, every checkout on every host switched to a setup-specific group key. The label collision fallback then exposed path tails, so one stablyai/orca project could suddenly look like three unrelated sidebar projects after a catalog refresh:

brennanbenson/orca/orca
home/brennan/orca
neil/orca/orca

A server outage could trigger the refresh that exposed the split, even though connection status was not itself part of the grouping key. Users retained the persistent red disconnected indicator but received no transient explanation.

After

Conceptually, the same checkouts remain presented as:

Orca
  local workspaces
  SSH workspaces
  Orca-server workspaces (disconnected when unavailable)
  • Ambiguity is scoped to the exact project, owning host, execution target, and Windows/WSL path surface.
  • Setup rows count distinct normalized checkout directories, so projection twins count once.
  • Folder workspaces and provisioned copies do not count as independent Git checkouts.
  • If one surface genuinely has two Git checkouts, only those checkouts receive setup-specific headers; other hosts remain under Orca.
  • Online/offline changes do not alter project keys, labels, ordering, or collapsed state.
  • A connected-to-offline transition shows one deduplicated warning toast with the server name and a Retry action.
  • Cold-start offline detection and repeated failed probes do not spam toasts; recovery or server removal dismisses any active notification.

Screenshots

Not included: the regression requires a multi-host catalog with duplicate projections plus a live server transition. The before/after presentation is documented above and covered by grouping and runtime-status regression tests.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation run:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/sidebar/worktree-list-groups.test.ts src/renderer/src/store/slices/runtime-status.test.ts src/renderer/src/components/right-sidebar/file-explorer-operation-generation.test.ts src/renderer/src/store/slices/runtime-environment-ssh.test.ts — 154 tests passed
  • pnpm run typecheck:web
  • focused oxlint on the four changed TypeScript files
  • pnpm run verify:localization-catalog
  • pnpm run verify:localization-extraction
  • pnpm run verify:localization-coverage
  • pnpm run check:max-lines-ratchet
  • git diff --check

AI Review Report

Reviewed the grouping boundary, checkout identity, disconnect transition lifecycle, retry behavior, and cleanup paths.

The review explicitly checked macOS, Linux, Windows drive paths, WSL UNC aliases, local/SSH/runtime execution hosts, nested SSH identity spelling, and folder-workspace behavior. It also confirmed that this PR does not change shortcuts, shell commands, terminal launching, or other Electron platform behavior.

The review flagged that cleanup initially called Sonner's dismiss path even when no toast had been shown. That was tightened to track active toast generations only, preventing unnecessary renderer work and stale callback races; headless consumer tests were added to the validation set.

Security Audit

  • No new dependencies, auth flows, command execution, shell input, or filesystem mutations.
  • Runtime paths are used only through the existing comparison normalizer; normalized values are never used as real filesystem paths.
  • The Retry action calls the existing saved-environment status IPC with an internal environment id; no user-controlled text is interpolated into commands or IPC methods.
  • Server names are rendered through React/Sonner and the existing localization layer.
  • No secrets or endpoint credentials are logged or added to state.

No security follow-up is required.

Notes

  • This changes projection/grouping behavior only; it does not delete or migrate existing checkout or folder records.
  • The persistent sidebar disconnected state remains the durable indicator. The toast is intentionally transient and transition-based.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cf60bdd5-6ddf-42f2-9f49-92af1636e9e2

📥 Commits

Reviewing files that changed from the base of the PR and between 622eaaf and 731d30a.

📒 Files selected for processing (2)
  • src/renderer/src/store/slices/runtime-status.test.ts
  • src/renderer/src/store/slices/runtime-status.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/store/slices/runtime-status.test.ts
  • src/renderer/src/store/slices/runtime-status.ts

📝 Walkthrough

Walkthrough

The runtime status store now shows localized disconnect notifications with retry and dismissal behavior. Callers can suppress notifications during intentional disconnect flows. Tests cover disconnect, recovery, retry, cleanup, and suppression cases. Project grouping now identifies execution surfaces and normalized checkout identities, splitting headers only when multiple distinct checkouts share one surface. Tests cover projection twins and cross-platform setup grouping.

🚥 Pre-merge checks | ✅ 4 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: stabilizing sidebar project grouping across hosts.
Description check ✅ Passed The description includes all required sections, explains the user-visible changes, documents validation, and covers AI review and security risks.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes two related problems: cross-host project grouping fragmentation in the sidebar and a missing disconnect notification when an Orca runtime server goes offline. The core grouping fix narrows ambiguity detection from the whole project to the exact surface (project × host × execution target × filesystem namespace), so only the specific surface with genuinely independent checkouts gets split headers. The disconnect toast adds a one-shot warning with a Retry action when a previously-connected server becomes unreachable, with clean suppression for intentional disconnects and cold-start probes.

  • Grouping fix (worktree-list-groups.ts): replaces projectIdsRequiringSetupGroups (project-wide) with surfaceKeysRequiringSetupGroups (per-surface), counts normalized checkout directories (not raw setup rows), and excludes folder workspaces and provisioned copies from the duplicate-checkout count.
  • Toast lifecycle (runtime-status.ts): introduces showRuntimeDisconnectedToast / dismissRuntimeDisconnectedToast driven by activation symbols to avoid stale callbacks; suppressDisconnectToast option threads through RuntimeEnvironmentsPane and SshStatusSegment for intentional disconnects.
  • Tests cover the grouping boundaries, cold-start offline suppression, retry deduplication, recovery dismiss, and intentional-disconnect suppress paths.

Confidence Score: 5/5

Safe to merge — changes are scoped to grouping presentation logic and a transient toast notification with no mutations to stored state or IPC behavior.

The grouping refactor correctly narrows ambiguity to the per-surface level and uses normalized paths to deduplicate projection twins. The toast lifecycle is guarded by activation symbols that prevent stale callbacks and is properly cleaned up through every removal path (remove, clear, retain, intentional disconnect, recovery). All edge cases — cold-start offline, repeated failed probes, retry deduplication, environment removal during a pending retry — are exercised by the new tests and hold up under manual analysis.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/renderer/src/store/slices/runtime-status.ts Adds disconnect toast lifecycle with activation-symbol guards, retry deduplication, and suppress option; previous-status capture moved before set() (safe in synchronous Zustand); all dismiss paths (remove, clear, retain, suppress, recover) are covered.
src/renderer/src/components/sidebar/worktree-list-groups.ts Surface-scoped ambiguity detection replaces project-wide detection; checkout identity uses normalized paths so projection twins count once; folder/provisioned setups excluded from checkout count; execution surface normalization handles SSH/WSL/Windows/runtime targets.
src/renderer/src/store/slices/runtime-status.test.ts Comprehensive new tests for cold-start suppression, connected→offline toast, recovery dismiss, retry dedup, intentional-disconnect suppress, and removal/clear scenarios; fake timers used correctly for async retry flow.
src/renderer/src/components/sidebar/worktree-list-groups.test.ts Updates existing 'splits all setups' test to verify that only the ambiguous surface is split; adds two new grouping tests (projection twins, folder + Windows setups).
src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx Threads suppressDisconnectToast through the manual disconnect call so the new toast logic doesn't fire on intentional user action.
src/renderer/src/components/status-bar/SshStatusSegment.tsx Same suppress-toast threading as RuntimeEnvironmentsPane for the SSH status bar disconnect path.
src/renderer/src/i18n/locales/en.json Adds runtimeHostDisconnectedDescription under the correct auto-key path for the disconnect toast description string.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[setRuntimeEnvironmentStatus called] --> B{options.suppressDisconnectToast?}
    B -- Yes --> C[dismissRuntimeDisconnectedToast\nclear active toast]
    B -- No --> D{previous.status === null\nAND new status !== null?}
    D -- Yes --> E[dismissRuntimeDisconnectedToast\nserver recovered]
    D -- No --> F{previous exists AND\nprevious.status !== null\nAND new status === null?}
    F -- Yes --> G[showRuntimeDisconnectedToast\nconnected to offline transition]
    F -- No --> H[No toast action\nnull to null or first probe]
    G --> I[toast.warning shown\nwith Retry action]
    I --> J{User clicks Retry}
    J --> K{retrying flag?}
    K -- Already retrying --> L[event.preventDefault\nsilently ignore]
    K -- Not retrying --> M[retrying = true\nshowToast infinity duration\nrefreshRuntimeEnvironmentStatus]
    M --> N{Probe result}
    N -- Reachable --> O[setRuntimeEnvironmentStatus\nnon-null status\ndismissRuntimeDisconnectedToast]
    N -- Still offline --> P{activation still current\nAND env still saved?}
    P -- Yes --> Q[showToast 4s duration]
    P -- No --> R[No new toast\nstale activation guard]
    S[setRuntimeEnvironments / clearRuntimeEnvironmentStatus\nretainRuntimeEnvironmentStatuses] --> T[dismissRuntimeDisconnectedToast\nfor each retired/removed id]
Loading

Reviews (4): Last reviewed commit: "fix(runtime): keep offline retry toast v..." | Re-trigger Greptile

}

const connectionGenerationByEnvironment = new Map<string, number>()
const activeRuntimeDisconnectedToasts = new Map<string, symbol>()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Module-level toast map outlives store recreation

activeRuntimeDisconnectedToasts is a module-level singleton, so it is never reset when the Zustand store is re-created (e.g. hot-module replacement in development, or any future multi-store test pattern). If HMR tears down and rebuilds the renderer while a disconnect toast is active, Sonner clears its own DOM state but the map still has the entry. The next connected→offline transition calls showRuntimeDisconnectedToast as expected, but the preceding dismissRuntimeDisconnectedToast call inside clearRuntimeEnvironmentStatus would silently skip the toast.dismiss branch because the map entry from the old activation is still present — the new set() would then no-op.

This is benign in production (single renderer lifetime, single store) and the activation-symbol guard already prevents stale callbacks from mutating the map. Worth tracking if the store factory ever gets exercised more than once per process.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA evidence from the PR worktree\n\nScenario:\n- Seeded one project across Local Mac, SSH/Build Server, and QA Server hosts; verified all three workspace projections render under the single Orca project.\n- Marked QA Server unavailable and clicked the real Sonner Retry action; after 900 ms the disconnected toast, explanatory copy, and Retry action remained visible.\n- Direct visual inspection found no layout, clipping, contrast, or stale-state regression.\n\nThe catalog/outage state was seeded for deterministic coverage. A live remote-server outage and an actual Settings Disconnect against a live server were not exercised.\n\nCross-host project grouping\n\nDisconnect retry toast

@brennanb2025
brennanb2025 merged commit fcb23e1 into main Jul 31, 2026
81 of 83 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(sidebar): stabilize cross-host project grouping

* fix(runtime): suppress outage toast on disconnect

* fix(runtime): dismiss intentional outage toast

* fix(runtime): keep offline retry toast visible
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