mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
fix(cloud): WAKE-SCROLLBACK hold rendering from the woken terminal's bind (the process-boundary ground released it), so no pre-restore clear is painted; tests on a fixed clock
This commit is contained in:
+12
-1
@@ -1,5 +1,9 @@
|
||||
import { PROCESS_BOUNDARY_GROUND } from '../../../../../../shared/terminal/protocol/input-modes/terminal-mode-reset-profiles'
|
||||
import type { ConnectPanePtySession } from '../connect-pane-pty-session'
|
||||
import {
|
||||
HOLD_RENDER_UNTIL_RESTORED,
|
||||
hasPendingWakeScrollback
|
||||
} from '@/lib/orca-cloud/cloud-wake-scrollback'
|
||||
|
||||
/** A replaced process must not inherit the old one's input modes (#35559). */
|
||||
export function bindReplacedProcessInputModes(session: ConnectPanePtySession): void {
|
||||
@@ -8,7 +12,14 @@ export function bindReplacedProcessInputModes(session: ConnectPanePtySession): v
|
||||
|
||||
session.groundInputModesForNewProcess = (): void => {
|
||||
session.inputModeOwnerIncarnationId = null
|
||||
session.writeInputModeGround(PROCESS_BOUNDARY_GROUND)
|
||||
// WAKE-SCROLLBACK: the ground releases DEC 2026; a woken cloud pane with pre-sleep output to put
|
||||
// back re-holds rendering here, at the new terminal's bind, so no clear before its restore is
|
||||
// ever painted (the restore releases it).
|
||||
session.writeInputModeGround(
|
||||
hasPendingWakeScrollback(session.pane.leafId)
|
||||
? `${PROCESS_BOUNDARY_GROUND}${HOLD_RENDER_UNTIL_RESTORED}`
|
||||
: PROCESS_BOUNDARY_GROUND
|
||||
)
|
||||
// The new process never subscribed to mode 2031; a reconnect catch-up would land in its input.
|
||||
session.clearPaneMode2031State()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Terminal } from '@xterm/headless'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
armWakeScrollback,
|
||||
beginWakeScrollbackRestore,
|
||||
@@ -15,9 +15,18 @@ vi.mock('@/i18n/i18n', () => ({
|
||||
fallback.replace(/\{\{(\w+)\}\}/g, (_slot: string, name: string) => params?.[name] ?? '')
|
||||
}))
|
||||
|
||||
afterEach(() => resetWakeScrollbackForTests())
|
||||
// A fixed clock (Date only; xterm's own timers stay real): the divider reads 2:02–2:31 PM.
|
||||
const NOW = new Date(2026, 10, 11, 14, 31).getTime()
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers({ toFake: ['Date'] })
|
||||
vi.setSystemTime(NOW)
|
||||
})
|
||||
afterEach(() => {
|
||||
resetWakeScrollbackForTests()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
const SLEPT_AT = Date.now() - 29 * 60_000
|
||||
const SLEPT_AT = NOW - 29 * 60_000
|
||||
const DIVIDER = /^── Slept .+–.+ · processes stopped ──$/
|
||||
|
||||
function write(terminal: Terminal, data: string): Promise<void> {
|
||||
@@ -151,12 +160,10 @@ describe('WAKE-SCROLLBACK', () => {
|
||||
ptyId: 'remote:env::term-old'
|
||||
})
|
||||
// A cold restore of the old terminal while still asleep: not taken.
|
||||
expect(
|
||||
beginWakeScrollbackRestore('leaf-1', terminal, Date.now(), 'remote:env::term-old')
|
||||
).toBeNull()
|
||||
expect(beginWakeScrollbackRestore('leaf-1', terminal, NOW, 'remote:env::term-old')).toBeNull()
|
||||
// The woken terminal's snapshot: taken, even though nothing armed it yet.
|
||||
expect(
|
||||
beginWakeScrollbackRestore('leaf-1', terminal, Date.now(), 'remote:env::term-new')?.block
|
||||
beginWakeScrollbackRestore('leaf-1', terminal, NOW, 'remote:env::term-new')?.block
|
||||
).toContain('README')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user