Files
orca/src/shared/structured-agent-session-surface-capabilities.ts
T
Brennan Benson af211d6b82 Close the terminal before continuing its conversation in chat (#36732)
* Stop only the identified Windows pane agent before chat continuation

* Stop terminal agents before continuing their conversations in chat

* Continue in chat without confirmation while stopping the old agent

* Wire Windows stopping through the execution host and preflight permissions

* Scope chat continuation admission to proven terminal survivors

* Continue in chat after ordinary terminal close and verified exit

* Continue in chat without a stop prompt for the agent and keep the user on the new chat

Only work in other panes of the tab asks before the close; the worktree stays selected so the chat shows when it opens; an open chat for the conversation is opened instead of closing the terminal; the pre-close check skips the rows the host skips and counts restored ones; the preparation deadline no longer runs while a close dialog is open; failure messages say what happened once and point to Session History.

* Remove terminal-writer bookkeeping nothing reads after store-only admission

The hook server no longer tags OpenCode and tmux conversation bindings with a writer topology, the admission check drops its unused source pane argument, and the hook that clears a saved launch result is named for what it does.

* Keep the hook server's writer-topology tagging unchanged in this change

Another open change still reads it, so its removal waits for that one.

* Keep the terminal when its agent already quit, and refuse only an agent that is still running

Continue in Chat UI closes the terminal tab only while the clicked pane still shows its agent on this conversation; otherwise the chat opens and the terminal stays, as before. The host now refuses a takeover only when the agent's process is proven running: an agent with no recorded process, one that reported its own end, or one that can't be checked no longer blocks Session History or a chat.

* Prove a paired terminal's exit even when the close reaches the host first

A terminal handle a pane issued now keeps naming its process after the pane is removed, until that process record is pruned or replaced, so a late exit wait reads the recorded exit instead of failing. Before closing for Continue in Chat UI, only an open chat for the conversation is answered; whether another terminal still holds it is left to the host. A run that was already retired says nothing when its old confirmation is answered.

* Shrink the flaky-test pattern baseline for two cleaned-up test files

* Merge a duplicate import in the chat-continue run

* Keep unshown terminals usable and say how to recover when another terminal holds the conversation

A terminal that no pane shows is listed, read and controlled through its own handle again, as before; the closed pane's handle still answers a late exit wait and nothing else, and only for a known process incarnation. After Continue in Chat UI closes the terminal, a conversation still running in another terminal names that terminal and the remedy. A continuation retired with no newer one for the same tab says once that the terminal changed when its confirmed close is refused.

* Fix test types and retire translations whose English changed

* Keep the terminal when its agent's status is only restored from before a restart

Continue in Chat UI closes the terminal only while its agent is confirmed running there; a status row carried over a restart, with no live update since, now takes the keep-the-terminal path.

* Revert "Keep the terminal when its agent's status is only restored from before a restart"

This reverts commit c19d708ecb.

* Expect the new other-terminal copy in the Session History continue test

* Point a still-running terminal refusal to Session History, which old hosts still offer
2026-10-31 18:47:18 -07:00

65 lines
4.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { AGENT_SESSION_PERMISSION_OWN_RUNTIME_CAPABILITY } from './agent-session-permission-modes-capability'
// Registered-agent hosts accept only their agentSession.agents inventory; offer agents beyond Claude/Codex only after negotiation.
// Clients advertising this can render those agents’ tabs; withhold extra-agent tabs from older clients to avoid empty panes.
export const STRUCTURED_AGENT_SESSION_REGISTERED_AGENTS_RUNTIME_CAPABILITY =
'agent-session.structured.registered-agents.v1' as const
// Pi dialog rendering/answers require a capability beyond registered-agent support.
export const PI_STRUCTURED_DIALOGS_RUNTIME_CAPABILITY =
'agent-session.structured.pi-dialogs.v1' as const
// Explicit surface holds let hosts stop children after the last visible surface closes, independently of transports.
export const STRUCTURED_AGENT_SESSION_HOLD_RUNTIME_CAPABILITY =
'agent-session.structured.hold.v1' as const
// Gate session-history tab reveal: old hosts lack the method, and its refusal is indistinguishable from a real failure.
export const STRUCTURED_AGENT_SESSION_REVEAL_RUNTIME_CAPABILITY =
'agent-session.structured.reveal.v1' as const
// Offer Regenerate name only to hosts implementing agentSession.regenerateName.
export const STRUCTURED_AGENT_SESSION_REGENERATE_NAME_RUNTIME_CAPABILITY =
'agent-session.structured.regenerate-name.v1' as const
// Save names only on rename-capable hosts; older hosts retain the local tab alias.
export const STRUCTURED_AGENT_SESSION_RENAME_RUNTIME_CAPABILITY =
'agent-session.structured.rename.v1' as const
// Negotiate resumeFrom before sending: old strict create schemas reject it, while unproven acceptance could silently start a blank chat.
export const STRUCTURED_AGENT_SESSION_RESUME_HISTORY_RUNTIME_CAPABILITY =
'agent-session.structured.resume-history.v1' as const
// Alias-dependent actions need actual-source selected-path correspondence, absent on v1 hosts.
export const STRUCTURED_AGENT_SESSION_RESUME_LINKED_CWD_RUNTIME_CAPABILITY =
'agent-session.structured.resume-linked-cwd.v1' as const
// Gate savedOnly because old strict catalog params reject it; otherwise preload only agents with saved picks.
export const AGENT_SESSION_MODEL_CATALOG_SAVED_ONLY_RUNTIME_CAPABILITY =
'agent-session.model-catalog.saved-only.v1' as const
/** Strict create source identity is sent only after host negotiation. */
export const STRUCTURED_AGENT_SESSION_CLI_SOURCE_RUNTIME_CAPABILITY =
'agent-session.structured.cli-source.v1' as const
// Only these hosts admit the conversation after its source terminal closes.
export const STRUCTURED_AGENT_SESSION_CLOSE_TERMINAL_FOR_CHAT_RUNTIME_CAPABILITY =
'agent-session.structured.close-terminal-for-chat.v1' as const
// Gate the availability stream because old decoders silently drop its opcode; fall back to client facts/createSupport on click.
export const STRUCTURED_AGENT_SESSION_AVAILABILITY_RUNTIME_CAPABILITY =
'agent-session.structured.availability.v1' as const
export const AGENT_SESSION_COHERENT_MODEL_CATALOG_CAPABILITY =
'agent-session.coherent-model-catalog.v1' as const
export const AGENT_SESSION_COMMANDS_ON_REQUEST_CAPABILITY =
'agent-session.commands-on-request.v1' as const
export const STRUCTURED_AGENT_SESSION_SURFACE_RUNTIME_CAPABILITIES = [
AGENT_SESSION_COMMANDS_ON_REQUEST_CAPABILITY,
AGENT_SESSION_PERMISSION_OWN_RUNTIME_CAPABILITY,
AGENT_SESSION_COHERENT_MODEL_CATALOG_CAPABILITY,
STRUCTURED_AGENT_SESSION_HOLD_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_REVEAL_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_REGISTERED_AGENTS_RUNTIME_CAPABILITY,
PI_STRUCTURED_DIALOGS_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_RESUME_HISTORY_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_RESUME_LINKED_CWD_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_CLI_SOURCE_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_CLOSE_TERMINAL_FOR_CHAT_RUNTIME_CAPABILITY,
AGENT_SESSION_MODEL_CATALOG_SAVED_ONLY_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_AVAILABILITY_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_REGENERATE_NAME_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_RENAME_RUNTIME_CAPABILITY
] as const