Skip to content

refactor(terminal): move a dragged-out pane in main before the window opens its tab - #25380

Merged
Jinwoo-H merged 34 commits into
mainfrom
terminal-topology-b1-2-move-leaf
Oct 7, 2026
Merged

Jinwoo-H merged 34 commits into
mainfrom
terminal-topology-b1-2-move-leaf

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​949 $\color{#cf222e}{\Huge{\mathbf{−}}}$​141 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​808
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​905 $\color{#cf222e}{\Huge{\mathbf{−}}}$​74 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​831

ELI5

When you drag a pane out of a split into its own tab, the app window used to rearrange its own notebook of "which pane shows which terminal" and tell main afterwards, one field at a time. After a restart, main's notebook could still list the pane in its old tab, so one terminal showed up in two tabs and one of them froze (Linear STA-9259).

Now the window asks main to move the pane first. Main moves it in one step, and the window then opens the tab.

Builds on #25329 (merged).

What Changed

  • Drag to tab strip → moveLeaf in main first. Main moves the leaf, its terminal binding and every record keyed by that pane, in every saved partition (local, SSH, runtime) in one write through the terminal layout module from refactor(terminal): one commit module for terminal topology closes, with a boundary check #25329. Those records are: incarnation, sleeping session, remote session id, UI marks, SSH lease, agent-status alias and orchestration worker resources. Only then does the window open the new tab.
  • Refused or failed move: shows "Couldn't move the pane to a new tab." and the pane stays where it was. There is one attempt and no retry.
  • After main has moved it, the window only rolls forward. If the pane or its source tab was closed in the meantime, the new tab closes through the normal close path, so no ghost tab is left. If a sibling closed and the moved pane is now the last one, the new tab keeps the pane and its terminal, and the source tab closes without killing it.
  • A pane whose terminal is still starting can't be dragged out yet (a silent no-op, like today's pending-cwd case). Otherwise the late start result would bind it back into the source tab.
  • One existing-behavior shift: the move bumps the repo's topology revision. A repo with no earlier main-side layout write therefore starts using main's rebased membership on its first drag-out, exactly as any repo already past revision 0 does today.

Why

This is the second step of making main the only writer of terminal layout (see #25329). Drag-out was the main writer that changed layout from the window side. Moving it into one main-side step closes the STA-9259 path at its source instead of patching the restore.

An earlier version undid the window change when main refused. Review found that undo could not be made exact: it left ghost tabs, missed in-flight spawns and lost the pane if a sibling closed. Asking main first and only rolling forward is simpler and has no partial states.

Linked Issue

Maintainer PR. Context: Linear STA-9259, STA-9417.

Visual Proof

N/A. A drag looks the same; the fix shows after a restart (one terminal no longer appears in two tabs). This is covered by the live checks below.

Testing

  • pnpm tc, oxlint and check:code-quality:changed pass on the final commit. The B1-2 test files pass (8 files, 75 tests), and the related suites ran 10,414 passing and 0 failing.

  • Live, local, final build, real drags with output flowing:

    • 4/4 drags, each still correct after 2 restarts.
    • A sibling closed at the same instant: 2/2 kept the moved pane alive, also after restarts. The test for this fails on the previous commit.
    • The source tab closed at the same instant: 2/2, no ghost tab.
    • Dragging a pane whose terminal is still starting: refused 2/2.
  • SSH (Docker relay end-to-end), on the build just before the last-pane fix: 3/3. The flow was restart → move → 2 restarts, with output and a single owner each time. The final commit only changes the last-pane and retry paths.

  • Latency of the main-side move: p50 1.3 ms and p95 1.7 ms over IPC, on a copied 79-tab profile.

  • Parity check against main (test(e2e): terminal layout parity check against main #25681, real app, 9 scenarios): 8 identical. The drag-out-to-tab scenario (real mouse drag, then two restarts) ends with the same tabs, panes and terminal bindings as main; the only differences, on every run, are two internal bookkeeping fields. Main's move now saves the pane incarnations and terminal layout revision at the moment of the drag, so they are present at quit (main only writes them after the first restart) and the revision counter reads 1 instead of 2 after restarts.

  • I manually tested these changes locally

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

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • No change to the saved session format or wire protocols. Remote hosts keep their existing behavior.
  • Known limit: if the write throws with an unknown outcome, persistence is already faulted. The window keeps the pane, and the next load converges on whatever main saved.
  • Carried to the next PR: the binding checks that make a skipped move fail loudly.

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)

…s into terminal-topology

advanceTerminalTopologyRevision, findTerminalTabIdForLeaf and
hasHostAuthoritativeTerminalMembership move verbatim from the renderer-save
membership rebase into persistence/terminal-topology, the home of the commit
boundary. Importers are repointed; no behavior change.
…t boundary

The three session sinks now publish through one commitWorkspaceSessionPartition
helper, which hands the prior and published partition to the topology write
guard. Production never arms the guard, so each sink pays one global lookup.

The unit suite arms it in report mode: a sink write that changes class-(a)
topology (membership, root, bindings, titles, incarnations, sleeping records,
remote session ids, tombstones, default-applied, revision) outside a commit
scope is attributed to its writer's file by stack, and fails the test unless
the writer is on the unrouted-writers allowlist that later routing PRs shrink.
Renderer saves and test seeding are exempt. Deep-freeze is available but stays
off suite-wide until the in-place writers return new sessions.
…seLeaf and closeTab

terminal-topology-commit.ts is the boundary for class-(a) terminal topology.
bindLeaf forwards to persistPtyBinding, whose write now runs in a commit
scope; the spawn commits and the relay reattach bind through it. closeLeaf and
closeTab wrap the existing close mutation in a commit scope and one
persistence.terminal-topology span (kind, outcome, refusal reason; no ids),
and the runtime close goes through them. Session output is unchanged: tests
compare it byte for byte with the old writers for local, ssh: and folder
workspaces.
…root

The guard read a frame's file through its last /src/ segment, so a test under
tests/ (folder-upgrade-identity-persistence.unit.test.ts) had no source frame
and failed as an unknown writer. Frames are now taken relative to the repo
root the setup passes in, tests/ counts as test seeding, Windows backslashes
are normalized before the node_modules skip, and nested src/ paths keep their
full path. The two runtime funnel files skip only their funnel function, so
another writer in them still shows. The R9 allowlist key names the file whose
frame actually writes. The class-(a) diff and the attribution move into their
own files; the stack limit is restored in a finally.
…he boundary ratchet

bindLeaf and the commit scope inside persistPtyBinding changed nothing: the
binding write never reaches a session sink, and a scope inside the Store method
would have admitted every direct caller once it did. Both return in B1-4; the
spawn commits and the relay reattach call persistPtyBinding directly again.

The runtime close now calls one closeLeafOrTab entry, so its callbacks keep
their contextual types. A census test is the primary enforcement: only
persistence/terminal-topology and the callers it lists may call
persistPtyBinding, the session setters or the three sinks, and every
unrouted-writer allowlist entry must name an existing file.
Under happy-dom the global URL is not Node's, so fileURLToPath(new URL(...))
threw in the setup file and failed every happy-dom test file.
… tab mounts

Ported from fix/terminal-topology-stage-a (1bafc87, 3941bd4, 2ea2070, 3e79f31,
a9d428e minus the bridge comment) and exposed as the commit module's moveLeaf,
which runs inside the topology commit scope and span and publishes every
rewritten partition through the session sink, so the test-only write guard sees
it. Store.moveTerminalLeafToNewTab only hands it the store's state.

Detach-to-new-tab now asks main first: the leaf and its binding move into the
new tab in every owner partition (local and ssh:), with the incarnation,
sleeping session, remote session id, UI marks and SSH lease, and the topology
revision bumps. pty:moveLeafToNewTab then aliases the agent-status pane key and
re-keys orchestration worker resources; the renderer's repeat transfer is
skipped. A refused or failed move toasts and the pane stays; a move the
renderer cannot apply is undone (STA-9259).

Stage A review-2 fixes:
- SF1: an undo whose source tab has closed retires the moved tab instead of
  refusing, so no ghost tab comes back on restart.
- SF2: an undo restores the split direction, ratio and position, the source
  tab's PTY id and its SSH remote session id, from origins main kept for the
  move; it never adds a second copy of a leaf the source holds again.
- N1: layouts of tabs that no longer exist do not refuse a move.
- N2: an undo into a tab that gained a pane is refused as target_changed,
  not a silent not_held.
- N3: a repeat drop of a pane whose move is still committing is a no-op.

Note: the move bumps the topology revision, so a revision-0 repo enters
rebased membership on its first detach.
…copies

- An undo ignores a target layout whose tab row is gone, as the move does.
- A retired undo leaves UI marks and SSH leases on the moved pane key instead
  of re-keying them to the closed source tab.
- When an SSH respawn bound one partition before the other caught up, the move
  follows the renderer's live PTY id and drops the stale copy's incarnation
  instead of refusing with a toast.
- A test pins the late-spawn graft the renderer's in-flight guard exists for.
…in holding it

- A pane whose PTY spawn is still in flight is not dragged out (no toast):
  the late spawn result would bind it to the source tab and graft the leaf
  back beside its moved copy. The IPC transport reports a pending connect.
- A thrown or timed-out commit (10 s bound) sends an undo, since the write may
  have landed; undo answers not_held when nothing moved. The in-flight entry
  clears with it, so a stalled main cannot wedge the pane's drag.
- A throw while opening the new tab after the pane left its source undoes the
  move too.
- No "stays where it was" toast when the undo found the source tab closed or
  the source pane is gone; a failed undo says the pane may open in a new tab
  after a restart instead.
…main's undo

If opening the moved pane's tab throws after createTab ran, the renderer now
closes that tab without killing its PTY or telling main (main never had it),
and restores the source layout, while main undoes the move.
…ry ratchet enforces

The AST boundary ratchet is the enforcement for B1. The stack-attributed
runtime guard, its class-(a) diff, the unrouted-writer allowlist, the vitest
setup and the freeze option are removed; it saw two writers in the whole unit
suite and its real value starts only once binding reaches a sink (B1-4).

Also: one closeLeafOrTab wraps the close in the span (no per-kind copies or
narrowed types), the span has one finish like persistence.pty-binding, the
sink helper is publishWorkspaceSessionPartition (it publishes; the commit
boundary is the module), the ratchet drops the private publishSession row and
checks that every listed caller file exists, and the close comparison keeps
its two meaningful cases with span cases chosen by name.
# Conflicts:
#	src/main/persistence/terminal-topology/terminal-topology-commit.ts
Once main commits a pane move, the renderer only rolls forward:
- A repeat of a committed move answers moved and writes nothing, so a thrown
  commit (outcome unknown) is retried, up to three attempts; the IPC skips
  the agent-status transfer it already made.
- The renderer applies the move by leaf id. If the user closed the pane or
  its tab meanwhile, it closes main's new tab through the ordinary
  session:close-terminal-surface path; if a sibling closed and the pane is
  the source's last, the source tab closes without killing the PTY.
- One toast, for a move main refused or never answered.

Deleted: the undo planner, origin ledger, undo flag, retired and
target_changed results, the commit timeout, the half-opened-tab cleanup and
the second toast.

Also: one request validation (distinct tabs, stable leaf id, tab ids a pane
key can carry, built through makePaneKey); a two-line PTY check where the
live PTY id wins; the move and close share one span wrapper; the moved tab's
layout always takes the live PTY id (a stale saved id was kept before);
fallbackPtyId is now livePtyId; tests are organized by behavior.
…hey enforce

- Point the acknowledged-tab-retirement audit fixture at the moved
  advanceTerminalTopologyRevision; its old import no longer resolved.
- Drop publishWorkspaceSessionPartition: it was the removed guard's
  interception point, so the three session sinks return to origin/main.
- One traced(kind, mutate) wrapper in the commit file replaces the span
  factory; closeLeafOrTab is one call.
- The ratchet walks src/main with the shared scanSourceTree, drops the
  loading-store-internal rows and the redundant file-exists test; exact-set
  equality already fails on a missing file.
- The commit test is a pure unit test of the span outcomes: no Store
  harness, electron mock or self-comparing close.
# Conflicts:
#	src/main/persistence/terminal-topology/terminal-topology-commit.ts
#	src/main/persistence/terminal-topology/terminal-topology-write-span.ts
…attempt

A sibling closed while main committed the move persists the source layout
down to the moved leaf, so the renderer took that for "pane gone" and
closed main's new tab while the pane was live: after a restart it was held
nowhere. The renderer now reads the store layout: when the moved leaf is the
only one left it opens the new tab with that layout, syncs PTY ownership,
and closes the source tab without killing the PTY. Main's new tab is closed
only when main moved the pane and it is gone here.

Also:
- One commit attempt; the repeat answer, the retry loop and the IPC alias
  guard never ran in production (a write with an unknown outcome faults the
  writer, so every retry rethrows before it reaches the move).
- traced takes a typed refusalOf; one write-and-restore helper and a shared
  partition assign replace the duplicated local/remote and rollback checks.
- The planner's holders carry their source tab and layout, so the partition
  move cannot fail; pane-keyed UI marks are re-keyed in one loop; the request
  validator calls makePaneKey directly.
- applyMove looks the pane up once and takes one PTY id (main's when it moved
  the pane); the move-commit file is inlined; duplicated renderer tests are
  removed and the commit-path tests live together.
@Jinwoo-H
Jinwoo-H requested a review from brennanb2025 as a code owner October 5, 2026 03:15

@pullfrog pullfrog 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.

Important

One latent owner-cleanup gap in the new main-side move: a layout of a removed tab that still names the moved leaf is neither moved nor cleaned, and findTerminalTabIdForLeaf will resolve the pane to that dead tab after the move. Details inline.

Reviewed changes

  • New move contract — src/shared/terminal-leaf-move.ts adds TerminalLeafMoveRequest/TerminalLeafMoveResult, isTerminalLeafMoveRequest validation, and pane-key derivation.
  • Main commits the move first — pty:moveLeafToNewTab → commitLeafMoveAndRekey → moveTerminalLeafToNewTab → moveLeaf → planTerminalLeafMove, moving the leaf, its binding, and every pane-keyed record across all local/SSH owner partitions in one durable mutation with rollback.
  • Post-commit re-key — agent-status alias (transferPaneAuthority, verified) and orchestration worker-terminal pane_key.
  • Renderer rolls forward — detachTerminalPaneToTab mints the target tab id, awaits main, then applies locally; refusals show the failure toast, concurrent pane/tab closes close main's new tab, and a last-pane move closes the source tab without killing the PTY.
  • Dedup guards — isPaneAuthorityTransferredTo skips a repeat transfer; isConnectPending blocks dragging a pane whose spawn is in flight.
  • Tests — 8 files covering the STA-9259 sequence, dual-partition SSH, concurrent closes, the topology span, and the renderer commit/roll-forward paths.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +102 to +107
if (remainingLayout) {
terminalLayoutsByTabId[sourceTabId] = remainingLayout
} else {
// Its sibling was never bound here; the sibling's own binding mints the layout again.
delete terminalLayoutsByTabId[sourceTabId]
}

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.

moveLeafInPartition rewrites only the source and target layouts, so any other layout in the same session that still contains leafId keeps it. Since planTerminalLeafMove deliberately does not refuse on a layout whose tab row is gone (leafElsewhere only considers live tabs), that stray layout stays a second owner — and the target entry is appended last, so after the move findTerminalTabIdForLeaf (which walks every layout, live or dead) can now resolve the moved leaf to the removed tab instead of the target.

A relay reattach for the moved pane then fences to that dead tab (restoreReattachedPtyRuntime at src/main/ssh/ssh-relay-session.ts:2937), producing exactly the ghost-tab/lost-pane class this PR is meant to close. The PR's own planTerminalLeafMove test builds this input ("a stray layout of a removed tab still names") but only asserts planned.result, so the leftover layout is untested.

Technical details
# A moved leaf can keep a second owner in a removed tab's layout

## Affected sites
- `src/main/persistence/terminal-topology/terminal-leaf-move.ts:102-107` — `moveLeafInPartition` rewrites only `terminalLayoutsByTabId[sourceTabId]` / `[targetTabId]`; other layouts naming `leafId` are untouched.
- `src/main/persistence/terminal-topology/terminal-leaf-move.ts:159-171` — `leafElsewhere` intentionally ignores layouts whose tab row is gone.
- `src/main/persistence/terminal-topology/terminal-topology-membership.ts:35-49` — `findTerminalTabIdForLeaf` matches the first layout containing the leaf, with no liveness check; `Object.keys` order leaves `[targetTabId]` last.
- `src/main/ssh/ssh-relay-session.ts:2936-2961` — relay reattach resolves `tabId` through `findTerminalTabIdForLeaf` before falling back to the lease.

## Required outcome
- After a committed move, `leafId` names exactly one layout per owner partition (or the resolver skips layouts whose tab row no longer exists).

## Suggested approach (optional)
- Strip `leafId` from every other layout in the session when building the target (e.g. delete it from each non-source/non-target layout that contains it), keeping the existing tab-liveness exemption for refusal. Alternatively, make `findTerminalTabIdForLeaf` ignore layouts without a matching `tabsByWorktree` row — but that changes a shared resolver used by relay and headless reconcile, so the move-side cleanup is the narrower fix.

## Open questions for the human
- Is a layout that outlives its tab row actually reachable in the field? The `leafElsewhere` comment and the `planTerminalLeafMove` test assume it is; if it can only arise from prior corruption, a documented invariant may be enough.
- Same class, across partitions: `holders` requires the source tab row AND the source layout, and `leafElsewhere` excludes `sourceTabId`. A partition with the source layout but no source tab row is neither moved nor refused, so it can keep the moved leaf while another partition moves it.

… drop stage ids from comments

The controller's setter was named set, which the boundary census could not
list without matching every Map.set, so a new OrcaRuntime mixin could write
sessions through it unseen. Rename it setForWorktree and census it.
Comments now describe state instead of citing plan stage ids.
…llback

- traced() takes refusalOf instead of assuming an Error refusal, and only
  mutate() sits in the try, so a span outcome of threw means the write threw.
- The boundary ratchet counts references, not just direct calls: non-null
  calls, bracket keys, aliases, destructures, .call/.bind and parenthesized
  callees all count; declared names and type positions do not.
- Census terminalSurfaceCloseMutation (boundary-only) and the partition sinks
  setLocalWorkspaceSession / setHostWorkspaceSession.
…ns, skip type-only imports and local declarations

The census skipped ExpressionWithTypeArguments as a type, which also holds
`extends f(x)` and `x<T>` value expressions. Type-only import/export
specifiers and declared names (variables, parameters, accessors, enum
members) no longer count as uses. The audit fixture is listed in the table
instead of a separate exemption.
…inition

Telling definitions from uses per syntax kind kept missing nested and
for-of destructures. Exempt only the writer's own function or class-member
definition; any other mention (including object-literal keys) counts, so the
census errs toward a loud false alarm rather than a silent miss. Quoted names
count only in member-name position.
Member-name positions missed wrapped keys like store[('name')] and
store['name' as const]. Counting every string literal outside types is
shorter and errs toward a loud false alarm.
…initions

Object-literal methods and accessors were exempt while equivalent arrow
properties counted; all object-literal keys now count alike.
A name spelled with a \u escape never appears verbatim, so the text
prefilter skipped it.
\x, identity and line-continuation escapes also decode to a writer name
without it appearing verbatim.
@Jinwoo-H
Jinwoo-H changed the base branch from terminal-topology-b1-1-commit-module to main October 5, 2026 17:39
…1-1-commit-module' into refactor/terminal-topology-b1-2-move-leaf

# Conflicts:
#	src/main/persistence/terminal-topology/terminal-topology-commit.ts
…ology-b1-2-move-leaf

# Conflicts:
#	src/main/persistence/terminal-topology/terminal-topology-commit.ts
#	src/main/persistence/terminal-topology/terminal-topology-membership.ts
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89980915-cb73-424c-b9b0-15bdad0a24ad
📥 Commits

Reviewing files that changed from the base of the PR and between 4623647 and 6419814.

📒 Files selected for processing (5)
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/preload/api/pty-api.ts
  • src/preload/api/pty-bridge-session-control.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

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


📝 Walkthrough

Walkthrough

The change adds a terminal-leaf move request contract and persists moves across local and SSH session partitions. A new PTY IPC route invokes the durable move and then reconciles agent pane authority and worker terminal resources. Renderer detachment now runs asynchronously, sends the live or persisted PTY ID, and applies the main-process result. The renderer also tracks pending PTY connections. Tests cover move validation, persistence, restart and close scenarios, IPC reconciliation, and detachment behavior.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 64198

No identified issue blocks merging these changes after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 46236

The main-first move improves saved-layout consistency, but the new request can promote an unverified terminal association into trusted pane ownership. Recovery of related ownership records is also not fully established.

Retained concerns

  • Medium · security · observed: The new move path promotes persisted layout membership into verified pane/PTY authority without the current-ownership proof required by the existing authority-transfer IPC. When a held leaf has no saved PTY bindings, the planner accepts any syntactically valid requested PTY ID, then the handler transfers authority with authorityVerified=true. This creates trusted associations from renderer-supplied evidence; downstream impact beyond ownership and alias integrity is not established.
Security review details

Security Blast Radius

  • inferred — The demonstrated scope is the active profile's held terminal leaves, matching owner partitions, pane aliases, and associated worker-resource records. Exercising the path requires access to the renderer bridge and valid source identifiers. Evidence does not establish cross-tenant, separate-environment, or credential exposure.

Security Findings and Attack Paths

  • inferred — A renderer caller can submit an unbound held leaf with a chosen PTY ID. The planner's mismatch check does not reject that case, and successful completion mints a verified alias. That association can subsequently satisfy alias-based authority checks without proving that the source pane owns the named process. Actual takeover of another process or its credentials has not been demonstrated.

Trust Boundaries and Controls

  • observed — Main rejects malformed requests, existing target tabs, leaves held in another live tab, and PTY mismatches against nonempty saved bindings. Non-moved outcomes return before authority or worker rekeying. These are topology controls, not current process-ownership proof; the existing authority IPC separately requires canTransferPaneAuthority.

Resilience and Maintainability Implications

  • observed — Authority and resource follow-ups may fail after the profile move and still return moved. Alias persistence is scheduled separately, and worker rekey exceptions leave the resource at its prior key. Existing release checks retain resources when identity is unproven rather than proceeding with a terminal stop. The baseline lacked the new worker rekey, so this residual consistency risk is not by itself evidence of a newly introduced unsafe-close path.

Hardening Proposals

  • proposed — Separate permission to move persisted layout from permission to verify process authority. Require current PTY ownership or a previously verified association before promoting an alias; an unbound move should not authenticate a caller-supplied PTY.
  • proposed — Make post-commit alias and resource convergence explicitly recoverable, for example through durable pending work or reconciliation keyed by stable leaf and process identity. This would strengthen crash recovery without reversing an already committed layout move.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 29 files. (1 skipped:… 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 summarizes the main change: main moves a dragged-out terminal pane before the window opens its new tab.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, provides testing details, and marks visual proof as not applicable with a reason. The linked-issue guidance allows main…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 32.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 29 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@pullfrog pullfrog 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.

ℹ️ No new issues in this update — the commits since the last review are a merge-up, so the prior finding (still open) is the only thing standing between this and an approval.

Reviewed changes

  • Merged B1-1 and main into B1-2 — terminal-topology-commit.ts (both merges), terminal-topology-membership.ts, and a comment in terminal-leaf-move.test.ts were conflict-resolved; the result keeps B1-1's traced (refusals traced by callback) and membership helpers alongside B1-2's moveLeaf/commitLeafMove.
  • Move behaviour unchanged — the PR-authored move path (terminal-leaf-move.ts, ipc/pty/ipc/leaf-move.ts, moveTerminalLeafToNewTab, renderer detachTerminalPaneToTab) is byte-identical to the previously reviewed head, so there is no new production surface to re-review.
  • Census commits are B1-1's, already on main — the 9 writer census commits belong to #25329 and are not new B1-2 authored work; terminal-topology-boundary-ratchet.test.ts stays out of the PR diff for the same reason.

The prior review's open thread on terminal-leaf-move.ts (a removed tab's layout can keep a second owner of the moved leaf, and findTerminalTabIdForLeaf walks it) is untouched by these commits, so it remains open and I am not approving yet.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0aa92488-9656-4bfc-89e5-69949623c19a
📥 Commits

Reviewing files that changed from the base of the PR and between 2a68ea9 and 6bb3ea2.

📒 Files selected for processing (27)
  • src/main/agent-hooks/server-pane-authority.test.ts
  • src/main/agent-hooks/server/server-authority-aliases.ts
  • src/main/ipc/agent-pane-authority-ipc.ts
  • src/main/ipc/pty/ipc/leaf-move.test.ts
  • src/main/ipc/pty/ipc/leaf-move.ts
  • src/main/ipc/pty/register-handlers.ts
  • src/main/persistence/loading-store/pty-binding-persistence.ts
  • src/main/persistence/terminal-topology/terminal-leaf-move-concurrent-close.test.ts
  • src/main/persistence/terminal-topology/terminal-leaf-move-fixture.ts
  • src/main/persistence/terminal-topology/terminal-leaf-move.test.ts
  • src/main/persistence/terminal-topology/terminal-leaf-move.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts
  • src/main/persistence/terminal-topology/terminal-topology-membership.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-resource-store.ts
  • src/preload/api/pty-api.ts
  • src/preload/api/pty-bridge-session-control.ts
  • src/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach-commit.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach-fixture.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/terminal-leaf-move.test.ts
  • src/shared/terminal-leaf-move.ts

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

Comment on lines 164 to 181
getCallbacks: () => storedCallbacks
})
} finally {
if (pendingConnectGeneration === connectGeneration) {
pendingConnectGeneration = null
}
if (lifecycleGeneration === connectGeneration) {
await flushPreconnectInput()
}
}
},

isConnectPending: () =>
!destroyed && ptyId === null && pendingConnectGeneration === lifecycleGeneration,

attach: (options) => {
const attachGeneration = advancePtyLifecycle()
try {

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '170,215p' src/renderer/src/components/terminal-pane/pty-connection/run-deferred-connect.ts
sed -n '125,182p' src/renderer/src/components/terminal-pane/pty-transport.ts
sed -n '125,146p' src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
rg -n 'installRunDeferredConnect|runDeferredConnect|sourceConnectPending' src/renderer/src/components/terminal-pane | head -65

Repository: stablyai/orca

Length of output: 6494


Include scheduled connects in sourceConnectPending.

isConnectPending() becomes true only after connect() starts, but installRunDeferredConnect schedules that call earlier. During that gap, a confirmed-CWD split can pass the detach guard and move the leaf with a null PTY ID. If the scheduled connect then binds the leaf to the source tab, persistence can leave the same leaf owned by both tabs. Have the scheduler report its queued state to the detach guard; changing only the detach helper cannot detect a state its caller does not provide.

Comment on lines 127 to +164
const persistedPtyId =
initialStore.terminalLayoutsByTabId[args.sourceTabId]?.ptyIdsByLeafId?.[sourceLeafId]
initialStore.terminalLayoutsByTabId[args.sourceTabId]?.ptyIdsByLeafId?.[leafId]
const cwdDeferred = Boolean(
args.sourcePaneCwd?.pendingCwd || args.sourcePaneCwd?.deferredSplitSpawn
)
if (cwdDeferred && !persistedPtyId && !args.fallbackPtyId) {
// Why: a spawn result landing after the move binds SOURCE:leaf, and that bind grafts the leaf
// back into the source tab beside its moved copy.
if ((cwdDeferred || args.sourceConnectPending) && !persistedPtyId && !args.livePtyId) {
return null
}

args.persistLayoutSnapshot()
const store = args.getStore()
const detached = detachTerminalLayoutLeaf(
store.terminalLayoutsByTabId[args.sourceTabId],
sourceLeafId
)
if (!detached) {
const request: TerminalLeafMoveRequest = {
worktreeId: args.worktreeId,
sourceTabId: args.sourceTabId,
targetTabId: createBrowserUuid(),
leafId,
ptyId: args.livePtyId ?? persistedPtyId ?? null
}
if (!args.commitMove) {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
const moved = await args.commitMove(request).catch((error: unknown) => {
console.warn('[terminal-pane-detach] main did not answer the move', error)
return null
})
if (moved?.status === 'moved') {
return applyMove(args, request, { mainMoved: true, ptyId: moved.ptyId })
}
if (moved?.status === 'not_held') {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
// A failed write rolls main back; one whose outcome is unknown faults persistence, and the next
// load converges on whichever side main kept.
console.warn('[terminal-pane-detach] main did not move the pane', moved)
reportMoveFailed()
return null
}

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '118,165p' src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
sed -n '232,258p' src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.ts
sed -n '138,180p' src/renderer/src/components/terminal-pane/pty-transport.ts

Repository: stablyai/orca

Length of output: 4780


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\\n' '--- detach implementation ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts | sed -n '1,210p'
printf '%s\\n' '--- transport interface and lifecycle references ---'
rg -n -F -- 'isConnectPending' src/renderer/src
rg -n -F -- 'getPtyId:' src/renderer/src/components/terminal-pane
rg -n -F -- 'ptyId = null' src/renderer/src/components/terminal-pane/pty-transport.ts
printf '%s\\n' '--- transport lifecycle block ---'
nl -ba src/renderer/src/components/terminal-pane/pty-transport.ts | sed -n '1,245p'
printf '%s\\n' '--- move contract and implementation references ---'
rg -n -F -- 'moveLeafToNewTab' src
rg -n -F -- 'TerminalLeafMoveRequest' src

Repository: stablyai/orca

Length of output: 41851


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- detach implementation ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts | sed -n '1,210p'
printf '%s\n' '--- transport interface and lifecycle references ---'
rg -n -F -- 'isConnectPending' src/renderer/src
rg -n -F -- 'getPtyId:' src/renderer/src/components/terminal-pane
rg -n -F -- 'ptyId = null' src/renderer/src/components/terminal-pane/pty-transport.ts
printf '%s\n' '--- transport lifecycle block ---'
nl -ba src/renderer/src/components/terminal-pane/pty-transport.ts | sed -n '1,245p'
printf '%s\n' '--- move contract and implementation references ---'
rg -n -F -- 'moveLeafToNewTab' src
rg -n -F -- 'TerminalLeafMoveRequest' src

Repository: stablyai/orca

Length of output: 42067


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- PR diff for detach routine ---'
git diff --unified=12 2a68ea94967caf926aa60ebbd2bb32797bebb146 6bb3ea2d9adc4f3f70c8e191f3688ff0267ede8d -- src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
printf '%s\n' '--- PTY mismatch planner ---'
nl -ba src/main/persistence/terminal-topology/terminal-leaf-move.ts | sed -n '1,250p'
printf '%s\n' '--- move IPC binding ---'
nl -ba src/main/ipc/pty/ipc/leaf-move.ts | sed -n '1,100p'
printf '%s\n' '--- persisted PTY binding consumers in renderer ---'
rg -n -F -- 'ptyIdsByLeafId' src/renderer/src/components/terminal-pane src/renderer/src/store
printf '%s\n' '--- attach/reattach call sites ---'
rg -n -i -- 'reattach|transport\.connect|\.connect\(' src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
printf '%s\n' '--- detach commit tests ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-tab-detach-commit.test.ts | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 42959


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- planner mismatch and result path ---'
nl -ba src/main/persistence/terminal-topology/terminal-leaf-move.ts | sed -n '147,255p'
printf '%s\n' '--- reattach files ---'
rg --files src/renderer/src/components/terminal-pane/pty-connection | rg 'connect|restore|reattach|session'
printf '%s\n' '--- saved PTY binding references in connection code ---'
rg -n -F -- 'ptyIdsByLeafId' src/renderer/src/components/terminal-pane/pty-connection
printf '%s\n' '--- saved PTY binding references in pane lifecycle ---'
rg -n -F -- 'ptyIdsByLeafId' src/renderer/src/components/terminal-pane src/renderer/src/store
printf '%s\n' '--- persisted PTY ID selection references ---'
rg -n -i -- 'persistedPtyId|savedPtyId|initialPtyId|ptyId.*leafId|leafId.*ptyId' src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
printf '%s\n' '--- move IPC and persistence result ---'
nl -ba src/main/ipc/pty/ipc/leaf-move.ts | sed -n '1,100p'
nl -ba src/shared/terminal-leaf-move.ts | sed -n '1,90p'

Repository: stablyai/orca

Length of output: 41766


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- deferred reattach choice ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-choice.ts | sed -n '1,180p'
printf '%s\n' '--- deferred reattach call and restored binding source ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/deferred-session-attach.ts | sed -n '1,145p'
rg -n -F -- 'restoredPtyIdByLeafId' src/renderer/src/components/terminal-pane
printf '%s\n' '--- reattach result binding update ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts | sed -n '200,240p'
printf '%s\n' '--- connect binding update ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty.ts | sed -n '170,215p'
printf '%s\n' '--- direct SSH retry: restored binding and new PTY ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection-direct-ssh-reattach-retry.test.ts | sed -n '630,745p'

Repository: stablyai/orca

Length of output: 41283


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- deferred SSH reattach reaches transport.connect ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/deferred-session-attach.ts | sed -n '135,215p'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.ts | sed -n '1,145p'
printf '%s\n' '--- reattach result receives and compares old/new IDs ---'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts | sed -n '65,145p'
nl -ba src/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.ts | sed -n '216,250p'

Repository: stablyai/orca

Length of output: 17439


🏁 Script executed:

#!/bin/bash
set -e
nl -ba src/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.ts | sed -n '115,255p'

Repository: stablyai/orca

Length of output: 5824


Wait for reattach before moving the pane.

When a user drops a pane onto a tab-strip target during reattach, the transport has no live PTY ID, but this guard still sends persistedPtyId. Reattach can return a different ID after an SSH respawn. The planner may refuse the saved ID with pty_mismatch; if an owner partition still retains that stale ID, it can move the pane under it. Reject a pending connection when no live ID exists, while preserving the saved-ID fallback for non-pending moves.

Suggested fix
-  if ((cwdDeferred || args.sourceConnectPending) && !persistedPtyId && !args.livePtyId) {
+  if (
+    (cwdDeferred && !persistedPtyId && !args.livePtyId) ||
+    (args.sourceConnectPending && !args.livePtyId)
+  ) {
     return null
   }
📝 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.

Suggested change
const persistedPtyId =
initialStore.terminalLayoutsByTabId[args.sourceTabId]?.ptyIdsByLeafId?.[sourceLeafId]
initialStore.terminalLayoutsByTabId[args.sourceTabId]?.ptyIdsByLeafId?.[leafId]
const cwdDeferred = Boolean(
args.sourcePaneCwd?.pendingCwd || args.sourcePaneCwd?.deferredSplitSpawn
)
if (cwdDeferred && !persistedPtyId && !args.fallbackPtyId) {
// Why: a spawn result landing after the move binds SOURCE:leaf, and that bind grafts the leaf
// back into the source tab beside its moved copy.
if ((cwdDeferred || args.sourceConnectPending) && !persistedPtyId && !args.livePtyId) {
return null
}
args.persistLayoutSnapshot()
const store = args.getStore()
const detached = detachTerminalLayoutLeaf(
store.terminalLayoutsByTabId[args.sourceTabId],
sourceLeafId
)
if (!detached) {
const request: TerminalLeafMoveRequest = {
worktreeId: args.worktreeId,
sourceTabId: args.sourceTabId,
targetTabId: createBrowserUuid(),
leafId,
ptyId: args.livePtyId ?? persistedPtyId ?? null
}
if (!args.commitMove) {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
const moved = await args.commitMove(request).catch((error: unknown) => {
console.warn('[terminal-pane-detach] main did not answer the move', error)
return null
})
if (moved?.status === 'moved') {
return applyMove(args, request, { mainMoved: true, ptyId: moved.ptyId })
}
if (moved?.status === 'not_held') {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
// A failed write rolls main back; one whose outcome is unknown faults persistence, and the next
// load converges on whichever side main kept.
console.warn('[terminal-pane-detach] main did not move the pane', moved)
reportMoveFailed()
return null
}
const persistedPtyId =
initialStore.terminalLayoutsByTabId[args.sourceTabId]?.ptyIdsByLeafId?.[leafId]
const cwdDeferred = Boolean(
args.sourcePaneCwd?.pendingCwd || args.sourcePaneCwd?.deferredSplitSpawn
)
// Why: a spawn result landing after the move binds SOURCE:leaf, and that bind grafts the leaf
// back into the source tab beside its moved copy.
if (
(cwdDeferred && !persistedPtyId && !args.livePtyId) ||
(args.sourceConnectPending && !args.livePtyId)
) {
return null
}
args.persistLayoutSnapshot()
const request: TerminalLeafMoveRequest = {
worktreeId: args.worktreeId,
sourceTabId: args.sourceTabId,
targetTabId: createBrowserUuid(),
leafId,
ptyId: args.livePtyId ?? persistedPtyId ?? null
}
if (!args.commitMove) {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
const moved = await args.commitMove(request).catch((error: unknown) => {
console.warn('[terminal-pane-detach] main did not answer the move', error)
return null
})
if (moved?.status === 'moved') {
return applyMove(args, request, { mainMoved: true, ptyId: moved.ptyId })
}
if (moved?.status === 'not_held') {
return applyMove(args, request, { mainMoved: false, ptyId: request.ptyId })
}
// A failed write rolls main back; one whose outcome is unknown faults persistence, and the next
// load converges on whichever side main kept.
console.warn('[terminal-pane-detach] main did not move the pane', moved)
reportMoveFailed()
return null
}

@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.

Caution

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

⚠️ Outside diff range comments (1)

🟡 Minor · Fence stale mobile-session bindings at spawn commit. · terminal-pane-tab-detach.ts:127-145

src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts:127-145
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Fence stale mobile-session bindings at spawn commit.

When a main-side host spawn is outstanding, cwdDeferred and sourceConnectPending can both be false even though the renderer has no persisted or live PTY. The guard then permits a move with ptyId: null. If the source tab retains a sibling, the move removes the leaf from the source layout. The later host-spawn commit can still bind the captured source tab and leaf, grafting the leaf back into the source layout while it remains in the target layout. Revalidate leaf ownership at the host-spawn commit and refuse or reconcile a stale binding there; the renderer cannot observe this main-side spawn.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58abecb4-c288-4cb5-9564-a618d0f8536b
📥 Commits

Reviewing files that changed from the base of the PR and between 6bb3ea2 and 354ac63.

📒 Files selected for processing (1)
  • src/main/ipc/agent-hooks.test.ts

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

…status transfer

The pane manager decides whether the dragged pane is the last one, and a
refused detach closes main's new tab like a vanished pane. Paired web
clients answer the move as not held, so every client takes the same
moved / not_held / refused branch. Repeating an agent-status transfer that
is already in place is now a no-op where it happens, replacing the IPC
special case.

@pullfrog pullfrog 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.

ℹ️ No new issues in this update. The new commit reworks the move and status-transfer seams cleanly; the only open item is the pre-existing terminal-leaf-move.ts thread, which these commits do not touch.

Reviewed changes

  • One move path for every client — detachTerminalPaneToTab no longer takes an optional injected commitMove; it always awaits window.api.pty.moveLeafToNewTab. Paired web clients supply { status: 'not_held' } in createPtyApi, so their move still falls back to the renderer-local path.
  • Idempotent status transfer — removed AgentHookServer.isPaneAuthorityTransferredTo and its IPC-gate short-circuit; transferPaneAuthority now returns early when the owner already routes from→to and (when supplied) the physical alias carries the same trimmed ptyId. Main's direct call is now idempotent too, and the renderer still passes canTransferPaneAuthority first.
  • Spawn-in-flight fence — added PtyTransport.isConnectPending, true only while a connect has not produced a ptyId, and threaded it into the detach guard as sourceConnectPending beside the pending-cwd check.
  • Last-pane detection — the concurrent-sibling path now derives "source tab emptied" from manager.getPanes().length === 1 instead of re-walking the stored layout.
  • Tests — new main-side leaf-move suite, an idempotency case on server-pane-authority, a pending-connect case on pty-transport-connect-spawn, and the renderer commit/roll-forward suite updated for the async path.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…ology-b1-2-move-leaf

# Conflicts:
#	src/main/persistence/loading-store/pty-binding-persistence.ts
@Jinwoo-H
Jinwoo-H merged commit bfcbcfd into main Oct 7, 2026
44 of 48 checks passed
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