Files
archived-orca/src/shared/runtime-mobile-session-tab-contracts.ts
T
Brennan BensonandAJIADb9 239a70040c Terminal tabs show the agent session's name instead of the first-prompt title (#38518)
* fix(tabs): show the agent session's name on terminal tabs

The tab strip rebuilt each terminal tab without its session title and then re-ranked it, so the first-prompt title won over the session's own name. Carry the session title through the projection, and give the tab strip, unified tab label and sidebar agent row one shared name order so they cannot drift.

Co-authored-by: AJIADb9 <ajiadb9@bgd.team>

* fix(tabs): paired desktops take the host's session name for mirrored terminal tabs

The host projection now forwards the window's session title to paired clients, and the client's rebuild adopts it (older hosts omit it, so the client keeps its own). Without it a mirrored tab re-ranked to the client's first-prompt title.

* fix(tabs): one writer per session for a mirrored tab's session name

The paired client's own title sync keeps a session it already tracks current; the host's name only fills a session the client doesn't know, so a stale host snapshot can't revert a rename the client already read.

* fix(tabs): a paired host is the only writer of a session name it publishes

* fix(tabs): only a host window that resolves session names speaks for them

* fix(tabs): derive session title authority from live publishers

* fix(tabs): keep the session title publisher check concrete for runtime subclasses

* fix(tabs): one publication when a closing window drops browsers and title authority

* test(tabs): follow main's runtime test helper layout

* fix(tabs): paired desktops keep a quick-command name ahead of the session name

* fix(tabs): a name the host cleared doesn't come back as the idle pane's title

* test(tabs): build the idle-pane fixture as its own surface variant

* fix(tabs): point the moved session-title projection at its new shared path

---------

Co-authored-by: AJIADb9 <ajiadb9@bgd.team>
2026-11-05 11:04:58 -08:00

153 lines
5.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 type { AgentStatusEntry } from './agent-status/contracts/agent-status-types'
import type { BrowserCertificateFailure, BrowserLoadError } from './browser-workspace-types'
import type { RuntimeBrowserPlacement } from './runtime-browser-placement'
import type { TerminalColorOverrides } from './terminal-themes/terminal-color-overrides'
import type { TerminalLayoutSnapshot, TerminalTab } from './workspace-layout/terminal-tab-types'
import type { TuiAgent } from './agent-launch/catalog/tui-agent'
import type { StructuredAgentId } from './agent-session/lifecycle/agent-session-provider-handle'
export type RuntimeMobileSessionTerminalTab = {
type: 'terminal'
id: string
title: string
/** Host manual title; absent on old hosts preserves the client record, whereas null clears it. */
customTitle?: string | null
quickCommandLabel?: string | null
/** Window-to-main names ranked above live titles; generatedTitle is sent only when enabled. */
aiVaultTitle?: TerminalTab['aiVaultTitle']
/** The publishing window resolves this surface's session name, so aiVaultTitle (null clears) is authoritative. Headless and older hosts omit it; their saved names are only cache. */
resolvesSessionTitle?: true
generatedTitle?: string | null
parentTabId: string
leafId: string
ptyId?: string | null
/** Host-owned PTY incarnation used to fence remote identity observations. */
incarnationId?: string | null
terminalTheme?: RuntimeMobileTerminalTheme
agentStatus?: AgentStatusEntry | null
/** Event-only lead-turn end time for paired clients; never persisted in AgentStatusEntry. */
turnCompletedAt?: number
launchAgent?: TuiAgent
startupCwd?: string
parentLayout?: TerminalLayoutSnapshot
color?: string | null
isPinned?: boolean
viewMode?: 'terminal' | 'chat'
launchDraft?: string
launchDraftCreatedAt?: number
isActive: boolean
}
export type RuntimeMobileTerminalTheme = {
mode: 'dark' | 'light'
theme: TerminalColorOverrides
/** Optional desktop contrast override (#10754); absent uses the client’s background-luminance floor. */
minimumContrastRatio?: number
}
export type RuntimeMobileSessionMarkdownTab = {
type: 'markdown'
id: string
title: string
filePath: string
relativePath: string
language: 'markdown'
mode: 'edit' | 'markdown-preview'
isDirty: boolean
isActive: boolean
sourceFileId: string
sourceFilePath: string
sourceRelativePath: string
/** Set by a desktop for a "New Markdown" document not yet named; hosts and phones before it omit it. */
isUntitled?: true
documentVersion: string
color?: string | null
isPinned?: boolean
/** The paired server the file lives on. Its publisher sets it; runtimes strip it before serving. */
hostRuntimeEnvironmentId?: string
}
export type RuntimeMobileSessionFileTab = {
type: 'file'
id: string
title: string
filePath: string
relativePath: string
language: string
mode?: 'edit' | 'diff'
diffSource?: 'staged' | 'unstaged'
oldPath?: string
isDirty: boolean
color?: string | null
isPinned?: boolean
isActive: boolean
/** The paired server the file lives on. Its publisher sets it; runtimes strip it before serving. */
hostRuntimeEnvironmentId?: string
}
export type RuntimeMobileSessionBrowserTab = {
type: 'browser'
id: string
title: string
browserWorkspaceId: string
browserPageId: string | null
browserProfileId?: string
executionHostKey?: string
placement?: RuntimeBrowserPlacement
url: string
loading: boolean
canGoBack: boolean
canGoForward: boolean
loadError?: BrowserLoadError | null
certificateFailure?: BrowserCertificateFailure | null
color?: string | null
isPinned?: boolean
isActive: boolean
/** The paired server the page runs on. Its publisher sets it; runtimes strip it before serving. */
hostRuntimeEnvironmentId?: string
}
export type RuntimeMobileSessionAgentTab = {
type: 'agent-session'
id: string
title: string
sessionId: string
replacesSessionId?: string
/** Host-registered agent; gate names beyond Claude/Codex on client registered-agents capability. */
agent: StructuredAgentId
/** The host's structured status row for this chat. Optional: old hosts never send it. */
chatStatus?: RuntimeMobileSessionAgentTabStatus
color?: string | null
isPinned?: boolean
isActive: boolean
}
export type RuntimeMobileSessionAgentTabStatus = Pick<
AgentStatusEntry,
| 'state'
| 'workingMode'
| 'interrupted'
| 'mainAgent'
| 'updatedAt'
| 'evidenceObservedAt'
| 'structuredHostOwned'
>
export type RuntimeMobileSessionSnapshotTab =
| RuntimeMobileSessionTerminalTab
| RuntimeMobileSessionMarkdownTab
| RuntimeMobileSessionFileTab
| RuntimeMobileSessionBrowserTab
| RuntimeMobileSessionAgentTab
export type RuntimeMobileSessionTerminalClientTab =
| (RuntimeMobileSessionTerminalTab & { status: 'pending-handle'; terminal: null })
| (RuntimeMobileSessionTerminalTab & { status: 'ready'; terminal: string })
export type RuntimeMobileSessionClientTab =
| RuntimeMobileSessionTerminalClientTab
| RuntimeMobileSessionMarkdownTab
| RuntimeMobileSessionFileTab
| RuntimeMobileSessionBrowserTab
| RuntimeMobileSessionAgentTab