mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* fix(mobile): phone server rows follow the desktop's other-client and sleeping filters A phone created through a desktop now records whom it acted for, so the desktop's Hide other-client workspaces filter keeps the user's own phone workspaces (locally and on servers) and hides only other people's. The desktop relay marks each server row its sidebar would hide, and the rows its own browser or chat tabs keep awake; the phone applies both. * test(e2e): dedupe sidebar row ids in the visibility spec * fix(mobile): address review: owner naming, old-server relayed phones, scope trim * refactor: move the sidebar's project section grouping into shared The project sections the desktop sidebar draws under Group by Project are built from the project/setup projection, the per-host catalog fold, the endpoint host stamp, and the section labelling and ordering rules. Move the pure parts of each into src/shared (no behaviour change) so the paired phone can call the same code instead of guessing the grouping. * fix(mobile): group by Project with the desktop sidebar's own sections The phone grouped Project sections by repo display name, so it merged checkouts the desktop keeps apart (several local stablyai/orca checkouts, or a server's copy) and split what the desktop merges. The phone now reads each host's repo.list, project.list and projectHostSetup.list (the desktop's own and each server's through the relay), folds them with the renderer's shared catalog fold and projection merge, and builds sections with the desktop's shared grouping, labelling and ordering code. Keys, labels and Recent order equal the sidebar's; a host that predates the project lists gets the repo-derived projection, as the desktop does. Header colour and icon come from the section's anchor repo and rows from their own repo by id, as on the desktop. The repo filter lists every catalog repo by id per host instead of merging same-named repos. Group-by labels read Project and None. project.list and projectHostSetup.list are routed for paired phones (read-only, workspace permission). * refactor(mobile): record a phone's owner as creator and fold desktop tab activity into the host flag A phone now records its owner as the creator (this host for a directly paired phone, the relaying desktop for a delegated one), so the shared rule is unchanged and onBehalfOf is gone. The relay ORs the desktop's saved browser/chat tabs into hasHostSidebarActivity, so the phone's status dot follows too, and local worktree.ps counts the same signals. The old-server fallback is removed. * test(e2e): poll the phone and the sidebar together in the visibility spec * fix(mobile): one Project-section builder for desktop and phone, with the desktop's repo order Review fixes. The sidebar's buildOrderedGroups now calls the shared buildProjectSections for Group by Project (notice and pending repos are optional inputs), so desktop and phone run one function. The phone ranks manual header order by its folded catalog order, which is each host's repo.list order with the desktop's own repos first, as the renderer loads them; only the desktop's cross-host manualRepoOrder (pairing-local) is unknown to it. The projection selector is now a memo over the shared resolver. A transient project-list failure keeps that host's last catalog; only forbidden or method_not_found falls back to the repo-derived projection. Catalog rows are checked on every member grouping reads, and the parity test answers the renderer's real catalog fetch, includes a server's own project rows, and fixes Manual and Recent orders that differ. * fix(mobile): use the repo-derived catalog until a host's project lists first answer * fix(mobile): the desktop serves its sidebar's Project catalog instead of the phone fetching it The phone fetched repo.list, project.list and projectHostSetup.list from the desktop and every relay-ready server each minute and folded them itself, so rows from offline or older servers fell back to repo sections and keys moved on cold start. The desktop renderer now publishes the inputs its own Project headers use (state.repos in sidebar order, the projection selector's projects and setups, projectOrderBy) on the runtime window graph it already sends to main, only when they change. Main keeps the last one and answers it on a new paired-desktop read, mobileRelay.projectSections. The phone reads it with its repo metadata and groups with the shared builder; a desktop that predates the read (forbidden or method_not_found) leaves the phone grouping rows by repo from the desktop's repo.list, and a transient failure keeps the last catalog. The payload carries only grouping and label fields, no hooks, credentials or uploaded icons. The phone's own catalog fetching and its project.list/projectHostSetup.list routes are removed. * fix(mobile): keep uploaded repo icons on the phone, and isolate the snapshot tests * test(e2e): the desktop window serves its sidebar's Project catalog to the phone * chore(i18n): regenerate the runtime English catalog (drift already on main) * fix(mobile): read the Project catalog as its own request, outside the recorded repo-metadata flow The extra read inside the repo-metadata refresh stalled its recorded RPC sequence. It now runs beside it with its own throttle. The repo-metadata goldens are re-recorded for the intended state change: the name-keyed colour, icon and id maps became desktopRepos. * fix(mobile): fetch the Project catalog at once when the screen moves to another host The refresh window is now kept per client, so a host screen reused for another desktop doesn't wait out the previous host's 60s window before showing its Project headers.
309 lines
12 KiB
TypeScript
309 lines
12 KiB
TypeScript
import type { MobileProjectSectionCatalog } from './mobile-project-sections-contract'
|
|
import type { AgentStatusOrchestrationContext } from './agent-status-types'
|
|
import type { RemoteServerUpdateSupport } from './remote-server-update'
|
|
import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime-shared-control-types'
|
|
import type { RuntimeHostConnectionState } from './runtime-host-connection-state'
|
|
import type { RuntimeCapability } from './protocol-version'
|
|
import type {
|
|
RuntimeBrowserUnavailableReason,
|
|
RuntimeDegradation
|
|
} from './runtime-capability-degradation'
|
|
import type { TabGroupLayoutNode } from './tab-types'
|
|
import type { TerminalPaneLayoutNode } from './terminal-tab-types'
|
|
import type {
|
|
RuntimeMobileSessionClientTab,
|
|
RuntimeMobileSessionSnapshotTab,
|
|
RuntimeMobileSessionTerminalClientTab
|
|
} from './runtime-mobile-session-tab-contracts'
|
|
import type { CliStatusCaller } from './orchestration-caller-status'
|
|
import type { RuntimeHostDescriptor } from './runtime-host-descriptor'
|
|
|
|
export type * from './runtime-mobile-session-tab-contracts'
|
|
|
|
export type RuntimeGraphStatus = 'ready' | 'reloading' | 'unavailable'
|
|
|
|
export type RuntimeDesktopWindowStatus = 'available' | 'openable' | 'initializing' | 'blocked'
|
|
|
|
export const HEADLESS_RUNTIME_WINDOW_ID = 0
|
|
|
|
export type DeviceScope = 'mobile' | 'runtime'
|
|
|
|
export type RuntimeTerminalDriverState =
|
|
| { kind: 'idle' }
|
|
| { kind: 'desktop' }
|
|
| { kind: 'mobile'; clientId: string }
|
|
|
|
export type RuntimeBrowserDriverState = RuntimeTerminalDriverState
|
|
|
|
export const BROWSER_UNAVAILABLE_ERROR_CODE = 'browser_unavailable' as const
|
|
|
|
// Why: one sentence per cause, each naming the thing the operator can change. The host
|
|
// renders these so an older client still shows an accurate reason it cannot decode.
|
|
const BROWSER_UNAVAILABLE_MESSAGES: Record<RuntimeBrowserUnavailableReason, string> = {
|
|
unconfigured:
|
|
'Browser automation has no backend on this host. Install the Orca desktop app, or set ORCA_BROWSER_EXECUTABLE to a Chromium executable.',
|
|
driver_missing:
|
|
'ORCA_BROWSER_EXECUTABLE is set, but the bundled agent-browser driver is missing or not executable on this host, so Chromium cannot be driven.',
|
|
executable_not_found: 'ORCA_BROWSER_EXECUTABLE points at a path that does not exist.',
|
|
executable_not_executable:
|
|
'ORCA_BROWSER_EXECUTABLE points at a file that is not executable by this host.',
|
|
electron_start_failed: 'The installed Electron browser provider failed to start.',
|
|
chromium_start_failed:
|
|
'The Chromium browser provider named by ORCA_BROWSER_EXECUTABLE failed to start.',
|
|
provider_unhealthy: 'The browser provider started but is no longer answering health checks.',
|
|
desktop_window_unavailable:
|
|
'Browser automation on this host needs a desktop window, and none is available.',
|
|
unknown: 'Browser automation is unavailable on this host, and the cause could not be determined.'
|
|
}
|
|
|
|
export function browserUnavailableMessage(
|
|
reason: RuntimeBrowserUnavailableReason,
|
|
detail?: string
|
|
): string {
|
|
const base = BROWSER_UNAVAILABLE_MESSAGES[reason]
|
|
return detail ? `${base} (${detail})` : base
|
|
}
|
|
|
|
export type RuntimeStatus = {
|
|
runtimeId: string
|
|
/** Authenticated requester identity. Missing for in-process callers and older hosts. */
|
|
pairedDeviceId?: string
|
|
rendererGraphEpoch: number
|
|
graphStatus: RuntimeGraphStatus
|
|
authoritativeWindowId: number | null
|
|
desktopWindowStatus?: RuntimeDesktopWindowStatus
|
|
liveTabCount: number
|
|
liveLeafCount: number
|
|
runtimeProtocolVersion?: number
|
|
minCompatibleRuntimeClientVersion?: number
|
|
capabilities?: RuntimeCapability[]
|
|
/** Optional policy for clients that negotiated worktree.create-idempotency.v1. */
|
|
worktreeCreateIdempotency?: {
|
|
dedupeTtlMs: number
|
|
}
|
|
/** True only when this Windows host can read process creation times. TEMPORARY: read only by
|
|
* older clients, which keep re-probing WSL until it is true; remove after their window. */
|
|
windowsProcessStartTimeAvailable?: boolean
|
|
/**
|
|
* Optional for mixed-version peers. Absence means the host predates structured
|
|
* degradation reporting, not that the host proved every optional feature available.
|
|
*/
|
|
degradations?: RuntimeDegradation[]
|
|
appVersion?: string
|
|
remoteUpdateSupport?: RemoteServerUpdateSupport
|
|
remoteControl?: RemoteRuntimeSharedConnectionDiagnostics | null
|
|
hostPlatform?: NodeJS.Platform
|
|
/** Optional display name reported by the answering runtime. */
|
|
machineName?: string
|
|
/** Absent from older hosts and from hosts whose profile could not persist an installation id. */
|
|
hostDescriptor?: RuntimeHostDescriptor
|
|
terminalWindowsShell?: string | null
|
|
deviceScope?: DeviceScope
|
|
floatingWorkspaceEnabled?: boolean
|
|
// COMPAT(runtimeStatusMobileAliases): added 2026-05-15 for older mobile builds.
|
|
protocolVersion?: number
|
|
minCompatibleMobileVersion?: number
|
|
}
|
|
|
|
export type CliRuntimeState =
|
|
| 'not_running'
|
|
| 'starting'
|
|
| 'ready'
|
|
| 'graph_not_ready'
|
|
| 'stale_bootstrap'
|
|
|
|
export type CliStatusResult = {
|
|
target?: { kind: 'local' } | { kind: 'environment'; environment: string }
|
|
app: {
|
|
running: boolean
|
|
pid: number | null
|
|
desktopWindowStatus?: RuntimeDesktopWindowStatus
|
|
}
|
|
runtime: {
|
|
state: CliRuntimeState
|
|
reachable: boolean
|
|
/** Canonical runtime transport verdict, when the caller has runtime evidence. */
|
|
connectionState?: RuntimeHostConnectionState
|
|
runtimeId: string | null
|
|
appVersion?: string
|
|
remoteUpdateSupport?: RemoteServerUpdateSupport
|
|
capabilities?: RuntimeCapability[]
|
|
degradations?: RuntimeDegradation[]
|
|
}
|
|
graph: {
|
|
state: RuntimeGraphStatus | 'not_running' | 'starting'
|
|
}
|
|
/** This process's Orca session ID when it runs as an Orca session; see `CliStatusCaller`. */
|
|
caller?: CliStatusCaller
|
|
}
|
|
|
|
export type RuntimeSyncedTab = {
|
|
tabId: string
|
|
worktreeId: string
|
|
title: string | null
|
|
activeLeafId: string | null
|
|
layout: TerminalPaneLayoutNode | null
|
|
}
|
|
|
|
export type RuntimeSyncedLeaf = {
|
|
tabId: string
|
|
worktreeId: string
|
|
leafId: string
|
|
paneRuntimeId: number
|
|
ptyId: string | null
|
|
paneTitle?: string | null
|
|
title?: string | null
|
|
/** True when this leaf is retained by a parked PTY watcher, not mounted in the renderer. */
|
|
parked?: boolean
|
|
}
|
|
|
|
export type RuntimeSyncWindowGraph = {
|
|
tabs: RuntimeSyncedTab[]
|
|
leaves: RuntimeSyncedLeaf[]
|
|
mobileSessionTabs?: RuntimeMobileSessionTabsSnapshot[]
|
|
unchangedMobileSessionWorktrees?: string[]
|
|
/** Terminal grid that fills each shown tab group, by group id, so main starts a new tab's
|
|
* terminal at its group's size. Window-to-main only: never copied into session tabs. */
|
|
terminalGroupGridSizes?: Record<string, { cols: number; rows: number }>
|
|
/** The grid a workspace with a single tab group gets, for one the window is not showing. */
|
|
singleGroupWorkspaceGridSize?: { cols: number; rows: number }
|
|
/** The sidebar's Project grouping inputs for paired phones; sent only when they changed. */
|
|
projectSectionCatalog?: MobileProjectSectionCatalog
|
|
}
|
|
|
|
export type RuntimeRendererSyncWindowGraph = RuntimeSyncWindowGraph & {
|
|
rendererGeneration: string
|
|
}
|
|
|
|
export type RuntimeNativeChatLaunchDraftResolution = {
|
|
tabId: string
|
|
text: string
|
|
createdAt: number
|
|
}
|
|
|
|
export type RuntimeSyncWindowGraphResult = RuntimeStatus & {
|
|
agentOrchestrationByPaneKey?: Record<string, AgentStatusOrchestrationContext>
|
|
nativeChatLaunchDraftResolutions?: RuntimeNativeChatLaunchDraftResolution[]
|
|
mobileSessionResyncWorktrees?: string[]
|
|
}
|
|
|
|
export type RuntimeMobileSessionTabGroup = {
|
|
id: string
|
|
activeTabId: string | null
|
|
tabOrder: string[]
|
|
recentTabIds?: string[]
|
|
}
|
|
|
|
type RuntimeMobileSessionTabMoveBase = {
|
|
tabId: string
|
|
targetGroupId: string
|
|
}
|
|
|
|
export type RuntimeMobileSessionTabMove =
|
|
| (RuntimeMobileSessionTabMoveBase & { kind: 'reorder'; tabOrder: string[] })
|
|
| (RuntimeMobileSessionTabMoveBase & { kind: 'move-to-group'; index?: number })
|
|
| (RuntimeMobileSessionTabMoveBase & {
|
|
kind: 'split'
|
|
splitDirection: 'left' | 'right' | 'up' | 'down'
|
|
})
|
|
|
|
export type RuntimeMobileSessionTabMoveResult = { moved: true }
|
|
|
|
export type RuntimeMobileSessionTabCloseResult = {
|
|
closed: true
|
|
refused?: true
|
|
refusalReason?:
|
|
| 'missing-intent'
|
|
| 'stale-publication'
|
|
| 'stale-terminal'
|
|
| 'live-host-pty'
|
|
| 'unknown-liveness'
|
|
| 'retirement-owner'
|
|
snapshotRepublished?: true
|
|
}
|
|
|
|
export type RuntimeSessionTabCloseReason = 'user' | 'pty-exit' | 'cleanup'
|
|
|
|
/**
|
|
* The publication epoch a runtime answers with for a worktree it has published nothing for yet —
|
|
* the state every worktree is in for a moment after the host process restarts.
|
|
*
|
|
* Bare or with a paired client's navigation suffix, it marks a synthesized placeholder, not a host answer: the
|
|
* runtime is saying "ask me later", not "those tabs are gone". Clients must not read absence from
|
|
* such a frame as evidence a tab was closed.
|
|
*/
|
|
export const UNPUBLISHED_WORKTREE_PUBLICATION_EPOCH = 'none'
|
|
|
|
/** Suffix a host appends to the epoch when projecting a snapshot for one paired client's navigation. */
|
|
export const CLIENT_NAVIGATION_PUBLICATION_EPOCH_SUFFIX = ':client-navigation'
|
|
|
|
export type RuntimeMobileSessionTabsSnapshot = {
|
|
worktree: string
|
|
/** Immutable catalog identity used to fence snapshots across path reuse. */
|
|
worktreeInstanceId?: string
|
|
publicationEpoch: string
|
|
snapshotVersion: number
|
|
activeGroupId: string | null
|
|
activeTabId: string | null
|
|
activeTabType: 'terminal' | 'markdown' | 'file' | 'browser' | 'agent-session' | null
|
|
tabGroups?: RuntimeMobileSessionTabGroup[]
|
|
tabGroupLayout?: TabGroupLayoutNode | null
|
|
retiredTerminalSurfaces?: RuntimeMobileSessionRetiredTerminalSurface[]
|
|
tabs: RuntimeMobileSessionSnapshotTab[]
|
|
}
|
|
|
|
export type RuntimeMobileSessionRetiredTerminalSurface = {
|
|
parentTabId: string
|
|
leafId: string
|
|
ptyId: string
|
|
terminal: string
|
|
incarnationId?: string
|
|
}
|
|
|
|
export type RuntimeMobileSessionTabsResult = {
|
|
worktree: string
|
|
publicationEpoch: string
|
|
snapshotVersion: number
|
|
navigationIntent?: 'follow'
|
|
activeGroupId: string | null
|
|
activeTabId: string | null
|
|
activeTabType: 'terminal' | 'markdown' | 'file' | 'browser' | 'agent-session' | null
|
|
tabGroups?: RuntimeMobileSessionTabGroup[]
|
|
tabGroupLayout?: TabGroupLayoutNode | null
|
|
retiredTerminalSurfaces?: RuntimeMobileSessionRetiredTerminalSurface[]
|
|
tabs: RuntimeMobileSessionClientTab[]
|
|
/**
|
|
* Set while a freshly started runtime has not yet taken back the client-hosted pages its paired
|
|
* hosts are still holding. Such a snapshot is authoritative about terminals, which it rehydrated
|
|
* from disk, but silently empty of browser rows it has simply not heard about yet — so a client
|
|
* must not read the absence of its own client-hosted rows here as "the host closed them".
|
|
*
|
|
* Always bounded: the runtime clears it once a host attaches, and drops it on a deadline so a
|
|
* host that never returns cannot hold rows open forever.
|
|
*/
|
|
clientHostedPagesUnreconciled?: true
|
|
/**
|
|
* Set while this runtime has no structured-chat host that can say which chats exist because the
|
|
* chat journal will not open. The snapshot is still authoritative about everything else, but its
|
|
* missing `agent-session` rows mean "cannot tell", not "closed".
|
|
*
|
|
* Cleared by the first tab restore a host answers. Not bounded by a deadline: the chats are
|
|
* durable on disk, so holding their tabs strands nothing.
|
|
*/
|
|
agentSessionsUnverifiable?: true
|
|
}
|
|
|
|
export type RuntimeMobileSessionCreateTerminalResult = {
|
|
tab: RuntimeMobileSessionTerminalClientTab
|
|
publicationEpoch: string
|
|
snapshotVersion: number
|
|
}
|
|
|
|
export type RuntimeMobileSessionTabsRemovedResult = RuntimeMobileSessionTabsResult & {
|
|
removed: true
|
|
activeGroupId: null
|
|
activeTabId: null
|
|
activeTabType: null
|
|
tabs: []
|
|
}
|