/** * Invariant: a panel can show the workspace's agents without polling. `agents.list` names each * agent's terminal, `agent.status.changed` reaches the panel with the same `terminalId`, and * `workspace.changed` arrives on subscribe (the current context) and again when a terminal opens. */ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { expect, test } from './helpers/orca-app' import { emitCodexHookStatus, readHookEndpoint } from './helpers/agent-hook-endpoint' import { disablePluginSystem, enableDevPlugins } from './helpers/plugin-smoke' import { ISOLATED_FRAMES_E2E, pluginGuest, readInGuest, waitForGuestReady } from './helpers/plugin-frame-guest' import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store' import { waitForActivePaneHookDescriptor, waitForActiveTerminalManager } from './helpers/terminal' test.use(ISOLATED_FRAMES_E2E) const PANEL = `
` test('a panel lists agents and hears their status and workspace changes', async ({ orcaPage, electronApp }) => { const tempRoot = await mkdtemp(join(tmpdir(), 'orca-panel-agents-')) const pluginRoot = join(tempRoot, 'agent-board') try { await waitForSessionReady(orcaPage) const worktreeId = await waitForActiveWorktree(orcaPage) await ensureTerminalVisible(orcaPage) await waitForActiveTerminalManager(orcaPage, 30_000) await mkdir(pluginRoot, { recursive: true }) await writeFile(join(pluginRoot, 'panel.html'), PANEL) await writeFile( join(pluginRoot, 'orca-plugin.json'), JSON.stringify({ manifestVersion: 2, execution: 'sandboxed-ui', id: 'agent-board', name: 'Agent Board', version: '1.0.0', engines: { orca: '>=1.4.246' }, pluginApi: 1, contributes: { panels: [{ id: 'board', title: 'Agent Board', entry: 'panel.html' }] }, capabilities: [{ kind: 'agent:read' }, { kind: 'workspace:read' }] }) ) await enableDevPlugins(orcaPage, [pluginRoot]) await orcaPage.evaluate(async () => { const store = window.__store?.getState() if (store && !store.rightSidebarOpen) { store.toggleRightSidebar() } await window.api.plugins.refresh() }) await orcaPage.getByRole('button', { name: 'Agent Board' }).click({ timeout: 15_000 }) const guest = pluginGuest(orcaPage, 'Agent Board') await waitForGuestReady(guest) const ask = async