mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
The pane-close consistency spec closed panes with a bare PaneManager.closePane, the drawing-layer call that never asks main. In a layout-owner build that close reached main only because killing the pane's terminal made main retire the pane; right after a reveal the terminal has not attached yet, so main kept the pane. Every user close path already sends the close to main first. The helpers now close through the pane close request the menu and shortcut use, and every scenario also checks that main's stored panes match the window's.
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import type { Page } from '@stablyai/playwright-test'
|
|
import { leafIdsInOrder } from './workspace-layout-oracle-model'
|
|
import { readWorkspaceLayoutStreamFrame } from '../../../src/shared/workspace-layout/workspace-layout-stream-frames'
|
|
|
|
/** Terminal tab id → its pane ids in tree order, in tab-bar order. */
|
|
export type TerminalLayout = [tabId: string, paneIds: string[]][]
|
|
|
|
/** What main holds for the workspace, read from a stream of the test's own. */
|
|
export async function readMainLayout(page: Page, worktreeId: string): Promise<TerminalLayout> {
|
|
const raw = await page.evaluate(
|
|
(id) =>
|
|
new Promise<unknown>((resolve, reject) => {
|
|
const timer = setTimeout(() => reject(new Error('main sent no layout snapshot')), 10_000)
|
|
let handle: { unsubscribe: () => void } | null = null
|
|
let snapshot: unknown
|
|
const finish = (): void => {
|
|
if (handle && snapshot !== undefined) {
|
|
clearTimeout(timer)
|
|
handle.unsubscribe()
|
|
resolve(snapshot)
|
|
}
|
|
}
|
|
void window.api.runtime
|
|
.subscribe({ method: 'layout.subscribe', params: { workspaces: [id] } }, (response) => {
|
|
if (snapshot === undefined && response.ok) {
|
|
snapshot = response.result
|
|
finish()
|
|
}
|
|
})
|
|
.then((opened) => {
|
|
handle = opened
|
|
finish()
|
|
}, reject)
|
|
}),
|
|
worktreeId
|
|
)
|
|
const frame = readWorkspaceLayoutStreamFrame(raw)
|
|
if (frame?.type !== 'snapshot') {
|
|
throw new Error(
|
|
`layout.subscribe opened with no snapshot: ${JSON.stringify(raw).slice(0, 300)}`
|
|
)
|
|
}
|
|
const layout = frame.workspaces.find((entry) => entry.key === worktreeId)?.layout
|
|
return (layout?.tabs ?? [])
|
|
.filter((tab) => tab.kind === 'terminal')
|
|
.map((tab) => [tab.entityId, leafIdsInOrder(tab.terminal?.root)])
|
|
}
|