Skip to content

The agent that grows with you

test(desktop): exercise stalled preview locate deadline

unsupportedpastelsbd8ba03687fc
diff --git a/apps/desktop/electron/preview-guest-throttle.ts b/apps/desktop/electron/preview-guest-throttle.ts
index 01c21b354b6..3389d26ffd1 100644
--- a/apps/desktop/electron/preview-guest-throttle.ts
+++ b/apps/desktop/electron/preview-guest-throttle.ts
@@ -8,10 +8,11 @@ export interface PreviewGuestAttachPrefs {
/**
* `drive_preview` aims the pointer only after one animation frame inside the
- * guest. Chromium does not fire that frame while the guest is
- * background-throttled, so a click or keystroke never leaves once the Desktop
- * window is not in front. This guest is the page being driven, not a Hermes
- * chat renderer — those stay on the stream-throttle dial.
+ * guest. Background throttling can suspend that frame and stall input before
+ * dispatch. Keep preview guests unthrottled so background actions can proceed.
+ * Chat renderers retain their stream-throttle settings, but Electron draws
+ * frames for the entire containing window while any displayed guest disables
+ * throttling; an open preview therefore also has an idle rendering cost.
*/
export function applyPreviewGuestAttachPrefs(
webPreferences: PreviewGuestAttachPrefs,
diff --git a/apps/desktop/src/app/chat/right-rail/preview-act.test.ts b/apps/desktop/src/app/chat/right-rail/preview-act.test.ts
index 249223dd5d5..12a11772f3c 100644
--- a/apps/desktop/src/app/chat/right-rail/preview-act.test.ts
+++ b/apps/desktop/src/app/chat/right-rail/preview-act.test.ts
@@ -572,18 +572,25 @@ describe('actOnActivePreview (drive_preview tool)', () => {
expect(result.error).toContain('never reached the page')
})
- it('does not report a locate that never answers as a successful click', async () => {
+ it('fails without sending input when locating the target times out', async () => {
+ vi.useFakeTimers()
const send = vi.fn()
const tabId = openBrowserTab()
- cleanups.push(registerPreviewScriptRunner(tabId, async () => undefined))
+ cleanups.push(registerPreviewScriptRunner(tabId, () => new Promise(() => {})))
cleanups.push(registerPreviewInput(tabId, { focus: vi.fn(), send }))
- const result = await actOnActivePreview({ kind: 'click', ref: '@e1' })
+ try {
+ const pending = actOnActivePreview({ kind: 'click', ref: '@e1' })
+ await vi.advanceTimersByTimeAsync(8_000)
+ const result = await pending
- expect(send).not.toHaveBeenCalled()
- expect(result.success).toBe(false)
- expect(result.error).toContain('no input was sent')
+ expect(send).not.toHaveBeenCalled()
+ expect(result.success).toBe(false)
+ expect(result.error).toContain('no input was sent')
+ } finally {
+ vi.useRealTimers()
+ }
})
it('says so when the overlay itself swallowed the click', async () => {