From d4cd4dd2cb8564803e09f0e6d6e4763acb0537a9 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 11 Nov 2026 13:01:34 -0800 Subject: [PATCH] fix(cloud): N-01 lint: no as-casts in phase guards, return await in failAfterStart --- src/main/ipc/cloud-create-phase-timing.ts | 5 ++++- src/main/ipc/ephemeral-vm.ts | 4 ++-- src/shared/orca-cloud/cloud-create-phases.ts | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/ipc/cloud-create-phase-timing.ts b/src/main/ipc/cloud-create-phase-timing.ts index e0c8c225596..36af733c04c 100644 --- a/src/main/ipc/cloud-create-phase-timing.ts +++ b/src/main/ipc/cloud-create-phase-timing.ts @@ -24,7 +24,10 @@ export function noteCloudCreatePhase( if (phase === 'provision-start' || !startedAt.has(creationId)) { startedAt.set(creationId, now) if (startedAt.size > MAX_TRACKED_CREATES) { - startedAt.delete(startedAt.keys().next().value as string) + const oldest = startedAt.keys().next() + if (!oldest.done) { + startedAt.delete(oldest.value) + } } } const since = now - (startedAt.get(creationId) ?? now) diff --git a/src/main/ipc/ephemeral-vm.ts b/src/main/ipc/ephemeral-vm.ts index 4cf740cd9ae..e29e15fdfb3 100644 --- a/src/main/ipc/ephemeral-vm.ts +++ b/src/main/ipc/ephemeral-vm.ts @@ -260,7 +260,7 @@ export function registerEphemeralVmHandlers(store: Store, pluginService?: Plugin warnings: getEphemeralVmRecipeResultWarnings(result.start.result) } } catch (error) { - return failAfterStart(error) + return await failAfterStart(error) } } @@ -272,7 +272,7 @@ export function registerEphemeralVmHandlers(store: Store, pluginService?: Plugin source: 'ephemeral-vm' }) } catch (error) { - return failAfterStart(error) + return await failAfterStart(error) } const runtime = requireEphemeralVmRecipeResult( updateEphemeralVmRuntimeStatus(app.getPath('userData'), result.runtime.id, { diff --git a/src/shared/orca-cloud/cloud-create-phases.ts b/src/shared/orca-cloud/cloud-create-phases.ts index 010e71a888c..3ad62f813a5 100644 --- a/src/shared/orca-cloud/cloud-create-phases.ts +++ b/src/shared/orca-cloud/cloud-create-phases.ts @@ -30,21 +30,24 @@ export type CloudCreateMainPhase = (typeof CLOUD_CREATE_MAIN_PHASES)[number] export type CloudCreateRendererPhase = (typeof CLOUD_CREATE_RENDERER_PHASES)[number] export type CloudCreatePhase = CloudCreateMainPhase | CloudCreateRendererPhase +const RENDERER_PHASES: ReadonlySet = new Set(CLOUD_CREATE_RENDERER_PHASES) + export function isCloudCreateRendererPhase(value: unknown): value is CloudCreateRendererPhase { - return (CLOUD_CREATE_RENDERER_PHASES as readonly unknown[]).includes(value) + return typeof value === 'string' && RENDERER_PHASES.has(value) } -const PROVISION_LINE_PHASES = new Set([ +const PROVISION_LINE_PHASES = [ 'provisioning', 'plan-clone', 'plan-update', 'cloning', 'updating', 'connecting' -]) +] as const satisfies readonly CloudCreateMainPhase[] /** The phase a driver progress line names (`[orca-cloud] …`), or null for any other line. */ export function cloudCreatePhaseFromProvisionLine(line: string): CloudCreateMainPhase | null { const match = /^\[orca-cloud\] ([a-z-]+)/.exec(line.trim()) - return match && PROVISION_LINE_PHASES.has(match[1]) ? (match[1] as CloudCreateMainPhase) : null + const named = match?.[1] + return PROVISION_LINE_PHASES.find((phase) => phase === named) ?? null }