Files
orca/src/shared/runtime-workspace-window-availability.test.ts
T
Neilandgatsby74 f968583e95 fix(remote): stop a reachable Orca server with a closed workspace window from reading Ready (#12477)
A remote Orca server whose workspace window is closed keeps answering status RPC, so Settings > Available Hosts showed "Ready" and the status bar showed "Connected" while every graph-backed operation failed. Adds the shared predicate `isRuntimeWorkspaceWindowClosed` (`graphStatus !== 'ready' && desktopWindowStatus === 'openable'`) and one host-health derivation with a new `workspace-window-closed` state, consumed by both surfaces. Hosts that omit `desktopWindowStatus` are unaffected, so the connected-host count and overall dot do not regress.

Fixes #12350

Co-authored-by: gatsby74 <gatsby74@users.noreply.github.com>
2026-08-07 21:11:31 -07:00

77 lines
2.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { RuntimeStatus } from './runtime-types'
import { isRuntimeWorkspaceWindowClosed } from './runtime-workspace-window-availability'
function makeStatus(overrides: Partial<RuntimeStatus>): RuntimeStatus {
return {
runtimeId: 'runtime-hub',
rendererGraphEpoch: 1,
graphStatus: 'ready',
authoritativeWindowId: 1,
liveTabCount: 0,
liveLeafCount: 0,
...overrides
}
}
describe('isRuntimeWorkspaceWindowClosed', () => {
it('flags a reachable host whose graph is gone but whose desktop window can be opened', () => {
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({
graphStatus: 'unavailable',
authoritativeWindowId: null,
desktopWindowStatus: 'openable'
})
)
).toBe(true)
})
it('leaves graph-ready headless servers alone', () => {
// Why: #6844 headless serve owns a graph without a desktop window — it must
// never read as degraded just because a window could be opened.
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({ graphStatus: 'ready', desktopWindowStatus: 'openable' })
)
).toBe(false)
})
it('ignores a renderer reload that still owns its window', () => {
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({ graphStatus: 'reloading', desktopWindowStatus: 'available' })
)
).toBe(false)
})
it('flags a reload whose window disappeared before the graph was marked unavailable', () => {
// Why: 'openable' already means no live renderer window, so a mid-reload window
// teardown is just as unusable as 'unavailable'.
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({ graphStatus: 'reloading', desktopWindowStatus: 'openable' })
)
).toBe(true)
})
it('treats a missing desktop window claim as no claim', () => {
expect(isRuntimeWorkspaceWindowClosed(makeStatus({ graphStatus: 'unavailable' }))).toBe(false)
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({ graphStatus: 'unavailable', desktopWindowStatus: 'initializing' })
)
).toBe(false)
expect(
isRuntimeWorkspaceWindowClosed(
makeStatus({ graphStatus: 'unavailable', desktopWindowStatus: 'blocked' })
)
).toBe(false)
})
it('is not a substitute for an unreachable host', () => {
expect(isRuntimeWorkspaceWindowClosed(null)).toBe(false)
expect(isRuntimeWorkspaceWindowClosed(undefined)).toBe(false)
})
})