mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 08:03:33 +00:00
* docs: design for direct SSH reconnect fan-out Capture the implementation-ready plan for host-qualified, epoch-fenced SSH reconnect recovery after two rounds of multi-model LLM counsel review. * docs: reconcile SSH reconnect fan-out design * docs: close reconnect design consistency gaps * feat: implement bounded direct SSH reconnect recovery * fix: bound direct SSH retry settlement * fix: harden direct SSH reconnect authority * fix: preserve split SSH retry ownership * fix: preserve SSH split continuation authority * docs: record final SSH reconnect validation * fix: preserve SSH authority through retained and detached state * fix: retain SSH authority across delayed split mounts * fix: close SSH authority recovery gaps * fix: fence stale SSH transport replacement * fix: serialize SSH target teardown * fix: settle SSH teardown failures before reconnect * fix: retire failed SSH reset sessions * test: reconcile current main E2E contracts * fix: close direct SSH reconnect review gaps * fix: fence stale SSH reconnect side effects * fix: close final SSH reconnect lifecycle gaps * test: stabilize current-main reliability gates * test: prove plugin navigation containment * test: make plugin navigation oracle authoritative * test: make plugin navigation oracle deterministic * ci: allow sharded e2e suite to finish * test: wait for runtime pane publication * test: classify pane readiness by error code * test: select close persistence terminal by tab identity * docs: mark reconnect implementation validated --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
165 lines
5.4 KiB
TypeScript
165 lines
5.4 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, expectTypeOf, it, vi } from 'vitest'
|
|
import type { PreloadApi } from './api-types'
|
|
import type { SshConnectionState, SshProviderEpoch } from '../shared/ssh-types'
|
|
import type {
|
|
HostQualifiedDetectedWorktreeResult,
|
|
ListDetectedWorktreesArgs
|
|
} from '../shared/detected-worktree-provider-contract'
|
|
import type { DetectedWorktreeListResult } from '../shared/types'
|
|
|
|
function listDetectedVariableTypeProbe(api: PreloadApi, args: ListDetectedWorktreesArgs) {
|
|
return api.worktrees.listDetected(args)
|
|
}
|
|
|
|
const { exposeInMainWorld, invoke, on, removeListener, send, sendSync } = vi.hoisted(() => ({
|
|
exposeInMainWorld: vi.fn(),
|
|
invoke: vi.fn(),
|
|
on: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
send: vi.fn(),
|
|
sendSync: vi.fn()
|
|
}))
|
|
|
|
vi.mock('electron', () => ({
|
|
contextBridge: { exposeInMainWorld },
|
|
ipcRenderer: { invoke, on, removeListener, send, sendSync },
|
|
webFrame: {
|
|
getZoomFactor: vi.fn(() => 1),
|
|
setZoomFactor: vi.fn(),
|
|
setVisualZoomLevelLimits: vi.fn()
|
|
},
|
|
webUtils: { getPathForFile: vi.fn(() => '') }
|
|
}))
|
|
|
|
vi.mock('@electron-toolkit/preload', () => ({ electronAPI: {} }))
|
|
|
|
describe('native preload SSH authority forwarding', () => {
|
|
const originalContextIsolated = Object.getOwnPropertyDescriptor(process, 'contextIsolated')
|
|
|
|
beforeEach(() => {
|
|
vi.resetModules()
|
|
exposeInMainWorld.mockReset()
|
|
invoke.mockReset()
|
|
on.mockReset()
|
|
removeListener.mockReset()
|
|
send.mockReset()
|
|
sendSync.mockReset()
|
|
Object.defineProperty(process, 'contextIsolated', { configurable: true, value: true })
|
|
vi.stubGlobal('window', {
|
|
addEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
removeEventListener: vi.fn()
|
|
})
|
|
vi.stubGlobal('document', { addEventListener: vi.fn() })
|
|
})
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals()
|
|
if (originalContextIsolated) {
|
|
Object.defineProperty(process, 'contextIsolated', originalContextIsolated)
|
|
} else {
|
|
Reflect.deleteProperty(process, 'contextIsolated')
|
|
}
|
|
})
|
|
|
|
it('retains host-qualified outcomes for variable-form detected-worktree requests', () => {
|
|
expectTypeOf(listDetectedVariableTypeProbe).returns.toEqualTypeOf<
|
|
Promise<HostQualifiedDetectedWorktreeResult | DetectedWorktreeListResult>
|
|
>()
|
|
})
|
|
|
|
it('forwards full-pair get and push states without cloning away authority', async () => {
|
|
const state: SshConnectionState = {
|
|
targetId: 'ssh-1',
|
|
status: 'connected',
|
|
error: null,
|
|
reconnectAttempt: 0,
|
|
providerEpoch: 'native-provider-epoch' as SshProviderEpoch,
|
|
connectionGeneration: 29
|
|
}
|
|
invoke.mockResolvedValueOnce(state)
|
|
await import('./index')
|
|
const api = exposeInMainWorld.mock.calls.find(([name]) => name === 'api')?.[1] as PreloadApi
|
|
|
|
await expect(api.ssh.getState({ targetId: 'ssh-1' })).resolves.toEqual(state)
|
|
expect(invoke).toHaveBeenCalledWith('ssh:getState', { targetId: 'ssh-1' })
|
|
|
|
const onStateChanged = vi.fn()
|
|
api.ssh.onStateChanged(onStateChanged)
|
|
const listener = on.mock.calls.find(([channel]) => channel === 'ssh:state-changed')?.[1] as (
|
|
event: unknown,
|
|
data: { targetId: string; state: SshConnectionState }
|
|
) => void
|
|
listener({}, { targetId: 'ssh-1', state })
|
|
|
|
expect(onStateChanged).toHaveBeenCalledWith({ targetId: 'ssh-1', state })
|
|
expect(onStateChanged.mock.calls[0]?.[0].state).toEqual(state)
|
|
})
|
|
|
|
it('normalizes partial compatibility authority to unknown for reconciliation', async () => {
|
|
const partialState = {
|
|
targetId: 'ssh-1',
|
|
status: 'connected',
|
|
error: null,
|
|
reconnectAttempt: 0,
|
|
providerEpoch: 'partial-provider-epoch'
|
|
} as SshConnectionState
|
|
invoke.mockResolvedValueOnce(partialState)
|
|
await import('./index')
|
|
const api = exposeInMainWorld.mock.calls.find(([name]) => name === 'api')?.[1] as PreloadApi
|
|
|
|
const returned = await api.ssh.getState({ targetId: 'ssh-1' })
|
|
expect(returned).toEqual({
|
|
targetId: 'ssh-1',
|
|
status: 'connected',
|
|
error: null,
|
|
reconnectAttempt: 0,
|
|
providerEpoch: null
|
|
})
|
|
|
|
const onStateChanged = vi.fn()
|
|
api.ssh.onStateChanged(onStateChanged)
|
|
const listener = on.mock.calls.find(([channel]) => channel === 'ssh:state-changed')?.[1] as (
|
|
event: unknown,
|
|
data: { targetId: string; state: SshConnectionState }
|
|
) => void
|
|
listener({}, { targetId: 'ssh-1', state: partialState })
|
|
|
|
expect(onStateChanged.mock.calls[0]?.[0].state).toEqual({
|
|
targetId: 'ssh-1',
|
|
status: 'connected',
|
|
error: null,
|
|
reconnectAttempt: 0,
|
|
providerEpoch: null
|
|
})
|
|
})
|
|
|
|
it('drops malformed full authority before it reaches the renderer', async () => {
|
|
await import('./index')
|
|
const api = exposeInMainWorld.mock.calls.find(([name]) => name === 'api')?.[1] as PreloadApi
|
|
const onStateChanged = vi.fn()
|
|
api.ssh.onStateChanged(onStateChanged)
|
|
const listener = on.mock.calls.find(([channel]) => channel === 'ssh:state-changed')?.[1] as (
|
|
event: unknown,
|
|
data: { targetId: string; state: SshConnectionState }
|
|
) => void
|
|
|
|
listener(
|
|
{},
|
|
{
|
|
targetId: 'ssh-1',
|
|
state: {
|
|
targetId: 'ssh-1',
|
|
status: 'connected',
|
|
error: null,
|
|
reconnectAttempt: 0,
|
|
providerEpoch: '' as SshProviderEpoch,
|
|
connectionGeneration: 29
|
|
}
|
|
}
|
|
)
|
|
|
|
expect(onStateChanged).not.toHaveBeenCalled()
|
|
})
|
|
})
|