refactor: bind proxy process and session contracts to defining owners

This commit is contained in:
Neil
2026-11-08 23:33:04 -08:00
parent a5b61d1805
commit 8058ca342b
53 changed files with 173 additions and 207 deletions
@@ -4,10 +4,8 @@ import { join } from 'node:path'
import type { WebSocket } from 'ws'
import type { AgentStatusEntry } from '../../src/shared/agent-status/contracts/agent-status-types'
import type { NativeChatMessage } from '../../src/shared/native-chat/native-chat-types'
import type {
RuntimeMobileSessionTabsResult,
RuntimeMobileSessionTerminalClientTab
} from '../../src/shared/runtime-types'
import type { RuntimeMobileSessionTabsResult } from '../../src/shared/runtime-types'
import type { RuntimeMobileSessionTerminalClientTab } from '../../src/shared/runtime-mobile-session-tab-contracts'
import type { RpcRequest, RpcResponse } from './mock-server-rpc-handlers'
// Read send behavior from control file per request: restarting mock rekeys E2EE and forces re-pair, preventing mid-session native chat repros.
@@ -10,12 +10,12 @@ import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { TerminalFrame } from '../terminal-webview-messages'
import { TerminalWebView } from '../TerminalWebView'
import type {
MobileTerminalTheme,
TerminalKeyboardAvoidanceMetrics,
TerminalModes,
TerminalPointerInput,
TerminalWebViewHandle
} from '../terminal-webview-contract'
import type { RuntimeMobileTerminalTheme } from '../../../../src/shared/runtime-mobile-session-tab-contracts'
type TerminalPaneViewProps = {
handle: string
@@ -28,7 +28,7 @@ type TerminalPaneViewProps = {
title?: string
onFrame?: (handle: string, frame: TerminalFrame) => void
keyboardLift: number
terminalTheme?: MobileTerminalTheme
terminalTheme?: RuntimeMobileTerminalTheme
textScale: number
onRef: (handle: string, ref: TerminalWebViewHandle | null) => void
onWebReady: (handle: string) => void
@@ -1,4 +1,4 @@
import type { RuntimeMobileTerminalTheme as MobileTerminalTheme } from '../../../../src/shared/runtime-mobile-session-tab-contracts'
import type { RuntimeMobileTerminalTheme } from '../../../../src/shared/runtime-mobile-session-tab-contracts'
import type { AgentStatusEntry } from '../../../../src/shared/agent-status/contracts/agent-status-types'
import type { BrowserLoadError } from '../../../../src/shared/browser-workspace-types'
import { browserLoadErrorsEqual } from '../../../../src/shared/browser-load-failure'
@@ -7,7 +7,7 @@ import { translate } from '../../i18n/mobile-i18n'
export type TerminalRecord = {
handle: string
title: string
terminalTheme?: MobileTerminalTheme
terminalTheme?: RuntimeMobileTerminalTheme
isActive: boolean
/** From `terminal.list`; parked and proven-absent leaves report false. */
connected?: boolean
@@ -30,7 +30,7 @@ export type MobileTerminalSessionTab = {
/** Host-provided launch context still parked as an unsent TUI-input draft. */
launchDraft?: string
launchDraftCreatedAt?: number
terminalTheme?: MobileTerminalTheme
terminalTheme?: RuntimeMobileTerminalTheme
isActive: boolean
}
@@ -82,8 +82,8 @@ type MobileSessionTabLike =
}
export function mobileTerminalThemesEqual(
left: MobileTerminalTheme | null | undefined,
right: MobileTerminalTheme | null | undefined
left: RuntimeMobileTerminalTheme | null | undefined,
right: RuntimeMobileTerminalTheme | null | undefined
): boolean {
if (left === right) {
return true
@@ -1,5 +1,5 @@
import type { ParsedFileLinkLocation } from '../../../src/shared/file-links/file-link-location'
import type { RuntimeMobileTerminalTheme } from '../../../src/shared/runtime-types'
import type { RuntimeMobileTerminalTheme } from '../../../src/shared/runtime-mobile-session-tab-contracts'
import type { TerminalOscLinkRange } from '../../../src/shared/terminal/links/terminal-osc-link-ranges'
import type { StyleProp, ViewStyle } from 'react-native'
import type { TerminalFitDimensions } from './terminal-grid-fit'
@@ -61,8 +61,6 @@ function toNonNegativeInteger(value: unknown): number {
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.floor(value) : 0
}
export type MobileTerminalTheme = RuntimeMobileTerminalTheme
export type TerminalPointerInput = {
readonly click: boolean
}
@@ -89,7 +87,7 @@ export type TerminalSelectionEvents = {
export type TerminalWebViewProps = {
style?: StyleProp<ViewStyle>
terminalTheme?: MobileTerminalTheme
terminalTheme?: RuntimeMobileTerminalTheme
// Persistent font-size preset; transient CSS pinch zoom is committed into it on release.
textScale?: number
// Only initially shown views build pre-ready engines, limiting WebGL context use.
@@ -1,4 +1,4 @@
import type { RuntimeMobileTerminalTheme } from '../../../../src/shared/runtime-types'
import type { RuntimeMobileTerminalTheme } from '../../../../src/shared/runtime-mobile-session-tab-contracts'
import { colors } from '../../theme/mobile-theme'
export const DEFAULT_TERMINAL_THEME: RuntimeMobileTerminalTheme['theme'] = {
@@ -1,4 +1,4 @@
import type { RuntimeMobileTerminalTheme } from '../../../src/shared/runtime-types'
import type { RuntimeMobileTerminalTheme } from '../../../src/shared/runtime-mobile-session-tab-contracts'
import type { TerminalOscLinkRange } from '../../../src/shared/terminal/links/terminal-osc-link-ranges'
export type TerminalFrame = { width: number; height: number }
+3 -4
View File
@@ -1,12 +1,11 @@
import { BrowserWindow, ipcMain } from 'electron'
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
import type {
RuntimeBrowserDriverState,
RuntimeRendererSyncWindowGraph,
RuntimeStatus,
RuntimeSyncWindowGraphResult,
RuntimeTerminalDriverState
RuntimeSyncWindowGraphResult
} from '../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../shared/runtime-session-contracts'
import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
import type { ClientHostedBrowserRowsEvent } from '../../shared/client-hosted-browser-rows'
import { TERMINAL_FIT_RESTORE_DEADLINE_MS } from '../../shared/terminal/viewport/terminal-fit-restore-deadline'
@@ -178,7 +177,7 @@ export function registerRuntimeHandlers(runtime: OrcaRuntimeService): void {
ipcMain.removeHandler('runtime:getBrowserDrivers')
ipcMain.handle(
'runtime:getBrowserDrivers',
(): { browserPageId: string; driver: RuntimeBrowserDriverState }[] => {
(): { browserPageId: string; driver: RuntimeTerminalDriverState }[] => {
const drivers = runtime.getAllBrowserDrivers()
return Array.from(drivers.entries()).map(([browserPageId, driver]) => ({
browserPageId,
-2
View File
@@ -17,8 +17,6 @@ import { runBoundedProxyApplication } from './bounded-proxy-application'
import { defaultProxySession, type ProxySession } from './electron-default-proxy-session'
import { resolveProxyPolicyWithoutSession, type ProxyApplyResult } from './proxy-policy-resolution'
export { setDefaultProxySessionResolver } from './electron-default-proxy-session'
export type { ProxyApplyResult } from './proxy-policy-resolution'
const PROXY_PROBE_URL = 'https://api.anthropic.com/'
type SessionProxyApplicationState = {
appliedKey: string | null
@@ -1,24 +1,24 @@
import type { RuntimeBrowserDriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
type RuntimeBrowserDriverControllerDeps = {
notifyChanged: (browserPageId: string, next: RuntimeBrowserDriverState) => void
notifyChanged: (browserPageId: string, next: RuntimeTerminalDriverState) => void
cancelScreencast: (browserPageId: string) => void
}
export class RuntimeBrowserDriverController {
private readonly drivers = new Map<string, RuntimeBrowserDriverState>()
private readonly drivers = new Map<string, RuntimeTerminalDriverState>()
constructor(private readonly deps: RuntimeBrowserDriverControllerDeps) {}
getAll(): Map<string, RuntimeBrowserDriverState> {
getAll(): Map<string, RuntimeTerminalDriverState> {
return new Map(this.drivers)
}
get(browserPageId: string): RuntimeBrowserDriverState {
get(browserPageId: string): RuntimeTerminalDriverState {
return this.drivers.get(browserPageId) ?? { kind: 'idle' }
}
set(browserPageId: string, next: RuntimeBrowserDriverState): void {
set(browserPageId: string, next: RuntimeTerminalDriverState): void {
const prev = this.get(browserPageId)
if (prev.kind === next.kind) {
if (prev.kind === 'mobile' && next.kind === 'mobile' && prev.clientId === next.clientId) {
@@ -1,4 +1,4 @@
import type { RuntimeBrowserDriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
export type BrowserScreencastSubscriber = {
cancel: (emitEnd?: boolean) => void
@@ -16,7 +16,7 @@ export function screencastSubscriberDrivesAsMobile(
export function resolveBrowserDriverAfterMobileRelease(
remaining: Iterable<BrowserScreencastSubscriber>
): RuntimeBrowserDriverState {
): RuntimeTerminalDriverState {
let fallback: BrowserScreencastSubscriber | null = null
for (const subscriber of remaining) {
if (subscriber.drivesAsMobile) {
@@ -1,6 +1,6 @@
import { expect, vi } from 'vitest'
import { OrcaRuntimeService } from '../../orca-runtime'
import type { RuntimeBrowserDriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
export const HARNESS_WORKTREE_ID = 'repo-1::/tmp/worktree-a'
export const HARNESS_PAGE_ID = 'page-1'
@@ -48,7 +48,7 @@ export type ScreencastHarness = {
connectionId: string
clientKind?: 'mobile' | 'runtime'
}) => ScreencastSubscriber
driver: () => RuntimeBrowserDriverState | undefined
driver: () => RuntimeTerminalDriverState | undefined
}
/** Drive production subscription state with fake Chromium sessions. */
@@ -1,5 +1,5 @@
import type { BrowserScreencastResult } from '../../../../shared/browser/runtime/runtime-browser-contracts'
import type { RuntimeBrowserDriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { BrowserError } from '../../../browser/browser-error'
import {
resolveBrowserDriverAfterMobileRelease,
@@ -17,8 +17,8 @@ type RuntimeBrowserScreencastControllerDeps = {
connectionId?: string
) => void
cleanupSubscription: (subscriptionId: string) => void
getDriver: (browserPageId: string) => RuntimeBrowserDriverState
setDriver: (browserPageId: string, next: RuntimeBrowserDriverState) => void
getDriver: (browserPageId: string) => RuntimeTerminalDriverState
setDriver: (browserPageId: string, next: RuntimeTerminalDriverState) => void
notifyRemoteViewersChanged: (browserPageId: string, hasRemoteViewers: boolean) => void
}
@@ -29,7 +29,6 @@ import type {
import type { CreateWorktreeResult } from '../../../../shared/worktree/create-types'
import type { WorktreeStartupLaunch } from '../../../../shared/worktree/launch-types'
import type {
RuntimeBrowserDriverState,
RuntimeMobileSessionTabMove,
RuntimeTerminalDriverState
} from '../../../../shared/runtime-session-contracts'
@@ -39,8 +38,6 @@ import type {
AgentPaneActivityChange
} from '../../../../shared/agent-status/presentation/agent-list-status'
type DriverState = RuntimeTerminalDriverState
export type RuntimeNotifier = {
automationsChanged?(payload: {
selector?: { kind: 'self' } | { kind: 'ssh'; targetId: string } | { kind: 'orphan' }
@@ -187,12 +184,12 @@ export type RuntimeNotifier = {
rows: number
): void
// Publish driver/clientId so the lock banner distinguishes mobile actors; boolean lock state loses identity (docs/mobile-presence-lock.md).
terminalDriverChanged(ptyId: string, driver: DriverState): void
terminalDriverChanged(ptyId: string, driver: RuntimeTerminalDriverState): void
nativeChatLaunchDraftResolved?(
tabId: string,
resolution: { text: string; createdAt: number }
): void
browserDriverChanged?(browserPageId: string, driver: RuntimeBrowserDriverState): void
browserDriverChanged?(browserPageId: string, driver: RuntimeTerminalDriverState): void
browserRemoteViewersChanged?(browserPageId: string, hasRemoteViewers: boolean): void
clientHostedBrowserRowsChanged?(event: ClientHostedBrowserRowsEvent): void
claudeAccountSelected?(change: ClaudeAccountSelectionChange): void
@@ -7,7 +7,7 @@ import type { RpcCallerIdentity } from '../../rpc-caller-identity'
import { InvalidArgumentError } from '../../core'
import type { RuntimeTerminalSend } from '../../../../../shared/runtime-terminal-send-contract'
import type { OrcaRuntimeService } from '../../../orca-runtime'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../../shared/runtime-session-contracts'
import {
TERMINAL_INPUT_MAX_BYTES,
TERMINAL_INPUT_TOO_LARGE_ERROR,
@@ -54,7 +54,7 @@ export async function assertTerminalSendTextWithinLimit(text: string | undefined
}
export function resolveMobileFloorClientId(
driver: DriverState | null,
driver: RuntimeTerminalDriverState | null,
client: TerminalViewportClient | undefined
): string | null {
if (client?.type === 'mobile') {
@@ -11,8 +11,6 @@ import type {
RuntimeMobileSessionTabsSnapshot
} from '../../../shared/runtime-session-contracts'
type Row = RuntimeMobileSessionSnapshotTab
/** Main's projection of the rows (projectSessionTabs): the snapshot minus the runtime's stamps. */
export type MainSessionTabRows = Omit<
RuntimeMobileSessionTabsSnapshot,
@@ -20,7 +18,7 @@ export type MainSessionTabRows = Omit<
>
/** Merge window facts into terminal/edit rows; keep window browser/chat/diff/preview rows whole while listed, including diff-draft dirty state. */
function isMainRow(row: Row): boolean {
function isMainRow(row: RuntimeMobileSessionSnapshotTab): boolean {
return (
row.type === 'terminal' ||
(row.type === 'file' && row.mode !== 'diff') ||
@@ -29,7 +27,7 @@ function isMainRow(row: Row): boolean {
}
/** A terminal row with a manual name: its tab's custom title or its pane's own title. */
function isNamed(row: Extract<Row, { type: 'terminal' }>): boolean {
function isNamed(row: Extract<RuntimeMobileSessionSnapshotTab, { type: 'terminal' }>): boolean {
return !!row.customTitle || !!row.parentLayout?.titlesByLeafId?.[row.leafId]?.trim()
}
@@ -62,7 +60,11 @@ function keepsWindowPtyId(
}
/** Use window-only fields and pending terminal bindings until main catches up; main's certified exit overrides the window's old terminal id. */
function withWindowFacts(row: Row, windowRow: Row | undefined, rules: MergeRules): Row {
function withWindowFacts(
row: RuntimeMobileSessionSnapshotTab,
windowRow: RuntimeMobileSessionSnapshotTab | undefined,
rules: MergeRules
): RuntimeMobileSessionSnapshotTab {
if (row.type === 'terminal' && windowRow?.type === 'terminal') {
return {
...row,
@@ -100,10 +102,10 @@ function withWindowFacts(row: Row, windowRow: Row | undefined, rules: MergeRules
/** Main's rows in main's order, each window-only row after the row it follows in the window's. */
function withWindowOnlyRows(
rows: Row[],
windowRows: readonly Row[],
rows: RuntimeMobileSessionSnapshotTab[],
windowRows: readonly RuntimeMobileSessionSnapshotTab[],
windowOnly: ReadonlySet<string>
): Row[] {
): RuntimeMobileSessionSnapshotTab[] {
const merged = [...rows]
windowRows.forEach((row, index) => {
if (!windowOnly.has(row.id)) {
@@ -162,7 +164,7 @@ export function withMainSessionTabRows(
const shown = !mainRetiredSelection ? windowGroups.get(group.id)?.activeTabId : undefined
return shown !== undefined ? { ...group, activeTabId: shown } : group
})
const activeGroupIndex = (activeRow: Row | undefined): number => {
const activeGroupIndex = (activeRow: RuntimeMobileSessionSnapshotTab | undefined): number => {
const byRow = activeRow
? tabGroups.findIndex((group) => group.tabOrder.includes(orderIdOf(activeRow)))
: -1
@@ -1,42 +1,40 @@
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { notifyRuntimeListeners } from '../../events/runtime-listener-delivery'
type DriverState = RuntimeTerminalDriverState
type RuntimeTerminalDriverDependencies = {
notifyChanged: (ptyId: string, next: DriverState) => void
notifyChanged: (ptyId: string, next: RuntimeTerminalDriverState) => void
canClaimMobileFloor: (ptyId: string, clientId: string) => boolean
commitMobileFloor: (
ptyId: string,
clientId: string,
previousFloor: DriverState,
previousFloor: RuntimeTerminalDriverState,
isCurrent: () => boolean
) => Promise<void>
}
type MobileInputFloorState = {
base: DriverState
base: RuntimeTerminalDriverState
generation: number
committedGeneration: number
pending: Map<symbol, { clientId: string; generation: number }>
}
export class RuntimeTerminalDriverController {
private readonly current = new Map<string, DriverState>()
private readonly listeners = new Map<string, Set<(driver: DriverState) => void>>()
private readonly current = new Map<string, RuntimeTerminalDriverState>()
private readonly listeners = new Map<string, Set<(driver: RuntimeTerminalDriverState) => void>>()
private readonly inputFloorClaims = new Map<string, MobileInputFloorState>()
constructor(private readonly deps: RuntimeTerminalDriverDependencies) {}
get(ptyId: string): DriverState {
get(ptyId: string): RuntimeTerminalDriverState {
return this.current.get(ptyId) ?? { kind: 'idle' }
}
getAll(): Map<string, DriverState> {
getAll(): Map<string, RuntimeTerminalDriverState> {
return new Map(this.current)
}
set(ptyId: string, next: DriverState): void {
set(ptyId: string, next: RuntimeTerminalDriverState): void {
// A desktop reclaim or disconnect supersedes unfinished mobile input.
if (next.kind !== 'mobile') {
this.inputFloorClaims.delete(ptyId)
@@ -71,8 +69,9 @@ export class RuntimeTerminalDriverController {
return true
}
subscribe(ptyId: string, listener: (driver: DriverState) => void): () => void {
const listeners = this.listeners.get(ptyId) ?? new Set<(driver: DriverState) => void>()
subscribe(ptyId: string, listener: (driver: RuntimeTerminalDriverState) => void): () => void {
const listeners =
this.listeners.get(ptyId) ?? new Set<(driver: RuntimeTerminalDriverState) => void>()
listeners.add(listener)
this.listeners.set(ptyId, listeners)
return () => {
@@ -20,7 +20,7 @@ import type {
import type { ExactWorkerProviderSession } from '../../../../shared/orchestration/workers/orchestration-worker-output'
import type { RuntimeProviderSnapshotReadOptions } from '../output/provider-snapshot-read-options'
import { OrcaRuntimeWithFitOverrideListeners } from '../lifecycle/terminal-view-resources'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import type {
ApplyLayoutResult,
PtyLayoutTarget,
@@ -121,7 +121,7 @@ export abstract class OrcaRuntimeWithTerminalDrivers extends OrcaRuntimeWithFitO
providerSnapshot?: RuntimeProviderSnapshotReadOptions
): Promise<RuntimeTerminalRead>
abstract getDriver(ptyId: string): DriverState
abstract getDriver(ptyId: string): RuntimeTerminalDriverState
protected abstract enqueueLayout(
ptyId: string,
target: PtyLayoutTarget
@@ -129,7 +129,7 @@ export abstract class OrcaRuntimeWithTerminalDrivers extends OrcaRuntimeWithFitO
abstract mobileTookFloor(
ptyId: string,
clientId: string,
previousFloor?: DriverState,
previousFloor?: RuntimeTerminalDriverState,
isCurrent?: () => boolean
): Promise<void>
protected abstract resolveDesktopRestoreTarget(ptyId: string): { cols: number; rows: number }
@@ -1,6 +1,6 @@
import { OrcaRuntimeWithMarkPtyLivenessUnverifiable } from './terminal-input-floor'
import type { ApplyLayoutResult } from './terminal-layout-state'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { clampTerminalViewport } from '../../../../shared/terminal/viewport/terminal-viewport'
export abstract class OrcaRuntimeWithMobileTookFloor extends OrcaRuntimeWithMarkPtyLivenessUnverifiable {
@@ -11,7 +11,7 @@ export abstract class OrcaRuntimeWithMobileTookFloor extends OrcaRuntimeWithMark
async mobileTookFloor(
ptyId: string,
clientId: string,
previousFloor?: DriverState,
previousFloor?: RuntimeTerminalDriverState,
isCurrent?: () => boolean
): Promise<void> {
if (!isCurrent) {
@@ -1,5 +1,5 @@
import { OrcaRuntimeWithHasRecentTerminalOutputPath } from '../output/terminal-output-path'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeFileCommandSurface } from '../../construction/runtime-file-command-surface'
export abstract class OrcaRuntimeWithOnClientDisconnected extends OrcaRuntimeWithHasRecentTerminalOutputPath {
@@ -7,7 +7,7 @@ export abstract class OrcaRuntimeWithOnClientDisconnected extends OrcaRuntimeWit
protected abstract pickMostRecentActor(
inner: Map<string, { clientId: string; lastActedAt: number }>
): { clientId: string; lastActedAt: number } | null
protected abstract setDriver(ptyId: string, next: DriverState): void
protected abstract setDriver(ptyId: string, next: RuntimeTerminalDriverState): void
abstract applyRemoteDesktopLayout(ptyId: string): Promise<boolean>
protected abstract getAutoRestoreFitMs(): number | null
@@ -1,6 +1,6 @@
import { OrcaRuntimeWithOnPtyExit } from '../lifecycle/pty-exit-lifecycle'
import type { PtyLivenessVerdict } from '../../../../shared/terminal/pty/lifecycle/pty-liveness-verdict'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import {
isDrivingInputKind,
type TerminalInputKind
@@ -158,11 +158,11 @@ export abstract class OrcaRuntimeWithMarkPtyLivenessUnverifiable extends OrcaRun
this.ptyLivenessVerdictByPtyId.delete(ptyId)
}
getDriver(ptyId: string): DriverState {
getDriver(ptyId: string): RuntimeTerminalDriverState {
return this.terminalDrivers.get(ptyId)
}
protected setDriver(ptyId: string, next: DriverState): void {
protected setDriver(ptyId: string, next: RuntimeTerminalDriverState): void {
this.terminalDrivers.set(ptyId, next)
}
@@ -5,7 +5,7 @@ import type { PtyProviderBufferSnapshot } from '../../../providers/pty-provider-
import type { RuntimeTerminalWriteOptions } from '../input/runtime-terminal-writer'
import type { WriteSettlement } from '../../../../shared/terminal/pty/lifecycle/pty-write-settlement'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { addListenerToMap } from './terminal-listener-map'
import { notifyRuntimeListeners } from '../../events/runtime-listener-delivery'
import type { RuntimeTerminalAttention } from '../../../../shared/runtime-terminal-contracts'
@@ -222,7 +222,10 @@ export abstract class OrcaRuntimeWithNotifyRemoteTerminalViewPresenceChanged ext
return addListenerToMap(this.fitOverrideListeners, ptyId, listener)
}
subscribeToDriverChanges(ptyId: string, listener: (driver: DriverState) => void): () => void {
subscribeToDriverChanges(
ptyId: string,
listener: (driver: RuntimeTerminalDriverState) => void
): () => void {
return this.terminalDrivers.subscribe(ptyId, listener)
}
@@ -1,5 +1,5 @@
import type { ApplyLayoutResult, PtyLayoutTarget } from '../layout/terminal-layout-state'
import type { RuntimeTerminalDriverState as DriverState } from '../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { OrcaRuntimeWithGetOrchestrationDispatchAuthority } from './terminal-orchestration-authority'
import { clampTerminalViewport } from '../../../../shared/terminal/viewport/terminal-viewport'
@@ -11,7 +11,7 @@ export abstract class OrcaRuntimeWithHasRecentTerminalOutputPath extends OrcaRun
abstract mobileTookFloor(
ptyId: string,
clientId: string,
previousFloor?: DriverState,
previousFloor?: RuntimeTerminalDriverState,
isCurrent?: () => boolean
): Promise<void>
protected abstract resolveDesktopRestoreTarget(ptyId: string): { cols: number; rows: number }
@@ -153,7 +153,7 @@ export abstract class OrcaRuntimeWithHasRecentTerminalOutputPath extends OrcaRun
return result
}
getAllTerminalDrivers(): Map<string, DriverState> {
getAllTerminalDrivers(): Map<string, RuntimeTerminalDriverState> {
return this.terminalDrivers.getAll()
}
+1 -1
View File
@@ -71,7 +71,7 @@ import { electronSpeechServiceFactories } from '../host/electron-speech-services
import { setSpeechServiceFactories } from '../speech/speech-runtime-service'
import { setWorktreeWatcherRemoval } from '../workspaces/removal/worktree-watcher-removal'
import { desktopWorktreeWatcherRemoval } from '../ipc/filesystem/watchers/filesystem-watcher'
import { setDefaultProxySessionResolver } from '../network/proxy-settings'
import { setDefaultProxySessionResolver } from '../network/electron-default-proxy-session'
import { initDataPath, getCanonicalUserDataPath } from '../persistence/loading-store/user-data-path'
import { applyMacPressAndHoldDefaultAtStartup } from '../window/desktop-integration/macos-press-and-hold-default'
import { configureSessionParseCachePersistence } from '../ai-vault/parse-cache/session-parse-cache-persistence'
@@ -6,7 +6,7 @@ import { producePromptRecords } from './source-control-prompt-producer'
import { argumentBudgetFailure } from './source-control-command-line-budget'
export { fitsLocalCommandLine } from './source-control-command-line-budget'
import { removeTree } from '../../shared/windows-transient-lock-removal'
import { WindowsCmdLineBreakError } from '@orca/process-host'
import { WindowsCmdLineBreakError } from '@orca/process-host/windows-command-line'
import { WindowsCommandLineBudgetError } from '../../shared/windows-command-line-budget'
import { supervisedProviderSpawnFailure } from '../provider-process/provider-spawn-failure-report'
import {
@@ -12,8 +12,6 @@ import { hasSpawnObserver, notifySpawnObserver } from './spawn-observer'
import { createOutputSink } from './bounded-output-sink'
import { createChildTerminationReporter } from './child-termination-reporter'
export { WindowsCmdLineBreakError } from './windows-command-line'
import type { PipedProcessSpec, ProcessSpec, ProcessResult } from './process-spec'
import { DEFAULT_PROCESS_TIMEOUT_MS, DEFAULT_MAX_OUTPUT_BYTES } from './process-spec'
// Bound waits for children that ignore termination and never emit close.
+4 -5
View File
@@ -7,11 +7,10 @@ import type { ManagedOrcadPreloadApi } from './managed-orcad-api'
import type { WslHostsPreloadApi } from './wsl-hosts-api'
import type { RuntimeHostStatusSnapshot } from '../../shared/remote-runtime/host-status/runtime-host-status'
import type {
RuntimeBrowserDriverState,
RuntimeRendererSyncWindowGraph,
RuntimeSyncWindowGraphResult,
RuntimeTerminalDriverState
RuntimeSyncWindowGraphResult
} from '../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../shared/runtime-session-contracts'
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
import type { ClientHostedBrowserRowsEvent } from '../../shared/client-hosted-browser-rows'
@@ -56,7 +55,7 @@ export type RuntimeApi = {
getBrowserDrivers: () => Promise<
{
browserPageId: string
driver: RuntimeBrowserDriverState
driver: RuntimeTerminalDriverState
}[]
>
getBrowserRemoteViewerPages?: () => Promise<string[]>
@@ -78,7 +77,7 @@ export type RuntimeApi = {
callback: (event: { tabId: string; text: string; createdAt: number }) => void
) => () => void
onBrowserDriverChanged: (
callback: (event: { browserPageId: string; driver: RuntimeBrowserDriverState }) => void
callback: (event: { browserPageId: string; driver: RuntimeTerminalDriverState }) => void
) => () => void
// Older preloads lack this signal.
onBrowserRemoteViewersChanged?: (
+5 -6
View File
@@ -2,12 +2,11 @@ import { ipcRenderer } from 'electron'
import type { ClientHostedBrowserRowsEvent } from '../../shared/client-hosted-browser-rows'
import type { SidebarInputsChangedEvent } from '../../shared/sidebar-list/sidebar-inputs-feed-contract'
import type {
RuntimeBrowserDriverState,
RuntimeRendererSyncWindowGraph,
RuntimeStatus,
RuntimeSyncWindowGraphResult,
RuntimeTerminalDriverState
RuntimeSyncWindowGraphResult
} from '../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../shared/runtime-session-contracts'
import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
import type { RuntimeEnvironmentSubscriptionHandle } from '../runtime-environment-subscriptions'
import type { PreloadApi } from '../api-types'
@@ -55,7 +54,7 @@ export const runtimeApi = {
getBrowserDrivers: (): Promise<
{
browserPageId: string
driver: RuntimeBrowserDriverState
driver: RuntimeTerminalDriverState
}[]
> => ipcRenderer.invoke('runtime:getBrowserDrivers'),
getBrowserRemoteViewerPages: (): Promise<string[]> =>
@@ -110,13 +109,13 @@ export const runtimeApi = {
return () => ipcRenderer.removeListener('runtime:nativeChatLaunchDraftResolved', listener)
},
onBrowserDriverChanged: (
callback: (event: { browserPageId: string; driver: RuntimeBrowserDriverState }) => void
callback: (event: { browserPageId: string; driver: RuntimeTerminalDriverState }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: {
browserPageId: string
driver: RuntimeBrowserDriverState
driver: RuntimeTerminalDriverState
}
) => callback(data)
ipcRenderer.on('runtime:browserDriverChanged', listener)
@@ -1,11 +1,11 @@
import { useCallback, useRef, useState, type ReactElement } from 'react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import type { BrowserDriverState } from '@/lib/pane-manager/browser-mobile-driver-state'
import type { RuntimeTerminalDriverState } from '../../../../../shared/runtime-session-contracts'
import { useTranslate } from '@/i18n/use-translate'
type Props = {
driver: BrowserDriverState
driver: RuntimeTerminalDriverState
onTakeBack: () => void | Promise<void>
}
@@ -1,7 +1,9 @@
import type { DriverState } from '@/lib/pane-manager/mobile-driver-state'
import type { RuntimeTerminalDriverState } from '../../../../../shared/runtime-session-contracts'
/** Mirror terminal mobile-driver locks; unresolved driver state stays usable until send-time PTY validation. */
export function deriveNativeChatCanSend(driver: DriverState | null | undefined): boolean {
export function deriveNativeChatCanSend(
driver: RuntimeTerminalDriverState | null | undefined
): boolean {
return driver?.kind !== 'mobile'
}
@@ -1,4 +1,4 @@
import type { RuntimeTerminalDriverState as DriverState } from '../../../../../shared/runtime-session-contracts'
import type { RuntimeTerminalDriverState } from '../../../../../shared/runtime-session-contracts'
import { useCallback, useEffect, useId, useRef, useState, type ReactElement } from 'react'
import { Minimize2, Smartphone } from 'lucide-react'
import { Button } from '@/components/ui/button'
@@ -13,7 +13,7 @@ import {
import { useTranslate } from '@/i18n/use-translate'
type Props = {
driver: DriverState
driver: RuntimeTerminalDriverState
hasFitOverride: boolean
onAction: () => void | Promise<void>
onAllAction?: () => void | Promise<void>
@@ -11,10 +11,7 @@ import type { ClientHostedBrowserRowsEvent } from '../../../../shared/client-hos
import { setDriverForPty, hydrateDrivers } from '@/lib/pane-manager/mobile-driver-state'
import { setFitOverride, hydrateOverrides } from '@/lib/pane-manager/mobile-fit-overrides'
import { applyNativeChatLaunchDraftResolved } from '@/runtime/native-chat/launch-drafts/native-chat-launch-draft-runtime-resolution'
import type {
RuntimeBrowserDriverState,
RuntimeTerminalDriverState
} from '../../../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
import { useAppStore } from '../../store/index'
const MAX_PENDING_MOBILE_STATE_EVENTS = 300
@@ -32,7 +29,7 @@ type PendingMobileStateEvent =
| { kind: 'driver'; event: { ptyId: string; driver: RuntimeTerminalDriverState } }
| {
kind: 'browser-driver'
event: { browserPageId: string; driver: RuntimeBrowserDriverState }
event: { browserPageId: string; driver: RuntimeTerminalDriverState }
}
export function registerMobileDriverIpcBridge(
@@ -1,17 +1,15 @@
import { useSyncExternalStore } from 'react'
import { recomputeOn } from '@/lib/recompute-on'
import type { RuntimeBrowserDriverState } from '../../../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
export type BrowserDriverState = RuntimeBrowserDriverState
const driverByBrowserPageId = new Map<string, BrowserDriverState>()
const driverByBrowserPageId = new Map<string, RuntimeTerminalDriverState>()
// Why: a shared instance keeps getDriverForBrowserPage referentially stable for useSyncExternalStore snapshots.
export const IDLE_BROWSER_DRIVER: BrowserDriverState = { kind: 'idle' }
export const IDLE_BROWSER_DRIVER: RuntimeTerminalDriverState = { kind: 'idle' }
type BrowserDriverChangeEvent = {
browserPageId: string
driver: BrowserDriverState
driver: RuntimeTerminalDriverState
}
type BrowserDriverChangeListener = (event: BrowserDriverChangeEvent) => void
@@ -49,7 +47,10 @@ function notifyChange(event: BrowserDriverChangeEvent): void {
}
}
export function setDriverForBrowserPage(browserPageId: string, driver: BrowserDriverState): void {
export function setDriverForBrowserPage(
browserPageId: string,
driver: RuntimeTerminalDriverState
): void {
if (driver.kind === 'idle') {
driverByBrowserPageId.delete(browserPageId)
} else {
@@ -58,13 +59,13 @@ export function setDriverForBrowserPage(browserPageId: string, driver: BrowserDr
notifyChange({ browserPageId, driver })
}
export function getDriverForBrowserPage(browserPageId: string): BrowserDriverState {
export function getDriverForBrowserPage(browserPageId: string): RuntimeTerminalDriverState {
return driverByBrowserPageId.get(browserPageId) ?? IDLE_BROWSER_DRIVER
}
export function useBrowserDriverForPage(
browserPageId: string | null | undefined
): BrowserDriverState {
): RuntimeTerminalDriverState {
const storeVersion = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
return recomputeOn([storeVersion], () =>
browserPageId ? getDriverForBrowserPage(browserPageId) : IDLE_BROWSER_DRIVER
@@ -108,7 +109,7 @@ export function useBrowserMobileDrivenPageIds(
}
export function hydrateBrowserDrivers(
drivers: { browserPageId: string; driver: BrowserDriverState }[]
drivers: { browserPageId: string; driver: RuntimeTerminalDriverState }[]
): void {
const affectedPageIds = new Set(driverByBrowserPageId.keys())
driverByBrowserPageId.clear()
@@ -1,14 +1,12 @@
// Mirror runtime PTY driver presence from IPC: mobile ownership locks xterm input/resize and shows Take back (mobile-presence-lock.md).
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-types'
import type { RuntimeTerminalDriverState } from '../../../../shared/runtime-session-contracts'
export type DriverState = RuntimeTerminalDriverState
const driverByPtyId = new Map<string, DriverState>()
const driverByPtyId = new Map<string, RuntimeTerminalDriverState>()
type DriverChangeEvent = {
ptyId: string
driver: DriverState
driver: RuntimeTerminalDriverState
}
type DriverChangeListener = (event: DriverChangeEvent) => void
const changeListeners = new Set<DriverChangeListener>()
@@ -24,7 +22,7 @@ function notifyChange(event: DriverChangeEvent): void {
}
}
export function setDriverForPty(ptyId: string, driver: DriverState): void {
export function setDriverForPty(ptyId: string, driver: RuntimeTerminalDriverState): void {
if (driver.kind === 'idle') {
driverByPtyId.delete(ptyId)
} else {
@@ -45,11 +43,11 @@ export function replaceDriverPtyId(replacedPtyId: string, ptyId: string): void {
setDriverForPty(replacedPtyId, { kind: 'idle' })
}
export function getDriverForPty(ptyId: string): DriverState {
export function getDriverForPty(ptyId: string): RuntimeTerminalDriverState {
return driverByPtyId.get(ptyId) ?? { kind: 'idle' }
}
export function getAllDrivers(): Map<string, DriverState> {
export function getAllDrivers(): Map<string, RuntimeTerminalDriverState> {
return new Map(driverByPtyId)
}
@@ -57,7 +55,9 @@ export function isPtyLocked(ptyId: string): boolean {
return driverByPtyId.get(ptyId)?.kind === 'mobile'
}
export function hydrateDrivers(drivers: { ptyId: string; driver: DriverState }[]): void {
export function hydrateDrivers(
drivers: { ptyId: string; driver: RuntimeTerminalDriverState }[]
): void {
const affectedPtyIds = new Set(driverByPtyId.keys())
driverByPtyId.clear()
@@ -28,7 +28,6 @@ export type TerminalOrphanRecoveryState = WebTerminalOrphanTopologyState & {
tabsByWorktree: Record<string, TerminalTab[]>
}
export type TerminalSurface = RuntimeMobileSessionTerminalClientTab
export type RecoveryDisposition = 'claim' | 'retain' | 'remove'
type RecoverySurfaceCoordinates = {
@@ -36,7 +35,7 @@ type RecoverySurfaceCoordinates = {
leafId: string
surfaceKey: string
localTab: TerminalTab
incoming?: TerminalSurface
incoming?: RuntimeMobileSessionTerminalClientTab
pending: boolean
expectedPtyId: string | null
locallyActive: boolean
@@ -166,7 +165,9 @@ export function prepareTerminalOrphanRecovery(
return { candidates, unresolved, observed, retained }
}
export function buildRetainedTerminalSurface(surface: AnyRecoverySurface): TerminalSurface {
export function buildRetainedTerminalSurface(
surface: AnyRecoverySurface
): RuntimeMobileSessionTerminalClientTab {
const incoming = surface.incoming
const localTitle = typeof surface.localTab.title === 'string' ? surface.localTab.title.trim() : ''
// Why: a ready row counts as a live terminal, so a slept pane (#30108) would wake in the mirror.
@@ -190,7 +191,7 @@ export function buildRetainedTerminalSurface(surface: AnyRecoverySurface): Termi
terminal: null
}
}
const base: TerminalSurface = incoming ?? {
const base: RuntimeMobileSessionTerminalClientTab = incoming ?? {
type: 'terminal',
id: `${surface.tabId}::${surface.leafId}`,
parentTabId: surface.tabId,
@@ -1,10 +1,8 @@
import type { MobileProjectSectionCatalog } from '../../../../shared/mobile-project-sections-contract'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../shared/non-secure-context-uuid'
import type { AppState } from '@/store/types'
import type {
RuntimeMobileSessionSnapshotTab,
RuntimeMobileSessionTabsSnapshot
} from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionTabsSnapshot } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionSnapshotTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import type {
BrowserPagesProjectionCache,
BrowserWorkspacesProjectionCache,
@@ -11,7 +11,7 @@ import {
} from '../web-session-tabs-sync/testing/web-session-tabs-sync.test-fixture'
import { buildMobileSessionTabSnapshots } from './mobile-session-snapshots'
import { getRuntimeMobileSessionSyncKey, runtimeMobileSessionSyncKeysEqual } from './sync-key'
import type { RuntimeMobileSessionFileTab } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionFileTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
vi.mock('../../store', () => ({ useAppStore: { setState: vi.fn() } }))
@@ -1,5 +1,5 @@
import type { AppState } from '@/store/types'
import type { RuntimeMobileSessionBrowserTab } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionBrowserTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import type { Tab } from '../../../../shared/tab-types'
import { editorRowHost } from '../../../../shared/workspace-session/session-tab-file-host'
import { remoteTabFaviconUrl } from '../../../../shared/browser/browser-favicon-url'
@@ -2,7 +2,7 @@ import type { AppState } from '@/store/types'
import type {
RuntimeMobileSessionFileTab,
RuntimeMobileSessionMarkdownTab
} from '../../../../shared/runtime-types'
} from '../../../../shared/runtime-mobile-session-tab-contracts'
import type { Tab } from '../../../../shared/tab-types'
import { editorRowHost } from '../../../../shared/workspace-session/session-tab-file-host'
import type { MobileSessionWorktreeInputs } from './types'
@@ -1,9 +1,7 @@
import { getSystemPrefersDark } from '@/lib/terminal-theme'
import type { AppState } from '@/store/types'
import type {
RuntimeMobileSessionSnapshotTab,
RuntimeMobileSessionTabsSnapshot
} from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionTabsSnapshot } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionSnapshotTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import { parseWorkspaceKey } from '../../../../shared/workspace-scope'
import {
collectAmbiguousTerminalTabIds,
@@ -1,6 +1,6 @@
import { getSystemPrefersDark, resolveEffectiveTerminalAppearance } from '@/lib/terminal-theme'
import type { AppState } from '@/store/types'
import type { RuntimeMobileTerminalTheme } from '../../../../shared/runtime-types'
import type { RuntimeMobileTerminalTheme } from '../../../../shared/runtime-mobile-session-tab-contracts'
import '../../../../shared/terminal-themes/terminal-contrast-correction'
import { normalizeTerminalMinimumContrastRatio } from '../../../../shared/terminal-themes/terminal-minimum-contrast-settings'
@@ -1,5 +1,5 @@
import type { AppState } from '@/store/types'
import type { RuntimeMobileTerminalTheme } from '../../../../shared/runtime-types'
import type { RuntimeMobileTerminalTheme } from '../../../../shared/runtime-mobile-session-tab-contracts'
import type { TabGroupLayoutNode } from '../../../../shared/tab-types'
import type { TerminalPaneLayoutNode } from '../../../../shared/workspace-layout/terminal-tab-types'
@@ -11,10 +11,10 @@ import {
import type { TerminalTab } from '../../../../shared/workspace-layout/terminal-tab-types'
import type {
MirroredTerminalTab,
TerminalSurface,
WebSessionTabsBatchContext,
WebSessionTabsSyncState
} from './state'
import type { RuntimeMobileSessionTerminalClientTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import {
isClientOwnedAgentStatus,
isMirroredAgentStatusOwnedBy,
@@ -35,7 +35,7 @@ import {
export function buildMirroredAgentStatusPatch(
state: WebSessionTabsSyncState,
currentTerminalTabs: readonly TerminalTab[],
terminalSurfaceTabs: readonly TerminalSurface[],
terminalSurfaceTabs: readonly RuntimeMobileSessionTerminalClientTab[],
mirroredTerminalTabs: readonly MirroredTerminalTab[],
environmentId: string,
worktreeId: string,
@@ -58,7 +58,7 @@ export function buildMirroredAgentStatusPatch(
}
let retainedSurfaceByHostTabAndPrunedLeafId:
| Map<string, ReadonlyMap<string, TerminalSurface>>
| Map<string, ReadonlyMap<string, RuntimeMobileSessionTerminalClientTab>>
| undefined
for (const entry of mirroredTerminalTabs) {
if (entry.retainedSurfaceByPrunedLeafId) {
@@ -8,7 +8,8 @@ import { isClientAuthoritativeAgentStatusPane } from '@/components/terminal-pane
import { normalizeCompatibleAgentStatusEntryForOwner } from '../../../../shared/agent-status/title/agent-title-owner'
import { resolvePaneAgentOwnerRecord } from '../../../../shared/agent-status/identity/pane-agent-owner'
import { toWebTerminalSurfaceTabId } from '../../../../shared/workspace-layout/terminal-surface-id'
import type { TerminalSurface, WebSessionTabsBatchContext, WebSessionTabsSyncState } from './state'
import type { WebSessionTabsBatchContext, WebSessionTabsSyncState } from './state'
import type { RuntimeMobileSessionTerminalClientTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import {
type RetiredTerminalTabSweepState,
@@ -29,7 +30,7 @@ export function isMirroredAgentStatusOwnedBy(
}
export function toMirroredPaneKey(
surface: TerminalSurface,
surface: RuntimeMobileSessionTerminalClientTab,
leafId = surface.leafId
): string | null {
if (!isTerminalLeafId(leafId)) {
@@ -42,9 +43,9 @@ export function toMirroredPaneKey(
* frame publishes: older hosts omit it on agents restored after a restart, and clients judge a
* row's ownership (and retraction) by worktree, so every reader must see the same owner. */
export function remapHostAgentStatus(
surface: TerminalSurface,
surface: RuntimeMobileSessionTerminalClientTab,
frameWorktreeId: string,
retainedSurface?: TerminalSurface
retainedSurface?: RuntimeMobileSessionTerminalClientTab
): AgentStatusEntry | null {
if (!surface.agentStatus) {
return null
@@ -1,12 +1,8 @@
import type { RuntimeMobileSessionTabGroup } from '../../../../shared/runtime-types'
import type { TabGroup } from '../../../../shared/tab-types'
import type { TerminalTab } from '../../../../shared/workspace-layout/terminal-tab-types'
import type {
MirroredAgentTab,
MirroredBrowserTab,
MirroredEditorTab,
TerminalSurface
} from './state'
import type { MirroredAgentTab, MirroredBrowserTab, MirroredEditorTab } from './state'
import type { RuntimeMobileSessionTerminalClientTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import { toWebTerminalSurfaceTabId } from '../../../../shared/workspace-layout/terminal-surface-id'
import { clearHostSessionTabIdMappings, setHostSessionTabIdMapping } from './tracking-mappings'
import { isWebSessionBrowserPlacementGroupReserved } from '../browser/placement/web-session-browser-placement'
@@ -21,7 +17,7 @@ export function buildHostToLocalTabIdMap({
editorTabs,
agentTabs
}: {
terminalSurfaces: readonly TerminalSurface[]
terminalSurfaces: readonly RuntimeMobileSessionTerminalClientTab[]
terminalTabs: readonly TerminalTab[]
browserTabs: readonly MirroredBrowserTab[]
editorTabs: readonly MirroredEditorTab[]
@@ -52,7 +48,7 @@ export function buildHostToLocalTabIdMap({
export function updateHostSessionTabIdMappings(args: {
environmentId: string
worktreeId: string
terminalSurfaces: readonly TerminalSurface[]
terminalSurfaces: readonly RuntimeMobileSessionTerminalClientTab[]
terminalTabs: readonly TerminalTab[]
browserTabs: readonly MirroredBrowserTab[]
editorTabs: readonly MirroredEditorTab[]
@@ -1,7 +1,5 @@
import type {
RuntimeMobileSessionBrowserTab,
RuntimeMobileSessionTabsResult
} from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionBrowserTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import type { BrowserPage, BrowserWorkspace } from '../../../../shared/browser-workspace-types'
import type { Tab } from '../../../../shared/tab-types'
import type { WebSessionTabsSyncState, MirroredBrowserTab } from './state'
@@ -13,16 +13,16 @@ import { clientAgentStatusFencesHost } from './agent-status-primitives'
import { writableWebSessionTabsRecord } from './state-equality-core'
import type {
MirroredTerminalTab,
TerminalSurface,
WebSessionTabsBatchContext,
WebSessionTabsSyncState
} from './state'
import type { RuntimeMobileSessionTerminalClientTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
/** Reconcile saved pane titles with the accepted host inventory, including inactive tabs. */
export function buildMirroredRuntimePaneTitlePatch(
state: WebSessionTabsSyncState,
tabs: readonly MirroredTerminalTab[],
surfaces: readonly TerminalSurface[],
surfaces: readonly RuntimeMobileSessionTerminalClientTab[],
now: number,
batchContext?: WebSessionTabsBatchContext
): Partial<WebSessionTabsSyncState> | null {
@@ -37,9 +37,11 @@ export function buildMirroredRuntimePaneTitlePatch(
if (titledTabs.length === 0) {
return null
}
const surfacesByTab = new Map<string, Map<string, TerminalSurface>>()
const surfacesByTab = new Map<string, Map<string, RuntimeMobileSessionTerminalClientTab>>()
for (const surface of surfaces) {
const byLeaf = surfacesByTab.get(surface.parentTabId) ?? new Map<string, TerminalSurface>()
const byLeaf =
surfacesByTab.get(surface.parentTabId) ??
new Map<string, RuntimeMobileSessionTerminalClientTab>()
byLeaf.set(surface.leafId, surface)
surfacesByTab.set(surface.parentTabId, byLeaf)
}
@@ -1,15 +1,16 @@
import type { AppState } from '../../store/types'
import type { RetiredTerminalTabSweepState } from '../../store/terminals/retired-terminal-tab-state-sweep'
import type {
RuntimeMobileSessionAgentTab,
RuntimeMobileSessionTabGroup,
RuntimeMobileSessionTabsRemovedResult,
RuntimeMobileSessionTabsResult
} from '../../../../shared/runtime-types'
import type {
RuntimeMobileSessionBrowserTab,
RuntimeMobileSessionFileTab,
RuntimeMobileSessionMarkdownTab,
RuntimeMobileSessionTabGroup,
RuntimeMobileSessionTabsRemovedResult,
RuntimeMobileSessionTabsResult,
RuntimeMobileSessionTerminalClientTab
} from '../../../../shared/runtime-types'
} from '../../../../shared/runtime-mobile-session-tab-contracts'
import type {
BrowserCertificateFailure,
BrowserPage,
@@ -173,7 +174,6 @@ export function resetReceivedSessionTabsFrameSequence(): void {
receivedSessionTabsFrameSequence = 0
}
export type TerminalSurface = RuntimeMobileSessionTerminalClientTab
export type ReadyTerminalSurface = RuntimeMobileSessionTerminalClientTab & { status: 'ready' }
export type ReadyBrowserSurface = RuntimeMobileSessionBrowserTab & { browserPageId: string }
export type ReadyEditorSurface = RuntimeMobileSessionMarkdownTab | RuntimeMobileSessionFileTab
@@ -184,7 +184,7 @@ export type MirroredTerminalTab = {
hostTabId: string
ptyIds: string[]
layout: TerminalLayoutSnapshot
retainedSurfaceByPrunedLeafId?: ReadonlyMap<string, TerminalSurface>
retainedSurfaceByPrunedLeafId?: ReadonlyMap<string, RuntimeMobileSessionTerminalClientTab>
}
export type MirroredBrowserTab = {
workspace: BrowserWorkspace
@@ -282,6 +282,5 @@ export type WebSessionTabsBatchContext = {
openFilesIndex: WebSessionOpenFilesIndex | null
}
export type AgentTab = RuntimeMobileSessionAgentTab
export type TabGroupSnapshot = RuntimeMobileSessionTabGroup
export type RemovedTabsResult = RuntimeMobileSessionTabsRemovedResult
@@ -1,7 +1,5 @@
import type {
RuntimeMobileSessionBrowserTab,
RuntimeMobileSessionTabsResult
} from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/runtime-types'
import type { RuntimeMobileSessionBrowserTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import type { BrowserWorkspace } from '../../../../shared/browser-workspace-types'
import type { Tab } from '../../../../shared/tab-types'
import type { TerminalTab } from '../../../../shared/workspace-layout/terminal-tab-types'
@@ -9,7 +9,8 @@ import { normalizeCompatibleAgentTitleForOwner } from '../../../../shared/agent-
import { getRemoteRuntimePtyEnvironmentId } from '../hosted-terminals/identity/remote-runtime-pty-owner'
import { toRemoteRuntimePtyId } from '../../../../shared/remote-runtime/remote-runtime-pty-id'
import { toWebTerminalSurfaceTabId } from '../../../../shared/workspace-layout/terminal-surface-id'
import type { MirroredTerminalTab, TerminalSurface, ReadyTerminalSurface } from './state'
import type { MirroredTerminalTab, ReadyTerminalSurface } from './state'
import type { RuntimeMobileSessionTerminalClientTab } from '../../../../shared/runtime-mobile-session-tab-contracts'
import { chooseRemoteTerminalLayout, isTerminalSurfaceTab } from './terminal-surfaces'
function pendingBindingBelongsToEnvironment(
@@ -25,7 +26,7 @@ function pendingBindingBelongsToEnvironment(
/** Keep a known pane binding while the host briefly publishes its surface as pending. */
function retainPendingTerminalBindings(
surfaces: readonly TerminalSurface[],
surfaces: readonly RuntimeMobileSessionTerminalClientTab[],
existingLayout: TerminalLayoutSnapshot | undefined,
ptyIdsByLeafId: Record<string, string>,
environmentId: string,
@@ -67,7 +68,7 @@ export function buildMirroredTerminalTabs(
focusTarget?: { parentTabId: string; leafId: string },
terminalPtyMode: 'local' | 'remote' = 'remote'
): MirroredTerminalTab[] {
const groups = new Map<string, TerminalSurface[]>()
const groups = new Map<string, RuntimeMobileSessionTerminalClientTab[]>()
for (const tab of snapshot.tabs.filter(isTerminalSurfaceTab)) {
const group = groups.get(tab.parentTabId) ?? []
group.push(tab)
@@ -114,7 +115,9 @@ export function buildMirroredTerminalTabs(
const ptyIds = layoutPtyEntries
.map(([, ptyId]) => ptyId)
.filter((ptyId) => livePtyIds.has(ptyId))
let retainedSurfaceByPrunedLeafId: Map<string, TerminalSurface> | undefined
let retainedSurfaceByPrunedLeafId:
| Map<string, RuntimeMobileSessionTerminalClientTab>
| undefined
if (layoutPtyEntries.length < Object.keys(ptyIdsByLeafId).length) {
const retainedLeafIdByPtyId = new Map(
layoutPtyEntries.map(([leafId, ptyId]) => [ptyId, leafId])
@@ -1,8 +1,9 @@
import { readStructuredAgentLaunchRecord } from '@/lib/agent-session/launch/structured-agent-session-launch-persistence'
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/runtime-types'
import type {
RuntimeMobileSessionTabsResult,
RuntimeMobileSessionAgentTab
} from '../../../../shared/runtime-types'
RuntimeMobileSessionAgentTab,
RuntimeMobileSessionTerminalClientTab
} from '../../../../shared/runtime-mobile-session-tab-contracts'
import type {
TerminalLayoutSnapshot,
TerminalTab
@@ -21,7 +22,6 @@ import type {
ReadyBrowserSurface,
ReadyEditorSurface,
ReadyTerminalSurface,
TerminalSurface,
MirroredAgentTab
} from './state'
import type { Tab } from '../../../../shared/tab-types'
@@ -42,7 +42,7 @@ export function isReadyTerminalTab(
export function isTerminalSurfaceTab(
tab: RuntimeMobileSessionTabsResult['tabs'][number]
): tab is TerminalSurface {
): tab is RuntimeMobileSessionTerminalClientTab {
return tab.type === 'terminal'
}
@@ -176,7 +176,7 @@ export function isMirroredTerminalSurfaceId(tabId: string): boolean {
}
export function chooseRemoteTerminalLayout(
surfaces: readonly TerminalSurface[],
surfaces: readonly RuntimeMobileSessionTerminalClientTab[],
ptyIdsByLeafId: Record<string, string>,
existingLayout?: TerminalLayoutSnapshot,
requestedActiveLeafId?: string
-4
View File
@@ -20,8 +20,6 @@ import type { CliStatusCaller } from './orchestration/orchestration-caller-statu
import type { RuntimeHostDescriptor } from './remote-runtime/host-status/runtime-host-descriptor'
import type { TuiAgent } from './agent-launch/catalog/tui-agent'
export type * from './runtime-mobile-session-tab-contracts'
export type RuntimeGraphStatus = 'ready' | 'reloading' | 'unavailable'
export type RuntimeDesktopWindowStatus = 'available' | 'openable' | 'initializing' | 'blocked'
@@ -35,8 +33,6 @@ export type RuntimeTerminalDriverState =
| { kind: 'desktop' }
| { kind: 'mobile'; clientId: string }
export type RuntimeBrowserDriverState = RuntimeTerminalDriverState
export const BROWSER_UNAVAILABLE_ERROR_CODE = 'browser_unavailable' as const
// Render actionable per-cause messages host-side so older clients can display reasons they cannot decode.
+1 -13
View File
@@ -39,18 +39,10 @@ export type {
CliRuntimeState,
CliStatusResult,
DeviceScope,
RuntimeBrowserDriverState,
RuntimeDesktopWindowStatus,
RuntimeGraphStatus,
RuntimeMobileSessionAgentTab,
RuntimeMobileSessionAgentTabStatus,
RuntimeMobileSessionBrowserTab,
RuntimeMobileSessionClientTab,
RuntimeMobileSessionCreateTerminalResult,
RuntimeMobileSessionFileTab,
RuntimeMobileSessionMarkdownTab,
RuntimeMobileSessionRetiredTerminalSurface,
RuntimeMobileSessionSnapshotTab,
RuntimeMobileSessionTabCloseResult,
RuntimeMobileSessionTabGroup,
RuntimeMobileSessionTabMove,
@@ -58,9 +50,6 @@ export type {
RuntimeMobileSessionTabsRemovedResult,
RuntimeMobileSessionTabsResult,
RuntimeMobileSessionTabsSnapshot,
RuntimeMobileSessionTerminalClientTab,
RuntimeMobileSessionTerminalTab,
RuntimeMobileTerminalTheme,
RuntimeMountedLeaf,
RuntimeNativeChatLaunchDraftResolution,
RuntimeRendererSyncWindowGraph,
@@ -69,8 +58,7 @@ export type {
RuntimeSyncedLeaf,
RuntimeSyncedTab,
RuntimeSyncWindowGraph,
RuntimeSyncWindowGraphResult,
RuntimeTerminalDriverState
RuntimeSyncWindowGraphResult
} from './runtime-session-contracts'
export type {
RuntimeTerminalAgentStatus,
@@ -1,8 +1,6 @@
import type { Page } from '@stablyai/playwright-test'
import type {
RuntimeMobileSessionTabsResult,
RuntimeMobileSessionTerminalClientTab
} from '../../src/shared/runtime-types'
import type { RuntimeMobileSessionTabsResult } from '../../src/shared/runtime-types'
import type { RuntimeMobileSessionTerminalClientTab } from '../../src/shared/runtime-mobile-session-tab-contracts'
import { toWebTerminalSurfaceTabId } from '../../src/shared/workspace-layout/terminal-surface-id'
import type { TerminalLayoutSnapshot } from '../../src/shared/workspace-layout/terminal-tab-types'
import {