mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* fix(terminal): keep remote-viewer clipboard env on command-less creates (#39852) A paired viewer's plain terminal reaches the host renderer's tab-create bridge with spawn env (ORCA_REMOTE_VIEWER_CLIPBOARD, PI_CLIPBOARD_OSC52) but no startup command. The bridge queued pendingStartup only when a command existed, dropping the env, so the spawned shell never saw the remote-viewer clipboard marker and copied text stayed on the host clipboard (#39852). - Queue the startup whenever the request carries launch material (env/envToDelete/launchConfig/resume), not only a command. - PtyPaneStartup.command becomes optional for env-only startups; spawn options already tolerate a missing command. - Keep the plain-shell pre-bind input hold for startups that plan no post-bind work, so an env-only startup types as a plain shell does. Co-Authored-By: Claude Code <noreply@anthropic.com> * test(e2e): layout oracle marks only panes the user can see A hidden tab with a queued startup is laid out at opacity 0 so it spawns at real geometry. The marker check counted it as visible because it has a size, then waited for output that the hidden-delivery gate correctly withholds. Paired-client creates now queue spawn env, so their background tabs hit this. --------- Co-authored-by: Chen <zwq19980411@gmail.com> Co-authored-by: Claude Code <noreply@anthropic.com>
86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
import type { Page } from '@stablyai/playwright-test'
|
||
import type { RuntimeClient } from '../../../src/cli/runtime/client'
|
||
|
||
const POLL_MS = 300
|
||
|
||
function sleep(ms: number): Promise<void> {
|
||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||
}
|
||
|
||
// Require each bound pane to echo its unique marker in that pane’s accessibility DOM; no panes is a failure.
|
||
export async function checkPaneMarkers(
|
||
page: Page,
|
||
client: RuntimeClient,
|
||
worktreeId: string
|
||
): Promise<string[]> {
|
||
const listed = await client.call<{
|
||
terminals: { handle: string; tabId: string; leafId: string }[]
|
||
}>('terminal.list', { worktree: `id:${worktreeId}` })
|
||
const mounted = new Set(
|
||
await page.evaluate(() =>
|
||
Array.from(document.querySelectorAll<HTMLElement>('.pane[data-leaf-id][data-pty-id]'))
|
||
// Why opacity: a hidden tab with a queued startup is laid out at opacity 0 so it spawns at real geometry; it has a size but is not shown.
|
||
.filter(
|
||
(pane) =>
|
||
pane.getBoundingClientRect().width > 0 &&
|
||
pane.checkVisibility({ opacityProperty: true, visibilityProperty: true })
|
||
)
|
||
.map((pane) => pane.dataset.leafId ?? '')
|
||
)
|
||
)
|
||
const failures: string[] = []
|
||
let checked = 0
|
||
for (const [index, terminal] of listed.result.terminals.entries()) {
|
||
if (!mounted.has(terminal.leafId)) {
|
||
continue
|
||
}
|
||
const marker = `ORACLE_MARK_${Date.now().toString(36)}_${index}`
|
||
checked += 1
|
||
try {
|
||
await client.call('terminal.send', {
|
||
terminal: terminal.handle,
|
||
text: `echo ${marker}`,
|
||
enter: true
|
||
})
|
||
} catch (error) {
|
||
// A pane whose process is gone is a finding, not a harness fault.
|
||
failures.push(`pane ${terminal.tabId}:${terminal.leafId} refused ${marker}: ${String(error)}`)
|
||
continue
|
||
}
|
||
const deadline = Date.now() + 10_000
|
||
let shown = false
|
||
while (!shown && Date.now() < deadline) {
|
||
shown = await page.evaluate(
|
||
({ leafId, text }) => {
|
||
for (const manager of window.__paneManagers?.values() ?? []) {
|
||
for (const pane of manager.getPanes()) {
|
||
if (
|
||
manager.getLeafId(pane.id) === leafId &&
|
||
!pane.terminal.options.screenReaderMode
|
||
) {
|
||
pane.terminal.options.screenReaderMode = true
|
||
pane.terminal.refresh(0, pane.terminal.rows - 1)
|
||
}
|
||
}
|
||
}
|
||
const node = document.querySelector(
|
||
`.pane[data-leaf-id="${CSS.escape(leafId)}"] .xterm-accessibility-tree`
|
||
)
|
||
return (node?.textContent ?? '').includes(text)
|
||
},
|
||
{ leafId: terminal.leafId, text: marker }
|
||
)
|
||
if (!shown) {
|
||
await sleep(POLL_MS)
|
||
}
|
||
}
|
||
if (!shown) {
|
||
failures.push(`pane ${terminal.tabId}:${terminal.leafId} never showed ${marker}`)
|
||
}
|
||
}
|
||
if (checked === 0) {
|
||
failures.push(`no visible pane of ${worktreeId} to write a marker into`)
|
||
}
|
||
return failures
|
||
}
|