An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(extension): a click on a notice restores a minimized browser window before bringing its tab forward, since focus alone leaves it in the Dock or the taskbar
Shahriar96a9307298b0
diff --git a/src/lib/bridge/device-notices.test.ts b/src/lib/bridge/device-notices.test.tsindex ea1b427..dbc33f0 100644--- a/src/lib/bridge/device-notices.test.ts+++ b/src/lib/bridge/device-notices.test.ts@@ -20,9 +20,15 @@ const done: DeviceNotice = { id: 'monitor:build', kind: 'monitor', title: 'Done:type Window = { id: number; focused: boolean; state: string };-function windows(list: Window[]): void {+function windows(list: Window[], tabs: { id: number; windowId: number }[] = []): void {(fakeBrowser.windows as unknown as { getAll: () => Promise<Window[]> }).getAll = async () => list;+ (fakeBrowser.windows as unknown as { get: (id: number) => Promise<Window | undefined> }).get = async (id) => list.find((window) => window.id === id);(fakeBrowser.windows as unknown as { update: (id: number, change: object) => Promise<object> }).update = vi.fn(async () => ({}));+ (fakeBrowser.tabs as unknown as { get: (id: number) => Promise<object> }).get = async (id) => {+ const tab = tabs.find((candidate) => candidate.id === id);+ if (!tab) throw new Error('No tab');+ return tab;+ };}beforeEach(() => {@@ -58,16 +64,27 @@ describe('noticeOnDevice', () => {expect(await noticeOnDevice({ ...done, id: 'monitor:other' }, 8)).toBe(false);});- it('brings the notice’s own tab forward when it is clicked, or a window when it had none', async () => {- windows([{ id: 4, focused: false, state: 'minimized' }]);+ it('brings the notice’s own tab forward when it is clicked, restoring a minimized window first', async () => {+ windows([{ id: 4, focused: false, state: 'minimized' }, { id: 5, focused: false, state: 'minimized' }], [{ id: 7, windowId: 5 }]);serveDeviceNotices();socket.sendNotice.mockResolvedValue(true);await noticeOnDevice(done, 7);- await noticeOnDevice({ ...done, id: 'task:t1' });socket.opened!(done.id);await vi.waitFor(() => expect(toast.goToTab).toHaveBeenCalledWith(7));+ expect(fakeBrowser.windows.update).toHaveBeenNthCalledWith(1, 5, { state: 'normal' });+ expect(fakeBrowser.windows.update).toHaveBeenNthCalledWith(2, 5, { focused: true });+ });++ it('brings a window forward for a notice that had no tab', async () => {+ windows([{ id: 4, focused: false, state: 'normal' }]);+ serveDeviceNotices();+ socket.sendNotice.mockResolvedValue(true);+ await noticeOnDevice({ ...done, id: 'task:t1' });+socket.opened!('task:t1');await vi.waitFor(() => expect(fakeBrowser.windows.update).toHaveBeenCalledWith(4, { focused: true }));+ expect(fakeBrowser.windows.update).not.toHaveBeenCalledWith(4, { state: 'normal' });+ expect(toast.goToTab).not.toHaveBeenCalled();});});diff --git a/src/lib/bridge/device-notices.ts b/src/lib/bridge/device-notices.tsindex 9a91564..6c73a5d 100644--- a/src/lib/bridge/device-notices.ts+++ b/src/lib/bridge/device-notices.ts@@ -35,11 +35,20 @@ async function rememberTab(noticeId: string, tabId: number): Promise<void> {await browser.storage.session.set({ [NOTICE_TABS_KEY]: Object.fromEntries(kept) });}+/** Focus alone leaves a minimized window in the Dock or the taskbar, so it is restored first. */+async function restore(windowId: number): Promise<void> {+ const window = await browser.windows.get(windowId).catch(() => null);+ if (window?.state === 'minimized') await browser.windows.update(windowId, { state: 'normal' }).catch(() => undefined);+ await browser.windows.update(windowId, { focused: true }).catch(() => undefined);+}+async function bringForward(noticeId: string): Promise<void> {const tabId = (await noticeTabs())[noticeId];- if (tabId != null) return goToTab(tabId);- const [window] = await browser.windows.getAll({ windowTypes: ['normal'] }).catch(() => []);- if (window?.id != null) await browser.windows.update(window.id, { focused: true }).catch(() => undefined);+ const tab = tabId != null ? await browser.tabs.get(tabId).catch(() => null) : null;+ const [first] = await browser.windows.getAll({ windowTypes: ['normal'] }).catch(() => []);+ const windowId = tab?.windowId ?? first?.id;+ if (windowId != null) await restore(windowId);+ if (tab?.id != null) await goToTab(tab.id);}export function serveDeviceNotices(): void {