Merge pull request #401 from nwparker/cloud/pc3b-start-focus

fix(cloud): PC-3b Start Claude on the held strip brings the agent's tab forward
This commit is contained in:
Neil
2026-11-11 02:37:28 -08:00
committed by GitHub
3 changed files with 24 additions and 5 deletions
@@ -121,7 +121,19 @@ export function readCloudAgentHold(paneKey: string): CloudAgentHold | null {
}
export function releaseCloudAgentHold(paneKey: string, outcome: 'proceed' | 'cancel'): void {
holds.get(paneKey)?.release(outcome)
const hold = holds.get(paneKey)
if (hold && outcome === 'proceed') {
// The strip's Start: the person asked for the agent here and now (a Renew's auto-start didn't).
startedByPerson.add(paneKey)
}
hold?.release(outcome)
}
const startedByPerson = new Set<string>()
/** Whether this hold was released by the person's Start (read once): its agent should take focus. */
export function takeCloudAgentHoldStartedByPerson(paneKey: string): boolean {
return startedByPerson.delete(paneKey)
}
// A launch decides within this budget; a slow or failed read never holds the agent.
@@ -120,7 +120,8 @@ describe('createWithCloudAgentHold (the one hold for every Orca Cloud agent laun
releaseCloudAgentHold(key, 'proceed')
await expect(result).resolves.toBe(AGENT)
// The original launch, untouched: its command still carries the first prompt.
expect(create).toHaveBeenLastCalledWith(CREATE_AGENT)
// Started by the person's click: the agent's tab comes forward.
expect(create).toHaveBeenLastCalledWith({ ...CREATE_AGENT, activate: true })
expect(host.close).toHaveBeenCalledWith(
expect.objectContaining({ tabId: toWebTerminalSurfaceTabId('h1'), reason: 'user' })
)
@@ -141,7 +142,7 @@ describe('createWithCloudAgentHold (the one hold for every Orca Cloud agent laun
await expect(result).resolves.toBe(AGENT)
const agentCreates = create.mock.calls.filter(([args]) => args.launchAgent === 'claude')
// The prompt rides in the prepared command, delivered once by the one agent create.
expect(agentCreates).toEqual([[launch]])
expect(agentCreates).toEqual([[{ ...launch, activate: true }]])
expect(create).toHaveBeenCalledTimes(2)
expect(readCloudAgentHold(key)).toBeNull()
})
@@ -159,6 +160,7 @@ describe('createWithCloudAgentHold (the one hold for every Orca Cloud agent laun
})
setOrcaCloudAgentAccountsStateForTest(accounts({ state: 'active' }))
await expect(result).resolves.toBe(AGENT)
// Renew's auto-start: the original args, no focus taken (the tab may be in the background).
expect(create).toHaveBeenLastCalledWith(args)
})
@@ -18,7 +18,8 @@ import { isOrcaCloudEnvironmentId } from './orca-cloud-environment-id'
import {
cloudAgentLaunchDecision,
cloudTabHoldKey,
holdCloudAgentLaunch
holdCloudAgentLaunch,
takeCloudAgentHoldStartedByPerson
} from './cloud-agent-launch-hold'
type CreateHostTerminal = (
@@ -86,7 +87,11 @@ export async function createWithCloudAgentHold(
)
return placeholder
}
const created = await create(args)
// Started by the person's click in the held pane: bring the agent's tab forward so they see their
// queued prompt run. A Renew's auto-start (maybe on a background tab) never steals focus.
const created = await create(
takeCloudAgentHoldStartedByPerson(cloudTabHoldKey(tabId)) ? { ...args, activate: true } : args
)
// The agent opened in its own tab; the placeholder shell has done its job.
if (args.environmentId) {
void closeWebRuntimeSessionTab({