Skip to content

fix(source-control): open a folder repo card's Git Graph in the folder workspace - #49629

Merged
nwparker merged 1 commit into
stablyai:mainfrom
TuanNancy:fix/source-control-graph-placement
Nov 26, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
TuanNancy:fix/source-control-graph-placement

Conversation

@TuanNancy

@TuanNancy TuanNancy commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

In a folder workspace, each repo card in Source Control has a Graph button. Clicking it opened the Git Graph inside a hidden child workspace, so it looked like nothing happened. Now the graph opens where you clicked, in the folder's own tabs. Diffs you open from that graph also show up in the folder.

What Changed

  • Before: the Graph button (repo card header) and the Graph item (scope menu) on a folder repo card called openGitGraph(childWorktreeId). The tab went into unifiedTabsByWorktree[childId], which the folder workspace never shows.
  • After: the tab opens in the folder workspace, one Git Graph tab per repo card. It still reads the child worktree's history.
  • How it works:
    • openGitGraph(worktreeId, resolveTargetGroupId?, placementWorkspaceId = worktreeId) passes the placement to both the reopen path (openWorkspaceEditorItem) and openFile.
    • panel-ready.tsx and change-scope-bar.tsx pass useSourceControlScope()?.placementWorkspaceId. The scope is null outside folder sections, so non-folder worktrees behave exactly as before.
    • openWorkspaceEditorItem used to treat a git-graph tab as one per workspace, with the fixed id ${workspace}::git-graph. A graph file shown outside its own worktree now reuses only a tab for that same file and gets a normal tab id. Without this, the second repo card's Graph would activate the first repo's graph.
    • GitGraphTab works out its workspace from its tab id (editorTabWorkspace, the same lookup EditorFileTab uses) and passes it to useGitHistoryCommitActions. Commit diffs opened from a folder-placed graph (double-click, Open diff, a file row in commit details) therefore also land in the folder. The editor pane has no source control scope provider, so before this they fell back to the child.

Why

Row and note diffs already pass placementWorkspaceId from the source control scope (use-row-opening.ts, use-note-opening.ts). Graph was the one entry point that didn't. We follow that existing pattern instead of switching the user to the child worktree, which would pull them out of the folder view they're working in.

Linked Issue

Fixes #49597

Reported by @EvilArthas. Original fix by @TuanNancy in #49629; final version reworked during the bug bash. It now also handles several repo cards in one folder and folder-placed commit diffs.

Visual Proof

N/A. No visual capture was recorded for this fix: the local machine can't be used for Electron runs, and no capture exists from the remote runner. The change only affects which workspace's tab set receives the tab, and the store-level tests below check this against the real editor and tabs slices.

Testing

  • Repro: in a folder workspace with a child worktree (--parent-worktree), open Source Control and click Graph on the repo card. On main, the tab is created under unifiedTabsByWorktree[childId] and nothing visible happens.

  • New git-graph-tab.test.ts uses the real editor and tabs store with two child worktrees under folder:F.

    • It opens CHILD, then OTHER, then CHILD again. The folder gets exactly one graph tab per repo, the child's tab set stays empty, and reopening activates CHILD's tab.
    • A graph already open in the child, then opened from the folder, shares one OpenFile, and each tab resolves to its own workspace.
  • use-git-history-commit-actions.test.tsx: a folder-placed graph opens both the all-files commit diff and a single commit file with placementWorkspaceId: 'folder:F'.

  • Fails on main: with the source files reverted to main and the new tests kept, all 3 new tests fail. With only the openGitGraph change (and workspace-editor-item.ts reverted), the second repo's graph collapses onto the first.

  • Passes: vitest on git-graph-tab, use-git-history-commit-actions, change-scope-bar and git-graph-open-button passes, 28/28. Wider source-control, editor-tabs and graph consumer suites passed during review.

  • Static checks: oxlint (--deny-warnings, anti-slop and code-quality configs), oxfmt --check, ast-grep and the changed-code quality gate are clean on all 9 files.

  • Platforms: the logic is renderer-only store placement with no OS-specific paths or shortcuts. Tested with unit tests on macOS.

  • 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

Performance

There is no slowdown on any hot path. All work runs on a click, apart from one cached selector.

  • Graph tab selector: GitGraphTab adds one zustand selector, which is a hit in the shared WeakMap placement index plus a Map.get. It costs 0.014 us/op with 50 tabs and 0.019 us/op with 20k tabs. The index rebuilds only when unifiedTabsByWorktree changes, and EditorFileTab already builds and shares it, so this adds no rebuilds.
  • Graph open (click only): a graph open adds one openFiles.some scan. It costs 0.18 us with 50 open files and 60 us with 20k files (adversarial). Non-graph opens short-circuit on contentType === 'git-graph'.
  • There is no new I/O, subprocess, IPC, polling or subscription.

Risk

Level: Low.

  • Riskiest part: the crossWorkspace branch in openWorkspaceEditorItem. It applies only to git-graph content shown outside its own worktree. If it went wrong, a folder's Graph click would activate the wrong repo's graph tab.
  • Unchanged: non-folder worktrees, cmd-J, and SSH/WSL routing, which still comes from the child worktree through gitGraphScope(worktreeId).
  • Back out: a plain revert. No persisted data or settings formats change.

Review

Reviewed in two rounds during the bug bash. The second round added the folder-placed commit-diff fix and a typed test fixture.

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-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The source-control graph actions pass the scope’s placement workspace ID to openGitGraph. The graph opener uses that ID to find, reopen, or open a Git Graph tab. The editor passes the tab’s workspace ID to commit-diff actions. The worktree ID remains in use for repository and tab operations.

Severity of issue fixed: Medium

Merge Risk: Low · up to 4033a

Git Graph now opens in the workspace that shows the Source Control panel, and each child repository gets its own graph tab there. Two minor edge cases remain: a split-open is ignored when the graph is already open in the child workspace, and a pending diff load may still open after the folder's graph tab has been closed. Neither blocks the main flow, so the change is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Issue #49597 requires that Graph in a folder-workspace repo card opens Git Graph where the user is (the folder workspace), or switches to the child worktree. Earlier review of the openGitGraph path (s…
Out of Scope Changes check Passed The new changes since the previous review are tied to folder-placed Git Graph tabs. The commit message and the new test in use-git-history-commit-actions.test.tsx describe this follow-on behavior. The…
Title check Passed The title is specific and matches the main change. It fixes folder repo cards so Git Graph opens in the folder workspace instead of a hidden child worktree. The title uses the conventional commit form…
Description check Passed The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue (Fixes #49597), Visual Proof (N/A with a reason), Testing, Performance, Risk with level, AI D…
Full details: Linked Issues check

Explanation

Issue #49597 requires that Graph in a folder-workspace repo card opens Git Graph where the user is (the folder workspace), or switches to the child worktree. Earlier review of the openGitGraph path (src/renderer/src/lib/source-control/graph/git-graph-tab.ts) found that it accepts placementWorkspaceId, uses it as the placement for the existing tab lookup and for openFile, and keeps worktreeId as the child worktree for history. panel-ready.tsx and change-scope-bar.tsx pass the scope placement. The changes since the previous review add cross-workspace graph reuse in workspace-editor-item.ts, placement of commit-diff opens through use-git-history-commit-actions.ts, and tabId-based workspace lookup in GitGraphTab. These support the same objective: a folder-placed graph keeps its commit diffs in the folder workspace. I inspected workspace-editor-item.ts directly. The core #49597 path was not re-read at head in this review, so it relies on the previous evidence. No automated test covers the UI wiring; the issue does not require one. Manual or visual verification was not performed.

Full details: Out of Scope Changes check

Explanation

The new changes since the previous review are tied to folder-placed Git Graph tabs. The commit message and the new test in use-git-history-commit-actions.test.tsx describe this follow-on behavior. The workspace-editor-item.ts change applies only when a git-graph file is already open in a different worktree (crossWorkspace). In that case it reuses a graph tab only when entityId matches and skips the fixed tab ID. In the normal same-worktree case the condition is false and the previous behavior is kept. The PR description does not describe these store and reuse changes, and its claim that non-folder workspaces behave exactly as before is not fully confirmed for this shared path. This is a documentation and verification gap, not an unrelated change.

Full details: Title check

Explanation

The title is specific and matches the main change. It fixes folder repo cards so Git Graph opens in the folder workspace instead of a hidden child worktree. The title uses the conventional commit form and follows the 'fix(scope): summary' pattern. It is 80 characters, which is long but within a typical limit for conventional titles.

Full details: Description check

Explanation

The description follows the repository template closely. It includes ELI5, What Changed, Why, Linked Issue (Fixes #49597), Visual Proof (N/A with a reason), Testing, Performance, Risk with level, AI Disclosure section left as template, Review, upstream boundary checkbox, Notes, and Checklist. The Performance section gives measured numbers and reasoning. The Risk section names the riskiest branch and back-out path. The Visual Proof N/A reason is given. The Testing section lists the new tests and platform coverage. The main gaps are that the manual testing box is unchecked and the final lint/typecheck/test/build checkbox is unchecked, which the template allows if CI covers them. The AI Disclosure section was left as template text, and the 'Level' field is filled in. Overall the description is mostly complete.

  • 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

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be700d99-8eee-4fcb-9958-708236fd2369
Commits

Reviewing files that changed from the base of the PR and between 2f8456f and 72b94cf.

Files selected for processing: 3

  • src/renderer/src/components/right-sidebar/source-control/panel/change-scope-bar.tsx
  • src/renderer/src/components/right-sidebar/source-control/panel/panel-ready.tsx
  • src/renderer/src/lib/source-control/graph/git-graph-tab.ts

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

)
const placementId = placementWorkspaceId ?? worktreeId
const existing =
state.unifiedTabsByWorktree?.[placementId]?.find((tab) => tab.contentType === 'git-graph') ??

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.

Major · Functional Correctness · Heavy lift

Keep graph reuse specific to the requested child worktree.

If folder workspace P already contains child A's graph, clicking Graph for child B selects A's tab here. id becomes A's entityId. The existing-file branch then activates A's graph and returns, so the user still sees A's history.

Match the graph to the requested repository, not only contentType. Update openWorkspaceEditorItem as well: its repository-blind early return and workspace-only fixed tab ID also prevent distinct child graphs in P. Repeated opens for the same child must still reuse that child's graph.

…r workspace

In a folder workspace, the Graph button on a child worktree's repo card
created the Git Graph tab in the hidden child worktree's tab set, so
nothing visible happened. openGitGraph now takes the source control
scope's placement workspace, so the tab opens in the folder workspace
while still reading the child worktree's history. A folder can show one
graph tab per repo card, and commit diffs opened from a folder-placed
graph also land in the folder workspace.

Fixes stablyai#49597

Co-authored-by: VNATdev-ops <[email protected]>
@nwparker
nwparker force-pushed the fix/source-control-graph-placement branch from 72b94cf to 4033aa9 Compare November 26, 2026 08:57
@nwparker nwparker changed the title fix(source-control): place Git Graph tab in the visible scope fix(source-control): open a folder repo card's Git Graph in the folder workspace Nov 26, 2026

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Check whether the requesting graph tab remains open. · git-graph-tab.tsx:107

src/renderer/src/components/editor/git-graph/git-graph-tab.tsx:107
Minor · Functional Correctness · Quick win

Check whether the requesting graph tab remains open.

If the child graph and folder graph share an OpenFile, start a folder diff load and close only the folder graph before the load completes. The child graph retains the shared file, so this predicate returns true. The pending action then opens a folder diff after its requesting view has closed.

Check the originating tabId in the unified tabs store instead. A hidden but still-open tab must continue to pass the check.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: efe1cfd8-663c-4b36-94c6-4461af7702f7
Commits

Reviewing files that changed from the base of the PR and between 72b94cf and 4033aa9.

Files selected for processing: 9

  • src/renderer/src/components/editor/EditorContent.tsx
  • src/renderer/src/components/editor/git-graph/git-graph-tab.tsx
  • src/renderer/src/components/right-sidebar/source-control/panel/change-scope-bar.tsx
  • src/renderer/src/components/right-sidebar/source-control/panel/panel-ready.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/use-git-history-commit-actions.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/sync/use-git-history-commit-actions.ts
  • src/renderer/src/lib/source-control/graph/git-graph-tab.test.ts
  • src/renderer/src/lib/source-control/graph/git-graph-tab.ts
  • src/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts

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

const label = translate('gitGraph.title', 'Git Graph')
if (state.openFiles.some((file) => file.id === id)) {
openWorkspaceEditorItem(state, id, worktreeId, label, 'git-graph')
openWorkspaceEditorItem(state, id, placementWorkspaceId, label, 'git-graph')

@coderabbitai coderabbitai Bot Nov 26, 2026 •

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.

Minor · Functional Correctness · Quick win

Resolve the split target when creating a second workspace view.

If the child graph is already open but the folder graph is not, this branch creates a new folder tab without calling resolveTargetGroupId. A split-open therefore opens the graph in an existing group.

Skip the resolver only when the placement workspace already contains the matching graph tab. Otherwise, pass the resolved target group to openWorkspaceEditorItem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in follow-up PR #50017. The reuse path now passes the lazily resolved target group unless the matching graph tab is already in the placement workspace. The merged commit already addressed the companion finding about repository-specific reuse via crossWorkspace matching in openWorkspaceEditorItem.

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.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Follow-up PR status ==='
gh api repos/stablyai/orca/pulls/50017 --jq '{number,state,merged,merged_at,base: .base.ref,head: .head.ref,title,html_url}'
echo '=== Follow-up PR relevant patches ==='
gh api --paginate repos/stablyai/orca/pulls/50017/files --jq '.[] | select(.filename == "src/renderer/src/lib/source-control/graph/git-graph-tab.ts" or .filename == "src/renderer/src/lib/source-control/graph/git-graph-tab.test.ts" or .filename == "src/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts") | {filename,status,patch}'
echo '=== Original PR status ==='
gh api repos/stablyai/orca/pulls/49629 --jq '{number,state,merged,merged_at,base: .base.ref,head: .head.ref}'

Length of output: 2223


Script executed:

#!/bin/bash
set -u
echo '=== Changed files ==='
gh api --paginate repos/stablyai/orca/pulls/50017/files --jq '.[] | {filename,status,patch}'
echo '=== Editor item target-group handling at follow-up head ==='
gh api -H 'Accept: application/vnd.github.raw+json' 'repos/stablyai/orca/contents/src/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts?ref=followup%2Fgraph-tab-reuse' | rg -n -C 8 'openWorkspaceEditorItem|targetGroupId|crossWorkspace'

Length of output: 1804


Script executed:

#!/bin/bash
set -u
ast-grep outline src/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts --match 'openWorkspaceEditorItem' --view expanded
rg -n -C 12 'openWorkspaceEditorItem|targetGroupId|crossWorkspace' src/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts

Length of output: 5224


@TuanNancy The patch in #50017 passes the target group as described. The PR is still open, and I could not read its branch source to verify the full path. I’m not marking the finding as addressed yet.


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

Thank you for using CodeRabbit!

You are interacting with an AI system.

@TuanNancy

Copy link
Copy Markdown
Contributor Author

CI note: the only failing job is test shard node 24 4/24, in src/main/runtime/rpc/methods/orchestration/structured-workers/structured-worker-slow-start.test.ts ("stops reading as starting once the ceiling fails a start whose acquire never returns"). It expected starting but observed pending. That file and its dependencies are not touched by this PR; the other 23 shards plus typecheck, ratchets, code quality and localization passed. Locally pnpm check:changed passed 32/32. I cannot rerun the failed job without repo admin rights, so a maintainer rerun would be appreciated.

@nwparker
nwparker merged commit 3e22725 into stablyai:main Nov 26, 2026
97 of 100 checks passed
DoozyX added a commit to DoozyX/orca that referenced this pull request Nov 27, 2026
Merges stablyai/orca 7030f25 (320 commits) into fork main 3e499a0.

Conflict resolutions:
- Antigravity usage (stablyai#50137): upstream stops reading agy usage for account
  safety. Carried into the fork's per-account status bar: dropped the
  Antigravity usage menu, accounts prop and checked-item setup flag from
  AccountUsageDetailsMenu, StatusBarUsageArea, the controller and provider
  visibility (and its fork-retained test); the omp slot stays, including in
  the rate-limit full cycle and the usage-tracking doc.
- Lazy Zod schemas (stablyai#49897): took upstream's lazyZodSchema wrapping and kept
  the fork's ProjectGroupUpdate.claudeAccountId, the omp status-bar item and
  _ompStatusBarDefaultAdded, and the federated release receipt's
  currentOwnerDispatchId/terminalReleaseState. Fork-only omp usage and
  AccountHome schemas are now lazy too; baseline pruned. Feature-interaction schemas
  stay in the fork's feature-interaction-params.ts, now lazy too.
- Git graph: openGitGraph keeps the fork's options object (afterOpen) and
  takes upstream's placementWorkspaceId (stablyai#49629, stablyai#50017) as an option;
  callers and upstream's test use it. The fork's branches/tags dock passes
  the folder placement too (same bug as stablyai#49597), and it and the graph tab
  share a new useGitGraphRefsEpoch hook (keeps git-graph-tab under 400). Source control keeps the fork's
  branches/tags dock beside upstream's file-list header; fork git-graph
  rendering tests pass the new tabId.
- Claude background tasks: upstream skips ambient artifact monitors; the
  fork's monitored-work rows and untyped-row handling stay.
- Claude managed hook: local POSIX keeps the fork's runtime-home wrapped
  command; getPosixManagedEventHook takes the command, so upstream's
  PreToolUse timeout applies to both local and remote entries.
- local-worker-start: keep the fork's reminted pane handle (#29) and add
  upstream's retained-chat assertStarting and launch warnings.
- Mobile web bundle fence: keep the fork's 11.25 MiB (above upstream's
  11 MiB + 16 KiB).
- en.json: union of the fork's ProjectGroupSettingsDialog and upstream's
  AutoNameFailed keys.
- Skills: regenerate bundled guides (upstream's shared CLI paragraph), union
  the add-only digest ledger, regenerate manifest and sources.
- tracked-upstream-cache test: fixed far-future expiry instead of
  Date.now() for upstream's new wall-clock ratchet.

Claude-Session: https://claude.ai/code/session_01BPjp5wba1X5fDbTK4YStHM
dluxhu pushed a commit to dluxhu/orca that referenced this pull request Nov 27, 2026
…r workspace (stablyai#49629)

In a folder workspace, the Graph button on a child worktree's repo card
created the Git Graph tab in the hidden child worktree's tab set, so
nothing visible happened. openGitGraph now takes the source control
scope's placement workspace, so the tab opens in the folder workspace
while still reading the child worktree's history. A folder can show one
graph tab per repo card, and commit diffs opened from a folder-placed
graph also land in the folder workspace.

Fixes stablyai#49597

Co-authored-by: Neil <[email protected]>
(cherry picked from commit 3e22725)
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]: Graph button in a folder workspace repo card opens Git Graph in the hidden child worktree

2 participants