mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
fix(cloud): re-opening a workspace from its row mid-suspend shows Waking too (W2 P2)
Left during the sleep, then clicked back: activation selects it, then (before its panes mount) marks it asleep and holds the read-only view again, and records the wake, so its panes wait for the wake instead of attaching to a VM going down.
This commit is contained in:
@@ -30,6 +30,8 @@ import {
|
||||
releaseWorktreeSleepView
|
||||
} from '@/lib/worktree-sleep-view'
|
||||
import { requestWakeAfterSleep } from '@/lib/worktree-sleep-wake-request'
|
||||
import { markWorktreeSleepIntent } from '@/lib/worktree-sleep-intent'
|
||||
import { holdActiveCloudSleepView } from '@/components/sidebar/workspace-actions/sleep/workspace-sleep-view-hold'
|
||||
|
||||
/** Coded failures render through the catalog; a thrown IPC error only has its message. */
|
||||
async function settleLifecycleCall(
|
||||
@@ -62,10 +64,21 @@ export async function activateWorktreeFromSidebar(
|
||||
})
|
||||
return { ok: true }
|
||||
}
|
||||
// "Wake to continue" (or opening it) while main is already suspending its VM: the VM must go
|
||||
// down before it can wake, so it shows as waking from now and wakes once the sleep ends (the
|
||||
// sleep follower does that). Opening it now would show dead panes with no cover meanwhile.
|
||||
if (isWorktreeSleepViewHeld(worktreeId) && isWorktreeSuspendCommitted(worktreeId)) {
|
||||
// "Wake to continue", or opening it again from its row, while main is already suspending its VM:
|
||||
// the VM must go down before it can wake, so it shows as waking from now and wakes once the
|
||||
// sleep ends (the sleep follower does that). Opening it now would show dead panes meanwhile.
|
||||
if (isWorktreeSuspendCommitted(worktreeId)) {
|
||||
if (!isWorktreeSleepViewHeld(worktreeId)) {
|
||||
// Left and come back: select it, then (before its panes mount) keep it asleep and on
|
||||
// screen read-only, as when it went to sleep, so its panes wait instead of reattaching.
|
||||
activateAndRevealWorktree(worktreeId, {
|
||||
navigationIntent: 'user-open',
|
||||
revealInSidebar: false,
|
||||
...(executionHostId ? { executionHostId } : {})
|
||||
})
|
||||
markWorktreeSleepIntent(worktreeId)
|
||||
holdActiveCloudSleepView(worktreeId)
|
||||
}
|
||||
requestWakeAfterSleep(worktreeId, Date.now())
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
const mocks = vi.hoisted(() => ({
|
||||
beginWorkspaceWake: vi.fn(),
|
||||
activateAndRevealWorktree: vi.fn(),
|
||||
holdActiveCloudSleepView: vi.fn(() => true),
|
||||
resumeWorkspace: vi.fn()
|
||||
}))
|
||||
|
||||
@@ -13,6 +14,9 @@ vi.mock('@/components/terminal-pane/input/wake-input-buffer', () => ({
|
||||
beginWorkspaceWake: mocks.beginWorkspaceWake,
|
||||
endWorkspaceWake: vi.fn()
|
||||
}))
|
||||
vi.mock('@/components/sidebar/workspace-actions/sleep/workspace-sleep-view-hold', () => ({
|
||||
holdActiveCloudSleepView: mocks.holdActiveCloudSleepView
|
||||
}))
|
||||
vi.mock('@/lib/workspace/activation/worktree-activation', () => ({
|
||||
activateAndRevealFolderWorkspace: vi.fn(),
|
||||
activateAndRevealWorktree: mocks.activateAndRevealWorktree
|
||||
@@ -34,6 +38,7 @@ import {
|
||||
resetWorktreeSleepViewForTests
|
||||
} from './worktree-sleep-view'
|
||||
import { activateWorktreeFromSidebar } from './workspace/activation/sidebar-worktree-activation'
|
||||
import { forgetWorktreeSleepIntent, hasWorktreeSleepIntent } from './worktree-sleep-intent'
|
||||
|
||||
const WS = 'cloud-wt'
|
||||
const PRESS = 1_800_000_000_000
|
||||
@@ -45,6 +50,7 @@ beforeEach(() => {
|
||||
afterEach(() => {
|
||||
resetWakeAfterSleepForTests()
|
||||
resetWorktreeSleepViewForTests()
|
||||
forgetWorktreeSleepIntent(WS)
|
||||
vi.unstubAllGlobals()
|
||||
cleanup()
|
||||
})
|
||||
@@ -88,6 +94,25 @@ describe('wake pressed while main suspends the VM', () => {
|
||||
expect(mocks.resumeWorkspace).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('re-opening it from its row after leaving mid-sleep selects it, kept asleep, and waits', async () => {
|
||||
// Left during the sleep: the read-only hold ended with the selection.
|
||||
markWorktreeSuspendCommitted(WS)
|
||||
await expect(activateWorktreeFromSidebar(WS)).resolves.toEqual({ ok: true })
|
||||
expect(mocks.activateAndRevealWorktree).toHaveBeenCalledWith(
|
||||
WS,
|
||||
expect.objectContaining({ navigationIntent: 'user-open' })
|
||||
)
|
||||
// Selecting clears sleep intent; it is put back (and the view held) right after, before any
|
||||
// pane mounts, so the panes wait for the wake instead of attaching to a VM going down.
|
||||
expect(hasWorktreeSleepIntent(WS)).toBe(true)
|
||||
expect(mocks.holdActiveCloudSleepView).toHaveBeenCalledWith(WS)
|
||||
expect(mocks.holdActiveCloudSleepView.mock.invocationCallOrder[0]).toBeGreaterThan(
|
||||
mocks.activateAndRevealWorktree.mock.invocationCallOrder[0]
|
||||
)
|
||||
expect(hasWakeAfterSleepRequest(WS)).toBe(true)
|
||||
expect(mocks.resumeWorkspace).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('opening it before the suspend is committed still wakes the ordinary way', async () => {
|
||||
holdWorktreeSleepView(WS)
|
||||
mocks.resumeWorkspace.mockResolvedValue({ ok: true })
|
||||
|
||||
Reference in New Issue
Block a user