Files
orca/src/main/runtime/runtime-terminal-spawn-placement.ts
T
Jinwoo Hong 0e4207400b fix(terminal): keep a named terminal's title across an orca serve restart (#28126)
* fix(terminal): keep a host-made terminal's title across a serve restart

A title given to terminal.create was kept only on the live process record, so
after an orca serve restart the tab read "Terminal N" and terminal.list
listed no title. The runtime now writes it as the tab's saved name when it
admits the pane, and terminal.list falls back to that saved name for a
terminal that has no title of its own yet, as a window does.

* test(e2e): record the kept terminal titles in the layout-compat baselines

* fix(terminal): save a created terminal's name only when the window would show it

A background create (a worker the window never reveals) keeps its live title:
a window reads a saved name on hydration and shows it over the agent's own
title. Also corrects two comments and drops a key count.
2026-10-12 22:25:55 -04:00

37 lines
1.3 KiB
TypeScript

import type { TerminalPanePlacement } from '../../shared/terminal-pane-placement'
import type { TerminalPaneSplitDirection } from '../../shared/terminal-tab-types'
import type { RuntimeTerminalPresentation } from '../../shared/runtime-terminal-contracts'
/**
* A runtime-started tab opens in the group asked for, else the first group (as the live view). Its
* title is the caller's name for it when the window would show it too: a revealed tab keeps the
* name, a background tab (a worker the window never revealed) keeps its live title.
*/
export function newTabIn(opts: {
viewMode?: 'terminal' | 'chat'
targetGroupId?: string
title?: string
presentation?: RuntimeTerminalPresentation
}): {
placement: TerminalPanePlacement
groupId?: string
} {
const { viewMode, targetGroupId } = opts
const title = opts.presentation === 'background' ? undefined : opts.title
const row = {
...(viewMode ? { viewMode } : {}),
...(title ? { customTitle: title } : {})
}
return {
placement: viewMode || title ? { kind: 'new-tab', row } : { kind: 'new-tab' },
...(targetGroupId ? { groupId: targetGroupId } : {})
}
}
export function runtimeSplitPlacement(
parentLeafId: string,
direction: TerminalPaneSplitDirection
): TerminalPanePlacement {
return { kind: 'split', parentLeafId, direction }
}