Skip to content

The agent that grows with you

fix(desktop): a preview locate that never answers is not a click

xxxigm7c9069939186
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 b4a2292f49d..249223dd5d5 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,6 +572,20 @@ 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 () => {
+ const send = vi.fn()
+ const tabId = openBrowserTab()
+
+ cleanups.push(registerPreviewScriptRunner(tabId, async () => undefined))
+ cleanups.push(registerPreviewInput(tabId, { focus: vi.fn(), send }))
+
+ const result = await actOnActivePreview({ kind: 'click', ref: '@e1' })
+
+ expect(send).not.toHaveBeenCalled()
+ expect(result.success).toBe(false)
+ expect(result.error).toContain('no input was sent')
+ })
+
it('says so when the overlay itself swallowed the click', async () => {
const tabId = openBrowserTab()
diff --git a/apps/desktop/src/app/chat/right-rail/preview-act.ts b/apps/desktop/src/app/chat/right-rail/preview-act.ts
index c45e4219de9..7f05811e6d9 100644
--- a/apps/desktop/src/app/chat/right-rail/preview-act.ts
+++ b/apps/desktop/src/app/chat/right-rail/preview-act.ts
@@ -94,6 +94,11 @@ const NOTHING_OPEN = 'No live page is open in the in-app browser — open one wi
const NAVIGATED =
'The page stopped answering right after — it is probably navigating. Call elements to see where you landed.'
+/** Locate never returned, so the pointer was not sent. That is not a
+ * navigation: nothing this action did could have moved the page. */
+const UNANSWERED =
+ 'The page did not answer in time, so no input was sent. Call elements to see whether it is still the same page.'
+
/** A fingerprint of the overlay's source, so the guest page can tell that the
* code it is running has changed underneath it.
*
@@ -564,8 +569,11 @@ async function driveAction(
return { error: trip.error, success: false }
}
+ // Silence after the pointer has been sent can be a navigation tearing the
+ // document down. Silence here is earlier: locate never returned, so no
+ // input was sent.
if (trip.kind === 'silent') {
- return { acted: action.kind, note: NAVIGATED, success: true }
+ return { error: UNANSWERED, success: false }
}
const found = trip.result