test(e2e): prove Pi EOF removes sidebar agent row (#21722)

This commit is contained in:
Neil
2026-09-19 13:00:46 -07:00
committed by GitHub
parent ac024d4f05
commit f016d38e9c
2 changed files with 71 additions and 0 deletions
@@ -855,6 +855,25 @@ describe('connectPanePty', () => {
expect(manager.closePane).toHaveBeenCalledWith(2)
})
it('removes the agent row when an established PTY exits through EOF (#12907)', async () => {
const { connectPanePty } = await import('./pty-connection')
const transport = createMockTransport('pty-pane-2')
transportFactoryQueue.push(transport)
const manager = createManager(2)
const deps = createDeps({
restoredLeafId: LEAF_2,
paneTransportsRef: { current: new Map([[1, createMockTransport('pty-pane-1')]]) }
})
connectPanePty(createPane(2) as never, manager as never, deps as never)
const onPtyExit = createdTransportOptions[0]?.onPtyExit as ((ptyId: string) => void) | undefined
expect(onPtyExit).toBeTypeOf('function')
onPtyExit?.('pty-pane-2')
expect(mockStoreState.removeAgentStatus).toHaveBeenCalledWith(makePaneKey('tab-1', LEAF_2))
})
it('closes a split pane when an established PTY exits after terminal input', async () => {
const { connectPanePty } = await import('./pty-connection')
const pane = createPane(2)
@@ -0,0 +1,52 @@
import { test, expect } from './helpers/orca-app'
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
import {
sendToTerminal,
waitForActivePanePtyId,
waitForActiveTerminalManager,
waitForTerminalOutput
} from './helpers/terminal'
import {
stageNodeScriptForTerminal,
type StagedTerminalNodeScript
} from './helpers/run-node-script-in-terminal'
import { worktreeRow } from './worktree-row-locators'
test('Pi EOF removes the completed agent row from the live Electron sidebar (#12907)', async ({
orcaPage
}, testInfo) => {
await waitForSessionReady(orcaPage)
const worktreeId = await waitForActiveWorktree(orcaPage)
await ensureTerminalVisible(orcaPage)
await waitForActiveTerminalManager(orcaPage)
const ptyId = await waitForActivePanePtyId(orcaPage)
await orcaPage.evaluate(() => {
const state = window.__store?.getState()
if (!state) {
throw new Error('window.__store is unavailable')
}
state.setAgentActivityDisplayMode('full')
if (!state.worktreeCardProperties.includes('inline-agents')) {
state.toggleWorktreeCardProperty('inline-agents')
}
})
const script: StagedTerminalNodeScript = stageNodeScriptForTerminal(
"process.stdout.write('PI_EOF_AGENT_READY\\r\\n\\x1b]0;Pi\\x07'); process.stdin.resume(); process.stdin.on('end', () => process.exit(0))"
)
// Keep the shell from becoming the surviving process after the child accepts
// EOF. The queued `exit` runs after node exits, on POSIX shells used here.
await sendToTerminal(orcaPage, ptyId, `${script.command}; exit\r`)
try {
await waitForTerminalOutput(orcaPage, 'PI_EOF_AGENT_READY', 15_000)
const agentRows = worktreeRow(orcaPage, worktreeId).locator('[aria-label="Agents"] > div')
await expect(agentRows).toHaveCount(1)
await orcaPage.screenshot({ path: testInfo.outputPath('pi-row-before-eof.png') })
await sendToTerminal(orcaPage, ptyId, '\u0004')
await expect(agentRows).toHaveCount(0, { timeout: 15_000 })
await orcaPage.screenshot({ path: testInfo.outputPath('pi-row-after-eof.png') })
} finally {
script.cleanup()
}
})