mirror of
https://github.com/stablyai/orca.git
synced 2026-09-21 16:02:20 +00:00
refactor(terminal): stop handing the reveal caller back its own worktree key
The target carried the event's key when there was no owner row, which is the caller's argument returned to it. Null now says 'mint', and the bridge falls back to the event's key in one place.
This commit is contained in:
@@ -57,7 +57,6 @@ export function registerTerminalPresentationIpcBridge(unsubs: (() => void)[]): v
|
||||
// Why: a split pane revealed from mobile is only bound in the persisted layout until
|
||||
// its pane mounts, and its row can sit under another worktree key (#10486, STA-7961).
|
||||
const revealTarget = resolveTerminalRevealTarget(store, {
|
||||
worktreeId,
|
||||
...(ptyId ? { ptyId } : {}),
|
||||
...(tabId !== undefined ? { tabId } : {}),
|
||||
...(leafId ? { leafId } : {}),
|
||||
@@ -65,11 +64,11 @@ export function registerTerminalPresentationIpcBridge(unsubs: (() => void)[]): v
|
||||
})
|
||||
// Why: every surfacing site below must use the owner's key, not the event's, or
|
||||
// verifyTerminalRevealIdentity looks the tab up under a key that does not hold it.
|
||||
const ownerWorktreeId = revealTarget.ownerWorktreeId
|
||||
const ownerWorktreeId = revealTarget?.worktreeId ?? worktreeId
|
||||
if (shouldActivate) {
|
||||
activateTerminalInitiatedWorktree(store, ownerWorktreeId)
|
||||
}
|
||||
const reusedTab = revealTarget.tab
|
||||
const reusedTab = revealTarget?.tab
|
||||
const tab =
|
||||
reusedTab ??
|
||||
(ptyId
|
||||
|
||||
@@ -75,30 +75,15 @@ export function resolveTerminalRevealTabAdoption(
|
||||
return null
|
||||
}
|
||||
|
||||
export type TerminalRevealTargetRequest = {
|
||||
worktreeId: string
|
||||
ptyId?: string
|
||||
tabId?: string
|
||||
leafId?: string
|
||||
splitFromLeafId?: string
|
||||
}
|
||||
|
||||
export type TerminalRevealTarget = {
|
||||
/** The row to reuse: the PTY or leaf owner, else a split reveal's parent row. */
|
||||
tab: TerminalTab | undefined
|
||||
/** The worktree key the reused row is filed under; the event's key when minting. */
|
||||
ownerWorktreeId: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The tab a reveal should land on, and the worktree key to surface it under. Ownership is
|
||||
* tab-keyed, so the owning row can sit under a worktree key other than the event's — surfacing
|
||||
* under the event's key then fails `verifyTerminalRevealIdentity` (STA-7961).
|
||||
* The row a reveal should land on, and the worktree key it is filed under; null to mint. Ownership
|
||||
* is tab-keyed, so the owning row can sit under a key other than the event's — surfacing under the
|
||||
* event's key then fails `verifyTerminalRevealIdentity` (STA-7961).
|
||||
*/
|
||||
export function resolveTerminalRevealTarget(
|
||||
state: TerminalRevealAdoptionState,
|
||||
request: TerminalRevealTargetRequest
|
||||
): TerminalRevealTarget {
|
||||
request: { ptyId?: string; tabId?: string; leafId?: string; splitFromLeafId?: string }
|
||||
): { tab: TerminalTab; worktreeId: string } | null {
|
||||
const adoptedTabId = request.ptyId
|
||||
? resolveTerminalRevealTabAdoption(state, {
|
||||
ptyId: request.ptyId,
|
||||
@@ -119,5 +104,5 @@ export function resolveTerminalRevealTarget(
|
||||
if (isSplitReveal && !adoptedRow) {
|
||||
throw new Error(`Terminal tab ${request.tabId} not found`)
|
||||
}
|
||||
return { tab: adoptedRow?.tab, ownerWorktreeId: adoptedRow?.worktreeId ?? request.worktreeId }
|
||||
return adoptedRow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user