← Back to Pull requests

fix(sidebar): keep the viewport on a visible pinned duplicate when revealing a workspace #25108

Merged
ggbdpq merged 4 files (275 lines) on Nov 12, 2026 11:38 UTC
View on GitHub
ggbdpq ggbdpq commented on Oct 04, 2026 00:11 UTC
Author

ELI5

If you pin a workspace and also show pinned workspaces inside their project groups, that workspace appears twice in the sidebar. When you clicked the copy in the Pinned section, the sidebar sometimes scrolled down to the other copy in the project group, so the row you had just clicked disappeared. Now, if a copy is already on screen, the sidebar stays where it is.

What Changed

Before: with "show pinned worktrees in groups" on, clicking a pinned workspace and then any follow-up "reveal this workspace" (terminal focus/create, notification click, agent launch, the reveal-current-workspace crosshair, the jump palette) scrolled the sidebar to the natural-group copy. The Pinned section went off screen, and the next click on a pinned row could miss because that row was no longer mounted.

After: the reveal stays on the copy that is already on screen. If that copy is fully visible, nothing scrolls. If it is clipped, it gets the smallest nudge needed to show it. The natural-group copy is still the target when no copy is on screen.

Mechanism: usePendingSidebarReveal now resolves the target option through a new findOnScreenWorktreeOption (mounted-row-reveal.ts) whenever the request has no explicit rowKey. It walks the mounted copies of the workspace using getMountedWorktreeOptions, matches the host via data-worktree-host-identity (hostless reveals match by id, the same as the existing lookup), and measures each copy with the existing getRevealTargetBounds. Because of that, a lineage parent is judged by its own card and not by its children. The new getRevealBoundsVisibility (worktree-sidebar-reveal.ts) classifies each copy as full, partial, or hidden, using the same sticky-header inset the reveal scroll uses. Precedence is: the lookup-preferred copy if fully visible, then any fully visible copy, then any partly visible copy, then the existing lookup result. Reveals with an explicit rowKey, and the case where no copy is mounted, behave exactly as before.

Why

Every reveal source carries only the worktree identity and not a specific row, so the row lookup's natural-group preference applied even when the user was looking at the pinned copy. The fix sits in the one place every reveal goes through, so it covers every trigger without having to find which event fires right after the click. Earlier iterations threaded an isVisibleRow predicate through both render-row lookup functions. That added more code, and it also left keyboard and aria callers sharing logic they don't need. Keeping the lookup unchanged and choosing among the mounted DOM copies is smaller, and it reuses the same bounds the scroll already uses.

Linked Issue

Fixes #24852

Visual Proof

Repro: a scratch repo with 25 worktrees, cc-20..cc-23 pinned, sort by name, "show pinned worktrees in groups" on, and the sidebar scrolled to the top. Click pinned cc-22, then run revealWorktreeInSidebar(cc-22) (the same courtesy reveal that terminal focus sends). Background Electron dev build on macOS, driven over CDP.

| Start (pinned cc-22 on screen) | Before (main): scrollTop 0 -> 1296, Pinned gone | After (this PR): scrollTop stays 0 |
| --- | --- | --- |
| !start | !before | !after |

Testing

  • Reproduced the bug and the fix in a background Electron dev build on macOS with a throwaway profile (screenshots above). The same click + reveal sequence on main scrolled the sidebar from 0 to 1296 and highlighted the group copy at the bottom. With this PR, scrollTop stayed at 0 and the pinned copy stayed highlighted.

  • New use-pending-reveal.test.tsx (7 cases): pinned copy on screen, so no scroll (also covers the hostless revealWorkspaceSurface path). Clipped pinned copy, so a minimal nudge. A pinned copy clipped under the header loses to a fully visible group copy. Both copies fully visible, so the lookup-preferred copy flashes and nothing scrolls. A pinned parent card off screen while its lineage children are visible. A visible pinned parent whose children overflow, so no scroll. No copy on screen, so the natural-group preference is kept. With the findOnScreenWorktreeOption call removed, 3 of the 7 cases fail.

  • vitest on sidebar/worktree-list/navigation/: 24 passed.

  • oxlint, oxfmt --check, anti-slop oxlint, code-quality native-plugins oxlint, ast-grep, and check-changed-code-quality.mjs are clean on the 4 changed files.

  • Platforms: macOS only. The change is renderer-only DOM measurement with no platform-specific paths.
  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns
  • Risk

    The riskiest part is choosing a different copy than before when duplicates are rendered. If it chose wrong, a reveal could flash or rename the pinned copy instead of the group copy, or fail to scroll when a user expected it to. Nothing scrolls away from a visible copy, and when no copy is on screen the behavior is exactly the same as main. Renderer-only: no saved data, settings, IPC, SSH/remote, or mobile protocol changes. Back out with a plain revert.

    Level: Low

    Review

    Reviewed over several rounds. Fixes from review:

  • A clipped pinned copy no longer beats a fully visible group copy.

  • Lineage children no longer inflate a parent's visibility bounds.

  • When both copies are visible, the flash and rename stay on the copy main picks.
  • A speculative folder-workspace change was dropped, because folder workspaces never render in the Pinned section.

    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, cross-platform, SSH/remote, mobile, backward compatibility, and performance: no impact beyond a walk over the mounted copies of a single workspace (normally 1-2 elements) per reveal. SSH/runtime copies are matched by host identity.

    Original fix by @ggbdpq in #25108. Authorship is preserved on the commit.

    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)

  • I stated the risk: what could break, for whom, and how to back it out

  • 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)
  • Diff: 275 lines (+266 / -9) across 4 files Reviewer: ggbdpq Review duration: 56846m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.55) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 275 lines diff across 4 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 5 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.336
    Self Review self_review
    0.140
    Real PR Conversation Timeline
    9 items
    pullfrog[bot] pullfrog[bot] commented on Oct 04, 2026 00:18 UTC
    Reviewer

    ✅ No new issues found.

    Reviewed changes

  • Visible-copy preference in the row lookup — findPreferredRenderRowIndexForWorktree (render-row-lookup.ts:84) and its identity variant now accept an optional isVisibleRow predicate. An already-visible match wins; when it is omitted the previous natural-group → fallback order is unchanged (the former early return is now a recorded index, which is behavior-equivalent).

  • Visibility helper — isElementVisibleInScrollContainer (worktree-sidebar-reveal.ts:73) reuses getScrollTopToRevealBounds with WORKTREE_SIDEBAR_REVEAL_TOP_INSET, so the "visible" judgment cannot diverge from the scroll-skip decision in revealElementInScrollContainer.

  • Predicate wiring — createVisibleRevealRowPredicate (mounted-row-reveal.ts:12) resolves each candidate row's option id and checks it against the sidebar container; use-pending-reveal.ts builds it from scrollRef.current and passes it to both lookups. Keyboard/aria callers pass no predicate and are untouched.

  • Tests — unit coverage for visible-wins, no-predicate equivalence, and fallback order; a happy-dom hook test asserting no scrollTo while the pinned copy is on screen and a scroll when neither copy is; helper-agreement tests.
  • I independently confirmed pnpm tc:web is clean, the navigation/ suite is green (65 tests), and that reverting the lookup's visible preference turns the new "does not yank…" hook test red (it scrolled toward the off-screen group copy) — the regression is genuinely pinned.

    <!--
    Pullfrog review metadata. These findings were written against dcc41b45;
    if commits have landed on fix/sidebar-pinned-reveal-yank since, treat every specific bug, file, or
    line callout as POTENTIALLY STALE and re-diff before acting on it.

  • Mode: Review (initial)

  • Files reviewed: 7

  • Commits reviewed: 1

  • Base: main (44b955b)

  • Head: fix/sidebar-pinned-reveal-yank (dcc41b45)

  • Reviewed commits:

  • - dcc41b45 — fix(sidebar): don't yank the viewport off a visible pinned row when activating duplicates
  • Prior pullfrog review: none

  • -->

    <!-- PULLFROG_DIVIDER_DO_NOT_REMOVE_PLZ -->
    <sup><a href="https://pullfrog.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pullfrog.com/logos/frog-white-full-18px.png"><img src="https://pullfrog.com/logos/frog-green-full-18px.png" width="9px" height="9px" style="vertical-align: middle; " alt="Pullfrog"></picture></a>&nbsp;&nbsp;| View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏</sup>

    coderabbitai[bot] coderabbitai[bot] commented on Oct 04, 2026 00:23 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/stablyai/orca/pull/25108?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a>

    <!-- review_stack_entry_end -->
    <!-- recent_review_status_start -->

    No actionable comments were generated in the recent review.

    <!-- recent_review_status_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>
    <br>

    Worktree row lookup now considers visibility when choosing between duplicate rows. The pending reveal hook supplies a visibility predicate based on the scroll container and reveal request. New tests cover visibility checks, duplicate-row selection, and pending reveal behavior.

    </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <!-- change_assessment_start -->
    <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->

    <!-- change_assessment_commit:"608f23fe36881a6a7b1baf072ac13646944f69ef" -->
    Severity of issue fixed: Medium
    <!-- change_assessment_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>608f2</code></summary>
    <dl>
    <dd>
    <br>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 608f2
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"608f23fe36881a6a7b1baf072ac13646944f69ef","coveredCommitId":"608f23fe36881a6a7b1baf072ac13646944f69ef","kind":"reviewed"} -->

    Visible pinned rows remain the reveal target under the inspected paths. No issue requiring a fix before merge was found.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
    <dl>
    <dd>
    <br>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Linked Issues check | !Passed | For #24852, the reveal path now prefers a visible duplicate row. The pending-reveal hook uses the same visibility judgment as the scroll-skip logic. When no copy is visible, the existing natural-group… |
    | Out of Scope Changes check | !Passed | The changes stay within #24852. They update reveal-row selection, reveal visibility evaluation, and focused tests. The folder-workspace identity handling supports the issue's duplicate-row scope. No u… |
    | Title check | !Passed | The title names the main change: when revealing a workspace, the sidebar keeps the viewport on a visible pinned duplicate. The raw summary and objectives confirm the change adds visible-copy preferenc… |
    | Description check | !Passed | The description follows the template closely: ELI5, What Changed (before/after and mechanism), Why (including alternatives considered), Linked Issue (Fixes #24852), Visual Proof (before/after media), … |

    <details>
    <summary><strong>Full details: Linked Issues check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    For #24852, the reveal path now prefers a visible duplicate row. The pending-reveal hook uses the same visibility judgment as the scroll-skip logic. When no copy is visible, the existing natural-group preference remains. Callers without the predicate retain their prior navigation and aria behavior. Tests cover visible-copy selection, fallback behavior, hook wiring, identity-based folder rows, and visibility agreement. The active-row logic is unchanged. The unperformed manual click sequence and the untested configuration combinations do not establish a missing coding requirement.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Out of Scope Changes check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The changes stay within #24852. They update reveal-row selection, reveal visibility evaluation, and focused tests. The folder-workspace identity handling supports the issue's duplicate-row scope. No unrelated feature, platform, persistence, or navigation behavior change is reported.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Title check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The title names the main change: when revealing a workspace, the sidebar keeps the viewport on a visible pinned duplicate. The raw summary and objectives confirm the change adds visible-copy preference to reveal row selection. The title is specific, though it is long at 88 characters.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Description check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The description follows the template closely: ELI5, What Changed (before/after and mechanism), Why (including alternatives considered), Linked Issue (Fixes #24852), Visual Proof (before/after media), Testing with checklist, Risk with level and back-out plan, AI Disclosure left blank, and Notes and Checklist. The AI Disclosure section is left empty, and the final pnpm checklist item is unchecked. Both gaps are minor and non-critical.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    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.

    <details>
    <summary><strong>Share</strong></summary>
    <dl>
    <dd>
    <br>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <!-- tips_end -->
    <!-- recent_review_start -->

    <h6>
    <details>
    <summary><strong>ℹ️ Recent review info</strong></summary>
    <dl>
    <dd>
    <br>

    <details>
    <summary><strong>⚙️ Run configuration</strong></summary>
    <dl>
    <dd>
    <br>

  • Configuration used: Repository UI

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: ec401de5-1108-4c90-90ac-911a334d5155
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong>📥 Commits</strong></summary>
    <dl>
    <dd>
    <br>

    Reviewing files that changed from the base of the PR and between dcc41b45dd1f6a20a2e099c0f14a91b19b9a20c5 and 608f23fe36881a6a7b1baf072ac13646944f69ef.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>📒 Files selected for processing (2)</strong></summary>
    <dl>
    <dd>
    <br>

    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.test.ts
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>🚧 Files skipped from review as they are similar to previous changes (2)</strong></summary>
    <dl>
    <dd>
    <br>

    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.test.ts
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts

    </dd>
    </dl>
    </details>

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

    </dd>
    </dl>
    </details>
    </h6>

    <!-- recent_review_end -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Oct 04, 2026 00:23 UTC
    Code Review
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts:1
    @@ -93,21 +98,36 @@ export function findPreferredRenderRowIndexForWorktree(
         if (fallbackIndex === -1) {
           fallbackIndex = index
         }
    +    if (visibleIndex === -1 && isVisibleRow?.(row)) {
    +      visibleIndex = index
    +    }
         const itemRow = getRenderRowWorktreeItem(row, worktreeId)
    -    if (pinnedDisplayPolicy === 'duplicate-in-groups' && itemRow && !isPinnedWorktreeRow(itemRow)) {
    -      return index
    +    if (
    +      naturalGroupIndex === -1 &&
    +      pinnedDisplayPolicy === 'duplicate-in-groups' &&
    +      itemRow &&
    +      !isPinnedWorktreeRow(itemRow)
    +    ) {
    +      naturalGroupIndex = index
         }
       }
    -  return fallbackIndex
    +  return visibleIndex !== -1
    +    ? visibleIndex
    +    : naturalGroupIndex !== -1
    +      ? naturalGroupIndex
    +      : fallbackIndex
     }
     
     export function findPreferredRenderRowIndexForWorktreeIdentity(
       renderRows: readonly RenderRow[],
       worktree: Pick<Worktree, 'id' | 'hostId'>,
    -  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy
    +  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy,
    +  isVisibleRow?: (row: RenderRow) => boolean

    _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_

    <details>
    <summary>🔎 Supported by static analysis</summary>

    🏁 Script executed:

    #!/bin/bash
    # Inspect folder-row production and the host-qualified reveal path.
    rg -n -C 4 --glob '*.{ts,tsx}' \
      "type: 'folder-workspace'|duplicate-in-groups|folderWorkspaceToWorktree" \
      src/renderer/src/components/sidebar/worktree-list
    rg -n -C 4 --glob '*.{ts,tsx}' \
      'pendingRevealWorktree|executionHostId' \
      src/renderer/src/components/sidebar/worktree-list/navigation
    

    Repository: stablyai/orca

    Length of output: 42453

    ---

    🏁 Script executed:

    printf '%s\n' '--- grouping/build-rows.ts ---'; sed -n '1,190p' src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts; printf '%s\n' '--- grouping/row-builders.ts ---'; sed -n '225,285p' src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts; printf '%s\n' '--- navigation/render-row-lookup.ts ---'; sed -n '80,180p' src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts; printf '%s\n' '--- navigation/use-pending-reveal.ts ---'; sed -n '55,135p' src/renderer/src/components/sidebar/worktree-list/navigation/use-pending-reveal.ts
    

    Repository: stablyai/orca

    Length of output: 15425

    ---

    🏁 Script executed:

    printf '%s\n' '--- remaining grouping/build-rows.ts ---'; sed -n '175,430p' src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts; printf '%s\n' '--- grouping/folder-workspace-lanes.ts ---'; sed -n '1,230p' src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-lanes.ts; printf '%s\n' '--- folder workspace emitters ---'; rg -n -C 3 'buildFolderWorkspaceRow|renderableFolderWorkspaces' src/renderer/src/components/sidebar/worktree-list/grouping --glob '*.ts'
    

    Repository: stablyai/orca

    Length of output: 16488

    ---

    🏁 Script executed:

    printf '%s\n' '--- folder workspace source and list bindings ---'; rg -n -C 3 --glob '*.{ts,tsx}' 'folderWorkspaces\s*[:=]|setFolderWorkspaces|folderWorkspace.*Map|Map<.*FolderWorkspace|folder-workspace:' src/renderer/src shared | head -n 260; printf '%s\n' '--- FolderWorkspace declaration ---'; rg -n -C 8 --glob '*.{ts,d.ts}' 'export (type|interface) FolderWorkspace|type FolderWorkspace\s*=' shared
    

    Repository: stablyai/orca

    Length of output: 24755

    ---

    🏁 Script executed:

    printf '%s\n' '--- locate relevant declarations ---'; rg --files | rg '(^|/)(folder-workspace-types|catalog-identity|folder-workspace-catalog)(\\.ts|\\.d\\.ts)$'; printf '%s\n' '--- folder-workspace-catalog.ts ---'; sed -n '1,175p' src/renderer/src/store/folder-workspaces/folder-workspace-catalog.ts; printf '%s\n' '--- catalog identity helpers ---'; rg -n -C 5 'function mergeByIdentity|const mergeByIdentity|mergeByIdentity\\(' src/renderer/src/store; printf '%s\n' '--- FolderWorkspace type ---'; rg -n -C 8 --glob '*.{ts,d.ts}' 'export (type|interface) FolderWorkspace' src
    

    Repository: stablyai/orca

    Length of output: 31490

    ---

    🏁 Script executed:

    printf '%s\n' '--- catalog-identity.ts ---'; sed -n '1,180p' src/renderer/src/store/catalog-identity.ts; printf '%s\n' '--- folder catalog merge context ---'; sed -n '125,175p' src/renderer/src/store/folder-workspaces/folder-workspace-catalog.ts; printf '%s\n' '--- folder catalog line anchors ---'; rg -n 'getRenderableFolderWorkspaces|pinnedDisplayPolicy === .duplicate-in-groups.|buildFolderWorkspaceRow|mergeFetchedFolderWorkspacesForHost|mergeByIdentity' src/renderer/src/components/sidebar/worktree-list/grouping/build-rows.ts src/renderer/src/components/sidebar/worktree-list/grouping/folder-workspace-lanes.ts src/renderer/src/components/sidebar/worktree-list/grouping/row-builders.ts src/renderer/src/store/folder-workspaces/folder-workspace-catalog.ts
    

    Repository: stablyai/orca

    Length of output: 4994

    ---

    🏁 Script executed:

    printf '%s\n' '--- project-group-sections.ts ---'; sed -n '1,155p' src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts; printf '%s\n' '--- project group section construction ---'; sed -n '1,250p' src/renderer/src/components/sidebar/worktree-list/grouping/project-group-sections.ts; printf '%s\n' '--- project group ID and host collision evidence ---'; rg -n -C 4 --glob '*.{ts,tsx}' 'multiple copies of a group|projectGroupsById|group\.id.*host|same.*group.*host|projectGroupId' src/renderer/src/components/sidebar/worktree-list/grouping src/renderer/src/store/folder-workspaces src/renderer/src/store/slices/project-group-owner-routing.ts | head -n 220
    

    Repository: stablyai/orca

    Length of output: 35577

    ---

    🏁 Script executed:

    printf '%s\n' '--- buildRows call sites in sidebar ---'; rg -n -C 5 'buildRows\\(' src/renderer/src/components/sidebar/worktree-list --glob '*.{ts,tsx}'; printf '%s\n' '--- projectGroups prop/store binding around sidebar row construction ---'; rg -n -C 4 'projectGroups:' src/renderer/src/components/sidebar/worktree-list --glob '*.{ts,tsx}' | head -n 220; printf '%s\n' '--- group catalog multi-host handling ---'; rg -n -C 5 'multiple copies of a group|mergeFetchedProjectGroups|projectGroupHostIdentity|project-group.*identity' src/renderer/src/store src/renderer/src/components/sidebar/worktree-list/grouping --glob '*.{ts,tsx}' | head -n 180
    

    Repository: stablyai/orca

    Length of output: 28842

    ---

    🏁 Script executed:

    sed -n '1,75p' src/renderer/src/store/project-groups/project-group-catalog.ts; printf '%s\n' '--- host filtering ---'; sed -n '20,65p' src/renderer/src/components/sidebar/worktree-list/listing/host-filtering.ts
    

    Repository: stablyai/orca

    Length of output: 4259

    ---

    </details>

    Apply isVisibleRow to duplicate folder-workspace matches.

    When multiple folder rows share the same workspace identity, the host-qualified lookup returns the first match before evaluating isVisibleRow. This can select an off-screen row instead of the visible copy.

    <details>
    <summary>🐛 Suggested fix</summary>

           if (
             folderWorkspaceKey(row.folderWorkspace.id) === worktree.id &&
             (!worktree.hostId ||
               getWorktreeHostIdentity(folderWorkspaceToWorktree(row.folderWorkspace)) === identity)
           ) {
    -        return index
    +        if (fallbackIndex === -1) fallbackIndex = index
    +        if (visibleIndex === -1 && isVisibleRow?.(row)) visibleIndex = index
           }
    

    </details>

    <!-- fingerprinting:phantom:poseidon:wombat -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:1e2a4f033de97c9623023be4 -->

    <!-- This is an auto-generated reply by CodeRabbit -->

    ✅ Addressed in commit 608f23f

    coderabbitai[bot] coderabbitai[bot] commented on Oct 04, 2026 00:23 UTC
    Reviewer

    Actionable comments posted: 1

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

  • Configuration used: Repository UI

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: 5ab574b5-6d76-4ef4-9fcd-cac9e55ad653
  • </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between 44b955b96c76c82e973f2ae2460204a6fccd9c4f and dcc41b45dd1f6a20a2e099c0f14a91b19b9a20c5.

    </details>

    <details>
    <summary>📒 Files selected for processing (7)</summary>

    src/renderer/src/components/sidebar/worktree-list/navigation/mounted-row-reveal.ts
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.test.ts
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts
    src/renderer/src/components/sidebar/worktree-list/navigation/use-pending-reveal.test.tsx
    src/renderer/src/components/sidebar/worktree-list/navigation/use-pending-reveal.ts
    src/renderer/src/components/sidebar/worktree-sidebar-reveal.test.ts

  • src/renderer/src/components/sidebar/worktree-sidebar-reveal.ts
  • </details>

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

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    ggbdpq ggbdpq commented on code on Oct 08, 2026 13:08 UTC
    Code Review
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts:1
    @@ -93,21 +98,36 @@ export function findPreferredRenderRowIndexForWorktree(
         if (fallbackIndex === -1) {
           fallbackIndex = index
         }
    +    if (visibleIndex === -1 && isVisibleRow?.(row)) {
    +      visibleIndex = index
    +    }
         const itemRow = getRenderRowWorktreeItem(row, worktreeId)
    -    if (pinnedDisplayPolicy === 'duplicate-in-groups' && itemRow && !isPinnedWorktreeRow(itemRow)) {
    -      return index
    +    if (
    +      naturalGroupIndex === -1 &&
    +      pinnedDisplayPolicy === 'duplicate-in-groups' &&
    +      itemRow &&
    +      !isPinnedWorktreeRow(itemRow)
    +    ) {
    +      naturalGroupIndex = index
         }
       }
    -  return fallbackIndex
    +  return visibleIndex !== -1
    +    ? visibleIndex
    +    : naturalGroupIndex !== -1
    +      ? naturalGroupIndex
    +      : fallbackIndex
     }
     
     export function findPreferredRenderRowIndexForWorktreeIdentity(
       renderRows: readonly RenderRow[],
       worktree: Pick<Worktree, 'id' | 'hostId'>,
    -  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy
    +  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy,
    +  isVisibleRow?: (row: RenderRow) => boolean

    Confirmed and fixed in 608f23fe36 — the folder-workspace branch now feeds the same fallback/visible trackers as the item-row path instead of returning the first match, so a visible duplicate wins and single-match lookups are unchanged. Red evidence: with two folder rows sharing one workspace identity and only the second visible, the lookup returned 0 before the fix and 1 after. Regression cases added for the no-predicate, visible-duplicate, and nothing-visible paths.

    coderabbitai[bot] coderabbitai[bot] commented on code on Oct 08, 2026 13:16 UTC
    Code Review
    src/renderer/src/components/sidebar/worktree-list/navigation/render-row-lookup.ts:1
    @@ -93,21 +98,36 @@ export function findPreferredRenderRowIndexForWorktree(
         if (fallbackIndex === -1) {
           fallbackIndex = index
         }
    +    if (visibleIndex === -1 && isVisibleRow?.(row)) {
    +      visibleIndex = index
    +    }
         const itemRow = getRenderRowWorktreeItem(row, worktreeId)
    -    if (pinnedDisplayPolicy === 'duplicate-in-groups' && itemRow && !isPinnedWorktreeRow(itemRow)) {
    -      return index
    +    if (
    +      naturalGroupIndex === -1 &&
    +      pinnedDisplayPolicy === 'duplicate-in-groups' &&
    +      itemRow &&
    +      !isPinnedWorktreeRow(itemRow)
    +    ) {
    +      naturalGroupIndex = index
         }
       }
    -  return fallbackIndex
    +  return visibleIndex !== -1
    +    ? visibleIndex
    +    : naturalGroupIndex !== -1
    +      ? naturalGroupIndex
    +      : fallbackIndex
     }
     
     export function findPreferredRenderRowIndexForWorktreeIdentity(
       renderRows: readonly RenderRow[],
       worktree: Pick<Worktree, 'id' | 'hostId'>,
    -  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy
    +  pinnedDisplayPolicy: PinnedWorktreeDisplayPolicy,
    +  isVisibleRow?: (row: RenderRow) => boolean

    @ggbdpq Thanks for the fix. The supplied code now checks folder-workspace matches for visibility before selecting a row. The regression cases cover visible-duplicate selection and fallback behavior.

    ---

    <!-- This is an auto-generated comment: tweet message by coderabbit.ai -->

    If you found this review helpful, would you consider giving us a shout-out on X?

    Thank you for using CodeRabbit!

    <!-- end of auto-generated comment: tweet message by coderabbit.ai -->

    ✅ Review thread resolved.

    _You are interacting with an AI system._

    <!-- This is an auto-generated reply by CodeRabbit -->

    ggbdpq ggbdpq commented on Oct 25, 2026 12:57 UTC
    Author

    Rebased onto 7d18e19907 today (clean). The single review thread (folder-workspace rows bypassing the visible-copy preference) is resolved — fixed in 608f23fe36 with red evidence and coderabbit's confirmation in-thread. Verification on the rebased head: use-pending-reveal.test.tsx + worktree-sidebar-reveal.test.ts pass 8/8, and both render-row-lookup suites (17 tests) stay green.

    @nwparker gentle ping — happy to adjust anything.

    ggbdpq ggbdpq commented on Oct 30, 2026 14:45 UTC
    Author

    Rebased onto current main (5f155d3df8) and force-pushed. One conflict area in worktree-sidebar-reveal.ts, resolved with both sides kept: upstream's revealCompactAgentCard relocation (#36080) and this PR's isElementVisibleInScrollContainer export both stay. One adaptation: upstream (#28942) removed WorktreeRow.lineageTrail, so the test fixtures drop that field.

    Verified after the rebase: worktree-sidebar-reveal / render-row-lookup / use-pending-reveal suites 18/18, typecheck:node, typecheck:web, and the max-lines ratchet all clean.

    @nwparker gentle ping — happy to adjust anything.

    Reviewers
    Assignees
    ggbdpq ggbdpq
    Labels
    risk: low confidence: 83.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55% (MEDIUM) · Higher = larger blast radius
    55%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.3% · Lower = rushed or shallow review
    83.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.2% · Safe to merge
    9.2%
    Repository