Files
orca/src/main/ipc/runtime-environment-shared-control-support.ts
T
Jinwoo HongandOmar Shahine 3b82d8de64 fix(runtime): let connections own host status recovery (#20003)
* fix(runtime): let connections own host status recovery

Verify runtime status after authenticated connection recovery and publish
ordered snapshots to desktop and browser viewers. Consolidate failed-status
retries in the connection owner and remove renderer retry/diagnostics merging.

Adapt sidebar host-state derivation and regression coverage from Omar
Shahine's original fix in https://github.com/stablyai/orca/pull/19163.

Co-authored-by: Omar Shahine <10343873+omarshahine@users.noreply.github.com>

* fix(runtime): show blocked hosts honestly and remove obsolete status options

* fix(runtime): preserve timeout guidance and update IPC test fixtures

* fix(runtime): preserve status evidence and address review gaps

* test(sidebar): assert workspace host icons dimming and recovery tooltips

* fix(palette): require available hosts before adding implicit badges

* fix: retain disconnected host snapshots for new renderers

---------

Co-authored-by: Omar Shahine <10343873+omarshahine@users.noreply.github.com>
2026-09-11 03:19:01 -04:00

49 lines
1.4 KiB
TypeScript

import type {
getPreferredPairingOffer,
KnownRuntimeEnvironment
} from '../../shared/runtime-environments'
import { RemoteRuntimeClientError } from '../../shared/remote-runtime-client-error'
import {
getAcceptedRuntimeEnvironmentCapabilityOutcome,
resetRuntimeEnvironmentCapabilityEvidence,
type RuntimeEnvironmentCapabilityOutcome
} from './runtime-environment-capability-evidence'
import {
getRuntimeEnvironmentStatusOwner,
resetRuntimeEnvironmentStatusOwners
} from './runtime-environment-request-connections'
export function resetSharedControlSupport(): void {
resetRuntimeEnvironmentStatusOwners()
resetRuntimeEnvironmentCapabilityEvidence()
}
export async function supportsSharedControl(
userDataPath: string,
environment: KnownRuntimeEnvironment,
pairing: ReturnType<typeof getPreferredPairingOffer>,
timeoutMs: number
): Promise<RuntimeEnvironmentCapabilityOutcome> {
const accepted = getAcceptedRuntimeEnvironmentCapabilityOutcome(
environment.id,
pairing,
environment.runtimeId
)
if (accepted) {
return accepted
}
const response = await getRuntimeEnvironmentStatusOwner(userDataPath, environment.id).refresh({
timeoutMs
})
if (!response.ok) {
throw new RemoteRuntimeClientError(response.error.code, response.error.message)
}
return (
getAcceptedRuntimeEnvironmentCapabilityOutcome(
environment.id,
pairing,
response._meta.runtimeId
) ?? { kind: 'stale_incarnation' }
)
}