Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/scripts/check-id-only-store-write-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const UNIQUE_FOLDER_ID = 'folder workspace ids are minted UUIDs, one row per id
export const NOT_HOST_TWINNED = new Map([
['AutomationPersistence.advanceAutomationNextRun', 'automation ids are minted UUIDs'],
['AutomationPersistence.deleteAutomation', 'automation ids are minted UUIDs'],
['AutomationPersistence.disableAutomations', 'automation ids are minted UUIDs'],
['AutomationPersistence.updateAutomation', 'automation ids are minted UUIDs'],
[
'MetadataLineageOperations.removeUnhostedWorktreeMeta',
Expand Down
8 changes: 7 additions & 1 deletion config/scripts/pr-e2e-source-routing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const MANUAL_ONLY_E2E_SPECS = ['tests/e2e/ssh-orcad-phone-feed-list.spec.
const MANAGED_SSH_HARNESS =
/^tests\/e2e\/helpers\/(?:orcad-managed-workspace|orcad-convert-(?:flow|host|teardown)|orcad-template-variant|orcad-upgrade-(?:profile|retained-state)|docker-ssh-host-target|reserve-local-port|ssh-remote-only-browser-fixture|windows-host-orcad-processes)\.ts$/

// An enabled SSH automation moves with its host and is re-enabled on the server (#29083).
const ENABLED_AUTOMATION_MOVE =
/^src\/(?:main\/(?:persistence\/(?:migrating-orcad-catalog\/orcad-(?:source-automation-state|source-dormant-state|source-dependency-census|destination-automation-state)|scheduling-automations\/automation-schedule-operations)|automations\/(?:run-target-resolution|automation-dispatch-request|orcad-fenced-automation)|ssh\/orcad-migration-(?:moved-automations|source-retention))|shared\/orcad-migration\/orcad-migration-(?:dormant-automation-validation|source-cutover))\.ts$/

export const PR_E2E_SOURCE_ROUTES = [
{
id: 'ssh.orcad-editor-ownership',
Expand Down Expand Up @@ -148,10 +152,12 @@ export const PR_E2E_SOURCE_ROUTES = [
id: 'ssh.orcad-connect-failure',
specs: [
'tests/e2e/ssh-orcad-ssh-failure-reason.spec.ts',
'tests/e2e/ssh-orcad-move-anyway-inline.spec.ts'
'tests/e2e/ssh-orcad-move-anyway-inline.spec.ts',
'tests/e2e/ssh-orcad-enabled-automation-move.spec.ts'
],
matches: (file) =>
MANAGED_SSH_HARNESS.test(file) ||
ENABLED_AUTOMATION_MOVE.test(file) ||
(isProductSource(file) &&
/^src\/(?:main\/(?:ipc\/ssh\/(?:ssh-connect-flow|ssh-host-server-)|ssh\/(?:ssh-session-start-failure|ssh-host-server-|connection\/ssh-connection-manager|orcad-migration-refusal-reason|targets\/ssh-target-orcad-preflight)|managed-server\/lifecycle\/orcad-runtime-conversion|persistence\/migrating-orcad-catalog\/orcad-source-(?:automation-state|leave-behind-view))|renderer\/src\/(?:ssh\/(?:ssh-host-server-status-copy|ssh-connect-failure-toast)|components\/settings\/(?:SshTargetServerStatus|SshHostMoveAnywayAction|SshTargetCard)))/.test(
file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class AutomationDispatchCancelledError extends Error {}
45 changes: 45 additions & 0 deletions src/main/automations/automation-dispatch-host-fence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { Store } from '../persistence'
import { resolveAutomationRunTarget } from './run-target-resolution'
import { AutomationService } from './service'
import { closeTestStores, createStore, testState } from '../persistence/persistence-test-harness'
import { writeOrcadMigrationSourceCutover } from '../ssh/orcad-migration-cutover-journal'
import { orcadMigrationCutoverFixture } from '../ssh/orcad-migration-cutover-fixture'

vi.mock('electron', () => ({
app: {
Expand Down Expand Up @@ -295,4 +297,47 @@ describe('scheduled dispatch fenced on the host the record captured', () => {
expect(runs).toHaveLength(1)
expect(runs[0]).toMatchObject({ error: REPLACED, occurrenceCount: 3 })
})

// #29083: the host's server owns its automations once a move fences it.
it('writes nothing for a host a move fenced, and resumes when the fence is released', async () => {
vi.setSystemTime(new Date('2026-05-13T08:00:00'))
const store = await createStore()
const automation = seedSshAutomation(store)
const { service, send } = attachedService(store)
store.updateSshTarget(TARGET_ID, { orcadFence: { environmentId: 'env-1' } })
const before = store.listAutomations()[0]

vi.setSystemTime(new Date('2026-05-13T09:01:00'))
service.setRendererReady()
await vi.advanceTimersByTimeAsync(0)
await expect(service.runNow(automation.id)).rejects.toThrow(
"This automation now runs on its SSH host's Orca server."
)
await service.recordRefusedRun(automation.id)

expect(send).not.toHaveBeenCalled()
expect(store.listAutomationRuns(automation.id)).toEqual([])
expect(store.listAutomations()[0]).toEqual(before)

store.updateSshTarget(TARGET_ID, { orcadFence: undefined })
await evaluateAt(store, service, automation.id, '2026-05-13T09:02:00')

expect(send).toHaveBeenCalledWith('automations:dispatchRequested', expect.anything())
})

it('still runs an automation Move anyway left on this desktop', async () => {
vi.setSystemTime(new Date('2026-05-13T08:00:00'))
const store = await createStore()
const automation = seedSshAutomation(store)
const { service, send } = attachedService(store)
writeOrcadMigrationSourceCutover(testState.dir, {
...orcadMigrationCutoverFixture('m-1', TARGET_ID, { generation: 1 }),
phase: 'destination-committed'
})
store.updateSshTarget(TARGET_ID, { orcadFence: { environmentId: 'env-1' } })

await evaluateAt(store, service, automation.id, '2026-05-13T09:01:00')

expect(send).toHaveBeenCalledWith('automations:dispatchRequested', expect.anything())
})
})
8 changes: 7 additions & 1 deletion src/main/automations/automation-dispatch-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import {
describeScheduledRefusal,
sendRendererDispatch
} from './dispatch-refusal'
import { isOrcadFencedAutomation, ORCAD_FENCED_AUTOMATION } from './orcad-fenced-automation'
import { AutomationDispatchCancelledError } from './automation-dispatch-cancelled-error'

export type AutomationRendererChannel = Pick<WebContents, 'isDestroyed' | 'send'>

export class AutomationDispatchCancelledError extends Error {}
export { AutomationDispatchCancelledError }

type DispatchContext = Pick<
HeadlessAutomationDispatchContext,
Expand Down Expand Up @@ -70,6 +72,10 @@ export async function requestAutomationDispatch(
'The automation was removed before it could launch.'
)
}
// A refusal row would change the fenced export; restart strands the run instead.
if (isOrcadFencedAutomation(ctx.store, automation)) {
throw new AutomationDispatchCancelledError(ORCAD_FENCED_AUTOMATION)
}
return current
}
const resolveCurrentTarget = (): AutomationRunTargetResult => {
Expand Down
4 changes: 4 additions & 0 deletions src/main/automations/dispatch-refusal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import { resolveAutomationRunTarget, type AutomationRunTargetResult } from './run-target-resolution'
import type { AutomationRunWriter } from './automation-run-writer'
import { wslMoveRepoBackoff } from '../persistence/moving-wsl-projects/wsl-move-background-backoff'
import { isOrcadFencedAutomation } from './orcad-fenced-automation'

export const NO_DISPATCH_HOST = 'No Orca window was available to launch the automation.'

Expand Down Expand Up @@ -45,6 +46,9 @@ export async function recordRefusedAutomationRun(input: {
automation: Automation
allowRemoteHostScheduling: boolean
}): Promise<void> {
if (isOrcadFencedAutomation(input.store, input.automation)) {
return
}
const target = resolveAutomationRunTarget(input.store, input.automation, {
allowRemoteHostScheduling: input.allowRemoteHostScheduling
})
Expand Down
35 changes: 35 additions & 0 deletions src/main/automations/orcad-fenced-automation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getAppEnvironment } from '../../shared/app-environment'
import type { Automation } from '../../shared/automations-types'
import type { Store } from '../persistence'
import { listOrcadMigrationCutoverChainForTarget } from '../ssh/orcad-migration-cutover-journal'

export const ORCAD_FENCED_AUTOMATION = "This automation now runs on its SSH host's Orca server."

/** While a move is in flight, or once it took this row, any desktop write would break or duplicate it. Rows Move anyway left behind stay runnable here. */
export function isOrcadFencedAutomation(
store: Pick<Store, 'getSshTarget'>,
automation: Pick<Automation, 'id' | 'executionTargetType' | 'executionTargetId'>,
userDataPath: () => string = () => getAppEnvironment().getPath('userData')
): boolean {
if (
automation.executionTargetType !== 'ssh' ||
store.getSshTarget(automation.executionTargetId)?.orcadFence === undefined
) {
return false
}
let chain
try {
chain = listOrcadMigrationCutoverChainForTarget(userDataPath(), automation.executionTargetId)
} catch {
return true // An unreadable journal can't show the row stayed behind.
}
return (
chain.length === 0 ||
chain.some(
(cutover) =>
cutover.phase === 'source-fenced' ||
cutover.phase === 'destination-staged' ||
cutover.manifest.payload.dormantState?.automations?.some(({ id }) => id === automation.id)
)
)
}
6 changes: 6 additions & 0 deletions src/main/automations/run-target-resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
buildWorkspaceRunContext,
type WorkspaceRunContext
} from '../../shared/task-source-context'
import { AutomationDispatchCancelledError } from './automation-dispatch-cancelled-error'
import { isOrcadFencedAutomation, ORCAD_FENCED_AUTOMATION } from './orcad-fenced-automation'

export type AutomationRunTargetResult =
| { ok: true; cwd: string; repo: Repo; setup?: ProjectHostSetup }
Expand Down Expand Up @@ -120,6 +122,10 @@ export function captureLegacyRunTarget(
automation: Automation,
allowRemoteHostScheduling: boolean
): Automation {
// The scheduler's first write; a fenced row must stay as the move exported it.
if (isOrcadFencedAutomation(store, automation)) {
throw new AutomationDispatchCancelledError(ORCAD_FENCED_AUTOMATION)
}
const runContext = findLegacyAutomationRunContextStamp(store, automation, {
allowRemoteHostScheduling
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ vi.mock('../../ssh/orcad-migration-delta-move', () => ({
keepOrcadServerVersion: mocks.keep
}))
vi.mock('../../managed-server/lifecycle/orcad-runtime-conversion-wiring', () => ({
orcadMigrationDestinationFor: mocks.destinationFor
orcadMigrationDestinationFor: mocks.destinationFor,
orcadServerAutomationEnablerFor: () => vi.fn()
}))
vi.mock('../../managed-server/lifecycle/orcad-managed-tunnel', () => ({
ensureOrcadManagedTunnel: mocks.ensure
Expand Down Expand Up @@ -82,7 +83,7 @@ describe('resolving a host an older build changed', () => {
expect(mocks.publish).not.toHaveBeenCalled()
mocks.move.mockResolvedValueOnce({ outcome: 'moved', migrationId: 'm' })
await handler('runtimeEnvironments:moveOrcadDelta')(null, { sshTargetId: 'ssh-1' })
expect(mocks.publish).toHaveBeenCalledWith(mocks.target, 'env-1')
expect(mocks.publish).toHaveBeenCalledWith(mocks.target, 'env-1', 0)
})

it('refreshes the host status after keeping the server version', async () => {
Expand Down
18 changes: 16 additions & 2 deletions src/main/ipc/runtime-environments/orcad-delta-move-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { ensureOrcadManagedTunnel } from '../../managed-server/lifecycle/orcad-m
import { keepOrcadServerVersion, runOrcadDeltaMove } from '../../ssh/orcad-migration-delta-move'
import { planOrcadDeltaMove } from '../../ssh/orcad-migration-delta-plan'
import { censusHostRelayTerminalsFor } from '../../ssh/legacy-relay/ssh-host-relay-census-for-target'
import { orcadMigrationDestinationFor } from '../../managed-server/lifecycle/orcad-runtime-conversion-wiring'
import {
orcadMigrationDestinationFor,
orcadServerAutomationEnablerFor
} from '../../managed-server/lifecycle/orcad-runtime-conversion-wiring'
import { enableMovedOrcadAutomationsForTarget } from '../../ssh/orcad-migration-moved-automations'
import { requiredString } from './orcad-runtime-lifecycle-handlers'
import { publishResolvedChangedHostStatus } from './runtime-environment-managed-tunnel'
import { runTargetLifecycle } from '../ssh/ssh-target-lifecycle-queue'
Expand Down Expand Up @@ -50,7 +54,17 @@ export function registerOrcadDeltaMoveHandlers(getUserDataPath: () => string): v
runTargetLifecycle
})
if (result.outcome === 'moved') {
publishResolvedChangedHostStatus(target, environment.id)
// Tunnel repair may have re-paired the server; read its current credentials.
const paired = listEnvironments(userDataPath).find((entry) => entry.id === environment.id)
const automationsLeftDisabled = await enableMovedOrcadAutomationsForTarget(
userDataPath,
target.id,
orcadServerAutomationEnablerFor(paired ?? environment)
).catch((error: unknown) => {
console.warn('[ssh] Could not re-enable moved automations:', error)
return 0
})
publishResolvedChangedHostStatus(target, environment.id, automationsLeftDisabled)
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,16 @@ export function installManagedOrcadStartStatus(): void {
})
}

export function publishResolvedChangedHostStatus(target: SshTarget, environmentId: string): void {
setSshHostServerStatus(target.id, { kind: 'managed', environmentId })
export function publishResolvedChangedHostStatus(
target: SshTarget,
environmentId: string,
automationsLeftDisabled = 0
): void {
setSshHostServerStatus(target.id, {
kind: 'managed',
environmentId,
...(automationsLeftDisabled > 0 ? { automationsLeftDisabled } : {})
})
// Moves release the relay session; publish even when its stale status line is disconnected.
broadcastSshState(
getCurrentMainWindow,
Expand Down
3 changes: 2 additions & 1 deletion src/main/ipc/ssh/ssh-connect-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ async function doConnect(
server.environmentId,
server.update,
server.serving,
server.linked
server.linked,
server.automationsLeftDisabled
)
// Publish first; the macOS-only check adds remote round trips.
void import('./ssh-host-launch-session-note')
Expand Down
6 changes: 4 additions & 2 deletions src/main/ipc/ssh/ssh-host-server-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ export function publishManagedServerConnect(
environmentId: string,
update?: SshManagedServerUpdateNote,
serving?: SshManagedServerServingNote,
linked?: SshManagedServerLinkedProject[]
linked?: SshManagedServerLinkedProject[],
automationsLeftDisabled?: number
): SshConnectionState {
const managedServer = {
kind: 'managed' as const,
environmentId,
...(update ? { update } : {}),
...(serving ? { serving } : {}),
...(linked ? { linked } : {})
...(linked ? { linked } : {}),
...(automationsLeftDisabled ? { automationsLeftDisabled } : {})
Comment on lines +82 to +83

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Data Integrity & Integration · Quick win

🔎 Supported by static analysis

Script executed:

rg -n 'admitSshRetainedPayload|admitSshManagedServerStatus|managedServer:|publishManagedServerConnect' src/main/ipc/ssh src/main/ssh src/shared/ssh-retained-payload-admission.ts src/renderer/src/ssh
sed -n '65,110p' src/shared/ssh-retained-payload-admission.ts

Repository: stablyai/orca

Length of output: 10252


Script executed:

set -o pipefail
printf '%s\n' '--- references ---'
rg -n -F --glob '*.ts' -e 'automationsLeftDisabled' -e 'admitSshManagedServerStatus' -e 'publishManagedServerConnect' -e 'retained' -e 'retainedPayload' src/main src/shared src/renderer/src/ssh | head -n 240
printf '%s\n' '--- managed status admission ---'
nl -ba src/shared/ssh-managed-server-status-admission.ts
printf '%s\n' '--- managed status types ---'
rg -n -F --glob '*.ts' -e 'SshManagedServerStatus' -e 'SshManagedServerLinkedProject' src/shared src/main src/renderer | head -n 160
printf '%s\n' '--- publisher and connect call ---'
nl -ba src/main/ipc/ssh/ssh-host-server-connect.ts | sed -n '1,115p'
nl -ba src/main/ipc/ssh/ssh-connect-flow.ts | sed -n '145,195p'
printf '%s\n' '--- retained payload admission and related persistence ---'
nl -ba src/shared/ssh-retained-payload-admission.ts | sed -n '1,175p'
rg -n -F --glob '*.ts' -e 'admitSshRetainedPayload' -e 'SshRetainedPayload' -e 'managedServer' src/main src/shared | head -n 220
printf '%s\n' '--- focused tests ---'
rg -n -F --glob '*.test.ts' -e 'automationsLeftDisabled' -e 'retained' -e 'admitSshManagedServerStatus' src/main src/shared src/renderer/src/ssh | head -n 220

Repository: stablyai/orca

Length of output: 41387


Script executed:

set -o pipefail
printf '%s\n' '--- exact admission and status definitions ---'
nl -ba src/shared/ssh-managed-server-status-admission.ts
rg -n -F --glob '*.ts' -e 'interface SshManagedServerStatus' -e 'type SshManagedServerStatus' -e 'SshManagedServerStatus =' -e 'SshConnectionState' -e 'admitSshConnectionState' -e 'admitSshRetainedPayload' src/shared src/main/ssh src/main/ipc/ssh src/renderer/src/ssh
printf '%s\n' '--- SSH persistence calls ---'
rg -n -F --glob '*.ts' -e 'save.*ssh' -e 'ssh.*save' -e 'persist.*ssh' -e 'ssh.*persist' -e 'retainedPayload' -e 'connectionState' -e 'connection state' src/main/ssh src/main/ipc/ssh src/shared | head -n 260
printf '%s\n' '--- retained payload complete file ---'
nl -ba src/shared/ssh-retained-payload-admission.ts
printf '%s\n' '--- connection state types and storage candidates ---'
rg -n -F --glob '*.ts' -e 'managedServer?:' -e 'managedServer:' -e 'plainSsh' -e 'supportsFolderDownload' src/main/ssh src/main/ipc/ssh src/shared | head -n 260
printf '%s\n' '--- focused tests and status copy ---'
nl -ba src/renderer/src/ssh/ssh-host-server-status-copy.ts | sed -n '1,90p'
rg -n -F --glob '*.test.ts' -e 'admitSshConnectionState' -e 'admitSshRetainedPayload' -e 'automationsLeftDisabled' -e 'managedServer' src/shared src/main/ssh src/main/ipc/ssh src/renderer/src/ssh | head -n 260

Repository: stablyai/orca

Length of output: 42296


Script executed:

set -o pipefail
printf '%s\n' '--- all retained SSH state bindings ---'
rg -n -F --glob '*.ts' -e 'sshConnectionStates' -e 'admitSshConnectionState' -e 'admitSshConnectionStateForAuthorityReconciliation' -e 'getRetained' -e 'setRetained' -e 'retainedPayload' src
printf '%s\n' '--- SSH state type and publisher/broadcast owners ---'
nl -ba src/shared/ssh-types.ts | sed -n '215,335p'
nl -ba src/main/ipc/ssh/ssh-host-server-connect.ts | sed -n '60,125p'
nl -ba src/main/ipc/ssh/ssh-renderer-broadcast.ts | sed -n '1,100p'
nl -ba src/main/ipc/ssh/ssh-connection-state-callbacks.ts | sed -n '1,90p'
printf '%s\n' '--- runtime/client hydration candidates ---'
rg -n -i --glob '*.ts' 'hydrate|hydration|retained.*state|state.*retained|runtime.*snapshot|snapshot.*runtime|connection.*state' src/main/runtime src/main/persistence src/main src/shared | grep -i -E 'ssh|retained|runtime|snapshot|hydrate' | head -n 320
printf '%s\n' '--- admission tests around managed status ---'
nl -ba src/shared/ssh-retained-payload-admission.test.ts | sed -n '1,115p'

Repository: stablyai/orca

Length of output: 42468


Script executed:

set -o pipefail
printf '%s\n' '--- preload SSH bridge ---'
nl -ba src/preload/api/ssh-bridge.ts | sed -n '1,125p'
printf '%s\n' '--- renderer runtime SSH hydration ---'
nl -ba src/renderer/src/runtime/runtime-environment-ssh-state.ts | sed -n '1,330p'
nl -ba src/renderer/src/runtime/runtime-client-events.ts | sed -n '1,105p'
printf '%s\n' '--- main SSH state IPC and handlers ---'
rg -n -F --glob '*.ts' -e 'ssh:getState' -e 'getState(targetId' -e 'getRegisteredSshState' -e 'getPublicSshState' -e 'stateChanged' -e 'onStateChange' src/main src/preload src/shared
nl -ba src/main/ipc/ssh/ssh-target-registry.ts | sed -n '1,90p'
nl -ba src/main/ipc/ssh/ssh-renderer-broadcast.ts | sed -n '1,90p'
nl -ba src/main/ipc/ssh/ssh-connection-state-callbacks.ts | sed -n '1,80p'
printf '%s\n' '--- renderer store hydration entrypoints ---'
nl -ba src/renderer/src/store/slices/ssh.ts | sed -n '1,125p'

Repository: stablyai/orca

Length of output: 42277


Script executed:

set -o pipefail
printf '%s\n' '--- managed status owner and lifecycle ---'
nl -ba src/main/ssh/ssh-host-server-status.ts
rg -n -F --glob '*.ts' -e 'setSshHostServerStatus' -e 'getSshHostServerStatus' -e 'clearSshHostServerStatus' -e 'publishManagedServerConnect' -e 'publishUnservedHostServer' src/main src/shared src/renderer
printf '%s\n' '--- runtime SSH RPC methods ---'
nl -ba src/main/runtime/rpc/methods/ssh.ts | sed -n '1,135p'
nl -ba src/main/runtime/rpc/methods/client-events.ts | sed -n '1,110p'
printf '%s\n' '--- runtime client event stream ---'
nl -ba src/shared/runtime-client-events.ts | sed -n '1,120p'
nl -ba src/renderer/src/runtime/runtime-client-events.ts | sed -n '1,125p'
printf '%s\n' '--- main IPC registration for ssh:getState ---'
rg -n -F --glob '*.ts' -e "'ssh:getState'" -e '"ssh:getState"' -e "ipcMain.handle" src/main/ipc/ssh src/main

Repository: stablyai/orca

Length of output: 41921


Script executed:

set -o pipefail
printf '%s\n' '--- managed status type ---'
nl -ba src/shared/ssh-types.ts | sed -n '285,325p'
printf '%s\n' '--- connect publisher and teardown ---'
nl -ba src/main/ipc/ssh/ssh-host-server-connect.ts | sed -n '35,100p'
nl -ba src/main/ipc/ssh/ssh-session-teardown.ts | sed -n '1,45p'
printf '%s\n' '--- runtime ready snapshot ---'
nl -ba src/main/runtime/rpc/methods/client-events.ts | sed -n '35,65p'
nl -ba src/renderer/src/runtime/runtime-client-events.ts | sed -n '40,85p'
printf '%s\n' '--- admission test current managed cases ---'
nl -ba src/shared/ssh-retained-payload-admission.test.ts | sed -n '1,85p'

Repository: stablyai/orca

Length of output: 14529


Preserve automationsLeftDisabled during retained-status admission.

A renderer reload or runtime reconnect snapshots the live managed status. admitSshManagedServerStatus then removes automationsLeftDisabled, so Settings loses the notice while the server keeps those automations disabled. This correction is separate from combining renderer warning lines.

Suggested fix
     const linked = admitSshManagedServerLinkedProjects('linked' in value ? value.linked : undefined)
+    const automationsLeftDisabled =
+      'automationsLeftDisabled' in value &&
+      isNonNegativeSafeInteger(value.automationsLeftDisabled)
+        ? { automationsLeftDisabled: value.automationsLeftDisabled }
+        : {}
     return {
       managedServer: {
         kind: 'managed',
         environmentId: value.environmentId,
         ...update,
         ...serving,
-        ...linked
+        ...linked,
+        ...automationsLeftDisabled
       }
     }

}
setSshHostServerStatus(targetId, managedServer)
const state: SshConnectionState = {
Expand Down
21 changes: 18 additions & 3 deletions src/main/ipc/ssh/ssh-host-server-on-connect-wiring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { listEnvironments } from '../../../shared/runtime-environment-store'
import { findOrcadMigrationSourceCutoverForTarget } from '../../ssh/orcad-migration-cutover-journal'
import { abandonOrcadConversion } from '../../ssh/orcad-conversion-abandon'
import { retainOrcadMigrationSource } from '../../ssh/orcad-migration-source-retention'
import { enableMovedOrcadAutomationsForTarget } from '../../ssh/orcad-migration-moved-automations'
import { hasOrcadTemplate } from '../../orcad/orcad-artifact-materializer'
import { isOrcadHostUnavailableFixableOnHost } from '../../orcad/orcad-host-unavailable'
import { managedServerUpdateDeps } from '../../ssh/managed-server-update-deps'
Expand All @@ -15,6 +16,7 @@ import { verifyOrcadManagedServing } from '../../managed-server/lifecycle/orcad-
import { convertSshTargetToManagedOrcad } from '../../managed-server/lifecycle/orcad-runtime-conversion'
import {
orcadMigrationDestinationFor,
orcadServerAutomationEnablerFor,
orcadServerFolderCatalogFor,
orcadServerRepositoriesFor
} from '../../managed-server/lifecycle/orcad-runtime-conversion-wiring'
Expand Down Expand Up @@ -57,9 +59,21 @@ export function hostServerOnConnectDeps(userDataPath: string): HostServerOnConne
ensureServing: (environmentId) => verifyOrcadManagedServing(userDataPath, environmentId),
retainCommittedSource: async (target) => {
const head = findOrcadMigrationSourceCutoverForTarget(userDataPath, target.id)
if (head?.phase === 'destination-committed') {
await retainOrcadMigrationSource(userDataPath, head.migrationId, store)
if (head?.phase !== 'destination-committed') {
return 0
}
await retainOrcadMigrationSource(userDataPath, head.migrationId, store)
// Retry what earlier connects could not reach the server to re-enable.
const environment = listEnvironments(userDataPath).find(
(entry) => entry.id === head.destinationEnvironmentId
)
return environment
? enableMovedOrcadAutomationsForTarget(
userDataPath,
target.id,
orcadServerAutomationEnablerFor(environment)
)
: 0
},
hasTemplate: hasOrcadTemplate,
recordedUnavailable: (target) =>
Expand Down Expand Up @@ -112,7 +126,8 @@ export function hostServerOnConnectDeps(userDataPath: string): HostServerOnConne
// Releasing the direct session here would cancel the connect that requested conversion.
destinationFor: orcadMigrationDestinationFor,
serverRepositoriesFor: orcadServerRepositoriesFor,
serverFolderCatalogFor: orcadServerFolderCatalogFor
serverFolderCatalogFor: orcadServerFolderCatalogFor,
serverAutomationEnablerFor: orcadServerAutomationEnablerFor
})
if (converted.outcome === 'converted' || converted.outcome === 'refused') {
// Move-anyway consent covers one attempt; retain it on failure so held-fence verification can resume.
Expand Down
1 change: 1 addition & 0 deletions src/main/ipc/ssh/ssh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('SSH IPC handlers', () => {
'env-test',
undefined,
undefined,
undefined,
undefined
)
expect(mockConnectionManager.connect).not.toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
stageRemoteOrcadMigrationSnapshotChunk
} from '../../ssh/orcad-migration-catalog-client'
import { abortRemoteOrcadMigrationCatalogByReference } from '../../ssh/orcad-migration-catalog-reference-client'
import {
enableRemoteOrcadAutomation,
type EnableServerAutomation
} from '../../ssh/orcad-migration-moved-automations'
import { censusHostRelayTerminalsFor } from '../../ssh/legacy-relay/ssh-host-relay-census-for-target'
import { isBridgeableLease } from '../../ssh/legacy-relay/legacy-relay-bridge-leases'
import type { OrcadManagedConversionArgs } from './orcad-runtime-conversion'
Expand Down Expand Up @@ -59,11 +63,20 @@ export function orcadServerFolderCatalogFor(
)
}

export function orcadServerAutomationEnablerFor(
environment: KnownRuntimeEnvironment
): EnableServerAutomation {
const pairingCode = encodePairingOffer(getPreferredPairingOffer(environment))
const options = environment.runtimeId ? { expectedRuntimeId: environment.runtimeId } : {}
return (automation) => enableRemoteOrcadAutomation(pairingCode, automation, options)
}

export function conversionCollaborators(): Pick<
OrcadManagedConversionArgs,
| 'destinationFor'
| 'serverRepositoriesFor'
| 'serverFolderCatalogFor'
| 'serverAutomationEnablerFor'
| 'censusHost'
| 'isBridgedPaneLease'
| 'releaseDirectSession'
Expand All @@ -72,6 +85,7 @@ export function conversionCollaborators(): Pick<
destinationFor: orcadMigrationDestinationFor,
serverRepositoriesFor: orcadServerRepositoriesFor,
serverFolderCatalogFor: orcadServerFolderCatalogFor,
serverAutomationEnablerFor: orcadServerAutomationEnablerFor,
censusHost: (target) => censusHostRelayTerminalsFor(target)(),
isBridgedPaneLease: isBridgeableLease,
releaseDirectSession: disconnectRegisteredSshTarget
Expand Down
Loading
Loading