Skip to content

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.

fix(extension): a tab that never answers no longer stalls the run queue — the busy marker and the rail stop waiting after 1.5 s, so a run's reply, Stop and End get through

Shahriar46c9103560b8
diff --git a/src/lib/bridge/rail.ts b/src/lib/bridge/rail.ts
index 922ced4..34afc0c 100644
--- a/src/lib/bridge/rail.ts
+++ b/src/lib/bridge/rail.ts
@@ -11,6 +11,7 @@ import { listSkillMeta } from './skill-store';
import { PANEL_COLLAPSED_KEY, PANEL_TAB_KEY, readPanelCollapsed, readPanelTab } from './panel-view';
import { THEME_KEY, readTheme } from './theme';
import { openSidePanel } from './side-panel';
+import { tellTab } from './tab-message';
import { readTabSessions } from './tab-sessions';
import type { DaemonState } from './socket';
@@ -79,7 +80,7 @@ async function paintTab(tabId: number): Promise<void> {
function post(tabId: number | undefined, discarded: boolean | undefined, command: unknown) {
if (tabId == null || discarded) return undefined;
- return browser.tabs.sendMessage(tabId, command).catch(() => undefined);
+ return tellTab(tabId, command);
}
async function describeRail(): Promise<RailView> {
diff --git a/src/lib/bridge/run-indicator.test.ts b/src/lib/bridge/run-indicator.test.ts
new file mode 100644
index 0000000..1bf9ce9
--- /dev/null
+++ b/src/lib/bridge/run-indicator.test.ts
@@ -0,0 +1,45 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { fakeBrowser } from 'wxt/testing';
+import { syncRunIndicator } from './run-indicator';
+import { TAB_REPLY_MS } from './tab-message';
+import { mutateTabSessions } from './tab-sessions';
+
+beforeEach(() => {
+ fakeBrowser.reset();
+ vi.useFakeTimers();
+});
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ vi.useRealTimers();
+});
+
+describe('syncRunIndicator', () => {
+ it('settles while a tab never answers, so the run queue behind it keeps moving', async () => {
+ const tab = await fakeBrowser.tabs.create({ url: 'https://example.com/' });
+ const frozen = await fakeBrowser.tabs.create({ url: 'https://example.org/' });
+ vi.spyOn(fakeBrowser.tabs, 'sendMessage').mockReturnValue(new Promise(() => undefined));
+ await mutateTabSessions((map) => {
+ map.running = {
+ sessionId: 'running',
+ mainTabId: tab.id!,
+ tabIds: [tab.id!, frozen.id!],
+ currentTabId: tab.id!,
+ windowId: -1,
+ title: 'Example',
+ runId: 'run',
+ turns: 1,
+ createdAt: 0,
+ lastActivityAt: 0,
+ };
+ });
+
+ let settled = false;
+ void syncRunIndicator().then(() => {
+ settled = true;
+ });
+ await vi.advanceTimersByTimeAsync(10 * TAB_REPLY_MS);
+
+ expect(settled).toBe(true);
+ });
+});
diff --git a/src/lib/bridge/run-indicator.ts b/src/lib/bridge/run-indicator.ts
index 9ef378b..305ec0d 100644
--- a/src/lib/bridge/run-indicator.ts
+++ b/src/lib/bridge/run-indicator.ts
@@ -1,6 +1,7 @@
import { browser } from 'wxt/browser';
import { INDICATOR_CHANNEL, INDICATOR_COLOR } from '@/lib/indicator/events';
import { syncRail } from './rail';
+import { tellTab } from './tab-message';
import { readTabSessions } from './tab-sessions';
type BadgeAction = {
@@ -46,7 +47,5 @@ async function paint(tabId: number, busy: boolean): Promise<void> {
}
}
- await browser.tabs
- .sendMessage(tabId, { channel: INDICATOR_CHANNEL, op: busy ? 'busy' : 'idle' })
- .catch(() => undefined);
+ await tellTab(tabId, { channel: INDICATOR_CHANNEL, op: busy ? 'busy' : 'idle' });
}
diff --git a/src/lib/bridge/tab-message.ts b/src/lib/bridge/tab-message.ts
new file mode 100644
index 0000000..51486ac
--- /dev/null
+++ b/src/lib/bridge/tab-message.ts
@@ -0,0 +1,19 @@
+import { browser } from 'wxt/browser';
+
+export const TAB_REPLY_MS = 1_500;
+
+/**
+ * Sends a message whose reply nothing depends on. A tab Chrome has frozen, or one held by an
+ * `alert()`, never answers until the user wakes it, and the run queue must not wait that long.
+ */
+export function tellTab(tabId: number, message: unknown): Promise<void> {
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ const unanswered = new Promise<void>((resolve) => {
+ timer = setTimeout(resolve, TAB_REPLY_MS);
+ });
+ const answered = browser.tabs.sendMessage(tabId, message).then(
+ () => undefined,
+ () => undefined,
+ );
+ return Promise.race([answered, unanswered]).finally(() => clearTimeout(timer));
+}