Repository navigation
fix(sidebar): stop background workspace creation from scrolling the sidebar - #11530
Conversation
…idebar Creating a workspace in the background still spawns its terminals, and the renderer treated "no presentation stated" as "point the user at this terminal" -- revealing (scrolling to) the owning workspace. Split adoption from surfacing with an explicit surfaceOwner flag: background worktree creates and worker dispatch adopt their tabs silently, while `orca terminal create` keeps its discoverability reveal.
Greptile SummaryThis PR fixes a sidebar-scrolling regression introduced by the background workspace creation path: when Orca spawned terminals for a background worktree, the renderer's default "absent
Confidence Score: 5/5The change is narrowly scoped — it adds a suppression flag that defaults to the existing reveal behavior, so any omission on a new call site silently falls back to the pre-existing safe path rather than breaking anything. All background terminal creation call sites are updated consistently, the absent-means-surface default is preserved throughout, and both directions (background creates suppress; explicit activations still reveal) are independently exercised by new unit tests verified to fail against the pre-fix code. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/runtime/orca-runtime.ts | Core runtime changes: adds ownerSurfacing helper, threads surfaceOwner: false through all background terminal creation paths (startup terminal, default tabs, setup pane, plain shell), and moves shouldActivate earlier in one method so it's available when constructing reveal payloads. |
| src/renderer/src/hooks/useIpcEvents.ts | Renderer: updates both onCreateTerminal and onRequestTerminalCreate handlers to gate shouldSurfaceOwner on surfaceOwner !== false, correctly keeping the "absent = reveal" default while suppressing for background creates. |
| src/main/window/attach-main-window-services.ts | IPC bridge: forwards surfaceOwner: false from the main-process payload to the renderer event only when explicitly set, preserving the absent-means-surface protocol across the IPC boundary. |
| src/shared/runtime-types.ts | Adds surfaceOwner?: false to RuntimeTerminalCreateBaseRequestPayload as a suppression-only flag; well-documented with a JSDoc comment explaining the absent-means-surface convention. |
| src/main/runtime/rpc/methods/orchestration-worker-topology.ts | Adds surfaceOwner: false to the worker dispatch createTerminal call, preventing orchestration worker creation from scrolling the sidebar to the worker's workspace. |
| src/renderer/src/hooks/ipc-events-test-harness.ts | Test harness: adds RequestTerminalCreateRequest type and requestTerminalCreate helper; types surfaceOwner as boolean (slightly looser than the production false-only type) — no production impact. |
Reviews (2): Last reviewed commit: "fix(sidebar): keep split-mode setup pane..." | Re-trigger Greptile
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds an optional 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime.ts (1)
19994-20051: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winSplit-mode Setup terminal doesn't respect
surfaceOwner: false.When
setupScriptLaunchModeissplit-vertical/split-horizontal, the Setup terminal is created viathis.splitTerminal(primaryTerminalHandle!, {...})(lines 20040-20046), which never receivessilent/surfaceOwner.splitTerminal's options type and itsrevealTerminalSessioncall (seesplitPtyBackedTerminal, ~lines 25278-25291) have nosurfaceOwnerfield at all — onlyactivate. During background (non-activated) worktree creation with this launch mode, the Setup terminal's reveal will still surface the workspace/sidebar (only its focus is suppressed viaactivate: false), which defeats the intent of this PR for that configuration.Thread
surfaceOwnerthroughsplitTerminal's options and itsrevealTerminalSessioncall the same waycreateTerminaldoes, and pass it from thisshouldSplitSetupbranch whensilent.surfaceOwner === false.🐛 Proposed fix sketch
const setupTerminal = await (shouldSplitSetup ? this.splitTerminal(primaryTerminalHandle!, { direction: setupLaunchMode === 'split-horizontal' ? 'horizontal' : 'vertical', command: setupCommand, env: setupEnv, - activate: false + activate: false, + ...silent })(plus adding
surfaceOwner?: booleantosplitTerminal's opts type and forwarding it into therevealTerminalSessioncall insplitPtyBackedTerminal.)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 84f9209d-b0ce-4c1d-bf5d-ebf458c074cc
📒 Files selected for processing (11)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/orchestration-worker-topology.tssrc/main/runtime/rpc/methods/orchestration.test.tssrc/main/window/attach-main-window-services.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/hooks/ipc-events-test-harness.tssrc/renderer/src/hooks/useIpcEvents.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/shared/runtime-types.ts
| ...(opts.viewMode ? { viewMode: opts.viewMode } : {}), | ||
| activate: opts.activate !== false, | ||
| ...(opts.presentation ? { presentation: opts.presentation } : {}), | ||
| ...(opts.surfaceOwner === false ? { surfaceOwner: false } : {}), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Forward surfaceOwner through the notifier-based create path.
surfaceOwner: false is added only to the revealTerminalSession payload at Line 405. The sibling setNotifier().createTerminal callback still omits it at Lines 339–347. Because the worker path now passes surfaceOwner: false to runtime.createTerminal, this can reach the renderer as undefined, causing surfaceOwner !== false to reveal and focus the worker workspace.
Mirror the conditional spread in the first ui:createTerminal payload.
Proposed fix
title: opts.title,
...(opts.presentation ? { presentation: opts.presentation } : {}),
+ ...(opts.surfaceOwner === false ? { surfaceOwner: false } : {})
}),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ...(opts.surfaceOwner === false ? { surfaceOwner: false } : {}), | |
| title: opts.title, | |
| ...(opts.presentation ? { presentation: opts.presentation } : {}), | |
| ...(opts.surfaceOwner === false ? { surfaceOwner: false } : {}), |
|
Good catch — confirmed and fixed.
Threaded |
|
On the
The worker path calls The split-mode Setup gap from the other comment was real and is fixed, with a regression test. |
Review catch: with setupScriptLaunchMode split-vertical/horizontal the Setup terminal goes through splitTerminal, whose reveal payload had no surfaceOwner, so a background create still scrolled the sidebar in that configuration. Also narrow surfaceOwner to `false` so "surface it" can only be expressed by omitting the key, and fold the repeated conditional spreads into ownerSurfacing.
…idebar (stablyai#11530) * fix(sidebar): stop background workspace creation from scrolling the sidebar Creating a workspace in the background still spawns its terminals, and the renderer treated "no presentation stated" as "point the user at this terminal" -- revealing (scrolling to) the owning workspace. Split adoption from surfacing with an explicit surfaceOwner flag: background worktree creates and worker dispatch adopt their tabs silently, while `orca terminal create` keeps its discoverability reveal. * fix(sidebar): keep split-mode setup panes silent, tighten surfaceOwner Review catch: with setupScriptLaunchMode split-vertical/horizontal the Setup terminal goes through splitTerminal, whose reveal payload had no surfaceOwner, so a background create still scrolled the sidebar in that configuration. Also narrow surfaceOwner to `false` so "surface it" can only be expressed by omitting the key, and fold the repeated conditional spreads into ownerSurfacing.
Description
Follow-up to #11445. That PR stopped background workspace creation from stealing the user's selection. The sidebar still scrolled by itself, because the scroll comes from a different signal.
Adopting a terminal and pointing the user at it were the same decision. This separates them with a
surfaceOwnerflag, and every background path now adopts silently.ELI5
Creating a workspace in the background should be like a coworker quietly filing a new folder in the cabinet behind you. Orca was tapping you on the shoulder and turning your chair toward the cabinet — not far enough to change what you were working on, but far enough to lose your place in the list.
Under the hood: a background create still has to start that workspace's terminal. When Orca handed that terminal to the UI it said nothing about how to present it, and "said nothing" was read as "show it to the user" — so the sidebar scrolled. #11445 stopped the chair from turning all the way; this removes the shoulder-tap.
Now a background create explicitly says "adopt this terminal silently": the tab is still created and the agent still runs, but the sidebar stays where you left it. Terminals you actually ask for still reveal themselves as before.
Root cause
A background create still spawns the new workspace's terminals via
OrcaRuntimeService.createTerminal, which asks the renderer to adopt the PTY throughnotifier.revealTerminalSession(...).No worktree-create call site passed a
presentation, soresolveTerminalPresentationreturnedundefined. Every downstream check ispresentation !== 'background'— true forundefined— and the renderer mirrored it:So "no presentation stated" meant "point the user at this terminal". That default is right for
orca terminal create, where discoverability is the entire point — the runtime even returns a warning when the reveal fails. It is wrong for terminals the user never asked for.presentation: 'background'could not express this: it means "do not adopt the terminal in the renderer at all", which would leave the new workspace with no tab for its agent.Version boundary
shouldSurfaceOwnerarrived in #6686 (Jun 28), which decoupled "surface the owner" from "activate". Before it the reveal was gated on activation, so a non-activating create could not scroll the sidebar. #11445 fixed the activation half; this fixes the surfacing half.Design
surfaceOwneris typed?: false, not?: boolean— absent means "surface it", so the flag is a suppression switch andtrueis unrepresentable. One way to express each intent.surfaceOwner: falseis passed from every background path: the agent/startup terminal, the plain initial shell, the Setup tab (both new-tab and split-pane placement), default tabs, and orchestration worker dispatch. It is threaded throughcreateTerminalandsplitTerminal. Explicitly activated creates omit it.No new CLI/RPC surface:
surfaceOwneris main-internal and absent from theterminal.createRPC schema, so callers cannot set it.Proof of regression
Tests were written against the fix, then run with the production change reverted.
Main process — reverting only the
surfaceOwner: falsearguments at the worktree-create call sites, leaving the forwarding machinery intact:The no-regression pair bites in the opposite direction — replacing
...ownerSurfacing(shouldActivate)with an unconditionalsurfaceOwner: false:Split-mode Setup (the review catch below) is wired to both halves of its fix independently — removing either the
...surfacingspread in theshouldSplitSetupbranch or the...ownerSurfacing(...)insplitPtyBackedTerminalproduces:Renderer — reverting each handler's guard fails only its own test, so both code paths are independently covered:
Proof of fix
src/relay/agent-exec-handler.test.ts(2 tests), reproduces identically on a clean tree at37af4577and is unrelated.pnpm run typecheck:node,pnpm run typecheck:web: passed.pnpm run check:code-quality:changed: 0 new findings across 11 files.pnpm run check:max-lines-ratchet,pnpm run verify:bundled-skill-guides: passed.oxlint+oxfmt --checkclean on all changed files.Proof of no regression
orca terminal createstill reveals its workspace — nosurfaceOwnerin its payload, and the pre-existing assertion is untouched. Each new renderer test also runs a control phase asserting the default still reveals.--activateand legacy--run-hooksstill reveal, in both new-tab and split Setup placement; four tests assertsurfaceOwneris absent from the reveal payload.createTabis called with the pre-minted tab id, so the agent tab exists when the user opens the workspace.presentation: 'background'semantics are untouched;surfaceOwneris a separate axis.focusTerminalInitiatedTabfor background creates, removing a second latent focus-steal on a workspace the user is not viewing.Review notes
setupScriptLaunchMode: split-vertical|split-horizontalthe Setup terminal goes throughsplitTerminal, whose reveal payload had nosurfaceOwner— a real gap, now fixed and tested. The non-PTY split path is unaffected:notifier.splitTerminalonly dispatches a rendererCustomEventand never reveals.notifier.createTerminalwas also flagged, but it is unreachable —grep -rn "notifier\.createTerminal" src/main(excluding tests) returns nothing. The worker path calls theOrcaRuntimeService.createTerminalmethod, which routes throughrevealTerminalSession. Threading the flag there would mean widening the notifier type for a path nothing calls.Known second cause (not in this PR)
While investigating I reproduced a second, independent cause of sidebar self-scrolling: creating a child worktree makes
buildRenderableRowscollapse the parent and its children into onelineage-grouprow, which rewrites the parent's scroll-anchor key. If that parent was the top-visible row,runVirtualizedScrollAnchorRestorecannot find the old key and pins a different row to the top — a measured +180 px jump with no reveal involved. It is long-standing rather than RC-new, needs the anchored row to be exactly that parent, and is being handled separately.