mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user