Skip to content

Commit d15d96a

Browse files
committed
fix(desktop): dismiss credential picker when browser hides
1 parent ce4ee7d commit d15d96a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎apps/desktop/src/main/browser-agent/panel.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function freshPanel(): PanelModule {
3030
const PANEL_RECT = { x: 400, y: 64, width: 600, height: 800 }
3131

3232
/** A panel showing one tab. */
33-
function showPanel(panel: PanelModule) {
33+
function showPanel(panel: PanelModule, onGeometryChanged?: () => void) {
3434
const win = new BrowserWindow()
3535
const view = new WebContentsView()
3636
const active = { id: 'tab-1', scopeId: 'chat-test', view }
@@ -40,6 +40,7 @@ function showPanel(panel: PanelModule) {
4040
backgroundColor: () => '#0c0c0c',
4141
restoreActiveScope: () => {},
4242
onViewDetached: () => {},
43+
onGeometryChanged,
4344
})
4445
panel.activatePanelScope('chat-test')
4546
panel.setPanelBounds(PANEL_RECT, win)
@@ -278,6 +279,20 @@ describe('panel chat scope', () => {
278279
expect(view.webContents.invalidate).toHaveBeenCalledTimes(2)
279280
})
280281

282+
it('dismisses field-anchored UI when the browser resource is hidden', () => {
283+
const onGeometryChanged = vi.fn()
284+
const { win, view } = showPanel(panel, onGeometryChanged)
285+
onGeometryChanged.mockClear()
286+
287+
panel.setPanelBounds(null, win)
288+
289+
expect(view.setVisible).toHaveBeenLastCalledWith(false)
290+
expect(onGeometryChanged).toHaveBeenCalledOnce()
291+
expect(win.contentView.removeChildView).not.toHaveBeenCalled()
292+
panel.layout()
293+
expect(onGeometryChanged).toHaveBeenCalledOnce()
294+
})
295+
281296
it('reports the exact applied native rectangle in renderer viewport coordinates', async () => {
282297
const { win, view } = showPanel(panel)
283298
const scopeId = panel.getActivePanelScopeId()

‎apps/desktop/src/main/browser-agent/panel.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ function hideAttachedView(): void {
334334
error: getErrorMessage(error, 'unknown'),
335335
})
336336
}
337+
host.onGeometryChanged?.()
337338
}
338339

339340
/**

0 commit comments

Comments
 (0)