From caf089751cfc4d35d04933647f3a57e72bfbf579 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 11 Nov 2026 02:13:16 -0800 Subject: [PATCH] fix(cloud): the row reads running, not Asleep, right after a wake goes live (W2 P3) Seen on m4air: ~200ms after a wake went live the sidebar row read "Asleep", because main's ready arrives before the status re-read and the last read still said sleeping. A ready wake newer than the last status read now counts as running; a read taken after it (or archived/failed) is the truth again. --- .../orca-cloud-workspace-state.test.ts | 25 +++++++++++++++++++ .../orca-cloud/orca-cloud-workspace-state.ts | 6 +++++ 2 files changed, 31 insertions(+) diff --git a/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.test.ts b/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.test.ts index 3b17266bc14..c65a3d76f23 100644 --- a/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.test.ts +++ b/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.test.ts @@ -124,6 +124,31 @@ describe('deriveCloudDotState', () => { }) describe('visibleOom', () => { + it('a wake main reported ready after the last status read is running, not the stale read', () => { + // The status was read (asleep) before the wake; main's ready lands before the re-read. + const asleepBefore = { ...status('sleeping'), checkedAt: NOW - 5_000 } + expect( + deriveCloudDotState({ status: asleepBefore, wake: wake('ready'), sleeping: false, now: NOW }) + ).toBe('running') + expect( + deriveCloudDotState({ status: null, wake: wake('ready'), sleeping: true, now: NOW }) + ).toBe('running') + // A read taken after the ready is the truth again (it slept since). + const asleepAfter = { ...status('sleeping'), checkedAt: NOW + 5_000 } + expect( + deriveCloudDotState({ status: asleepAfter, wake: wake('ready'), sleeping: false, now: NOW }) + ).toBe('sleeping') + // Archived and failed still win over a ready wake. + expect( + deriveCloudDotState({ + status: { ...status('archived'), checkedAt: NOW - 5_000 }, + wake: wake('ready'), + sleeping: false, + now: NOW + }) + ).toBe('archived') + }) + it('hides kills the user dismissed and shows newer ones', () => { const oom = { workspaceId: 'w', oomKills: 2, victim: 'node', at: NOW } expect(visibleOom(oom, undefined)).toBe(oom) diff --git a/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.ts b/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.ts index 5d32e52d407..58ae81b69bd 100644 --- a/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.ts +++ b/src/renderer/src/lib/orca-cloud/orca-cloud-workspace-state.ts @@ -62,6 +62,12 @@ export function deriveCloudDotState(input: { if (status?.state === 'failed') { return 'failed' } + // Main said this wake is ready after the last status read: that read (still "sleeping" or + // "waking" until the re-read lands) is stale, and the VM answers. Without this the row read + // "Asleep" for a moment after the workspace went live. + if (wake?.phase === 'ready' && (!status || status.checkedAt < wake.at)) { + return 'running' + } // The control plane is the truth for the VM; the desktop's own sleep record only fills in // before the first status read (a cloud workspace with no open panes is not asleep). if (!status) {