Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): r2-m3 preserve same-document app find readiness

Josué2a8e12fca470
diff --git a/desktop-app/src/__tests__/sandboxUiDriverLifecycle.test.ts b/desktop-app/src/__tests__/sandboxUiDriverLifecycle.test.ts
index 982ae8a1e..3944971c4 100644
--- a/desktop-app/src/__tests__/sandboxUiDriverLifecycle.test.ts
+++ b/desktop-app/src/__tests__/sandboxUiDriverLifecycle.test.ts
@@ -257,6 +257,33 @@ describe('mountSandboxUiView lifecycle cleanup', () => {
})
})
+ it('keeps the current document searchable after same-document navigation', async () => {
+ const parentWindow = new FakeParentWindow()
+ await mountSandboxUiView(mountArgs({ parentWindow }))
+ const webContents = electronMocks.views[0]!.webContents
+ const onResult = vi.fn()
+
+ webContents.emit('did-finish-load')
+ expect(findInActiveSandboxUi('invoice', 'start', 1, onResult).status).toBe('started')
+ webContents.emit('found-in-page', {} as Electron.Event, {
+ requestId: 41,
+ activeMatchOrdinal: 1,
+ matches: 2,
+ selectionArea: { x: 0, y: 0, width: 1, height: 1 },
+ finalUpdate: true,
+ })
+
+ webContents.emit(
+ 'did-start-navigation',
+ {} as Electron.Event,
+ 'https://rpc.example/app#next',
+ true,
+ true
+ )
+
+ expect(findInActiveSandboxUi('invoice', 'start', 2, onResult).status).toBe('started')
+ })
+
it('keeps only the newest view when cookie writes complete out of order', async () => {
const parentWindow = new FakeParentWindow()
let resolveFirstCookie!: () => void
diff --git a/desktop-app/src/sandboxUiDriver.ts b/desktop-app/src/sandboxUiDriver.ts
index a214c6f2a..2b49b4836 100644
--- a/desktop-app/src/sandboxUiDriver.ts
+++ b/desktop-app/src/sandboxUiDriver.ts
@@ -455,19 +455,19 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
documentReady: false,
}
- const invalidateFindForNavigation = (): void => {
+ const invalidateFindForNavigation = (requiresDocumentLoad: boolean): void => {
if (!active || active.view !== view) return
active.documentGeneration += 1
- active.documentReady = false
+ if (requiresDocumentLoad) active.documentReady = false
stopActiveSandboxUiFind()
}
const onDidStartNavigation = (
_event: Electron.Event,
_url: string,
- _isInPlace: boolean,
+ isInPlace: boolean,
isMainFrame: boolean
): void => {
- if (isMainFrame) invalidateFindForNavigation()
+ if (isMainFrame) invalidateFindForNavigation(!isInPlace)
}
const onDocumentReady = (): void => {
if (active?.view === view) active.documentReady = true