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(apps): after adding the extension both apps keep the pairing code for a store copy that asks for one, in every mode; Windows reads the waiting browsers on every poll as the Mac does, so an expired one comes down, toasts a request only once across a Bridge that dropped away, offers Rename only to a Bridge that can rename, and shows no mode or pairing it does not know; Allow on a Mac notification needs the Mac unlocked
Shahriar6359bed7118e
diff --git a/src/mac/Sources/Browsentic/App/AppModel.swift b/src/mac/Sources/Browsentic/App/AppModel.swiftindex 6446d50..fe6be87 100644--- a/src/mac/Sources/Browsentic/App/AppModel.swift+++ b/src/mac/Sources/Browsentic/App/AppModel.swift@@ -587,7 +587,7 @@ final class AppModel: ObservableObject {private func afterAdding(_ row: BrowserRow) -> String {switch pairingMode {case .auto: "It connects by itself. If it asks for a code, use the one below."- case .ask: "Allow it here when it asks to connect."+ case .ask: "Allow it here when it asks to connect. If it asks for a code instead, use the one below."default: "Then click Browsentic in \(row.label)’s toolbar and enter the code below."}}diff --git a/src/mac/Sources/Browsentic/App/PairingAlerts.swift b/src/mac/Sources/Browsentic/App/PairingAlerts.swiftindex 843210c..5d2a433 100644--- a/src/mac/Sources/Browsentic/App/PairingAlerts.swift+++ b/src/mac/Sources/Browsentic/App/PairingAlerts.swift@@ -35,7 +35,7 @@ final class PairingAlerts: NSObject, UNUserNotificationCenterDelegate {UNNotificationCategory(identifier: Category.request,actions: [- UNNotificationAction(identifier: Action.allow, title: "Allow"),+ UNNotificationAction(identifier: Action.allow, title: "Allow", options: .authenticationRequired),UNNotificationAction(identifier: Action.deny, title: "Deny", options: .destructive),],intentIdentifiers: []diff --git a/src/windows/src-tauri/src/pairing.rs b/src/windows/src-tauri/src/pairing.rsindex a703782..8eb16f7 100644--- a/src/windows/src-tauri/src/pairing.rs+++ b/src/windows/src-tauri/src/pairing.rs@@ -1,5 +1,5 @@use serde::{Deserialize, Serialize};-use std::collections::HashMap;+use std::collections::{HashMap, VecDeque};use std::sync::Mutex;use url::Url;@@ -98,11 +98,14 @@ pub struct Change {/// Links that arrive before the pending list are kept for it, but only a few: any web page can send them.const MOST_WAITING: usize = 8;+/// Requests already announced, so one that is listed again after the Bridge dropped away is not.+const MOST_ANNOUNCED: usize = 50;#[derive(Default)]pub struct Pairing {held: Mutex<Held>,waiting: Mutex<Vec<Link>>,+ announced: Mutex<VecDeque<String>>,}impl Pairing {@@ -110,7 +113,11 @@ impl Pairing {let mut held = self.held.lock().unwrap();let before = held.requests.take().unwrap_or_default();let now: HashMap<String, String> = requests.iter().map(|request| (request.id.clone(), request.nonce.clone())).collect();- let added = requests.iter().filter(|request| !before.contains_key(&request.id)).cloned().collect();+ let mut announced = self.announced.lock().unwrap();+ let added: Vec<Request> = requests.iter().filter(|request| !before.contains_key(&request.id) && !announced.contains(&request.id)).cloned().collect();+ announced.extend(added.iter().map(|request| request.id.clone()));+ let excess = announced.len().saturating_sub(MOST_ANNOUNCED);+ announced.drain(..excess);let removed = before.keys().filter(|id| !now.contains_key(*id)).cloned().collect();held.requests = Some(now);let released = self.waiting.lock().unwrap().drain(..).filter_map(|link| held.act(&link)).collect();@@ -291,6 +298,16 @@ mod tests {assert_eq!(pairing.list(&[request("r2", "secret-two")]), Change { added: vec![], removed: vec!["r1".into()], released: vec![] });}+ #[test]+ fn a_request_listed_again_after_the_bridge_dropped_away_is_not_announced_twice() {+ let pairing = Pairing::default();+ assert_eq!(pairing.list(&[request("r1", "secret-one")]).added, [request("r1", "secret-one")]);+ assert_eq!(pairing.list(&[]).removed, ["r1".to_string()]);+ let again = pairing.list(&[request("r1", "secret-one"), request("r2", "secret-two")]);+ assert_eq!(again.added, [request("r2", "secret-two")]);+ assert_eq!(pairing.judge(parse("browsentic://pair/allow?r=r1&n=secret-one").unwrap()), Some(Act::Decide { request: "r1".into(), allow: true }));+ }+#[test]fn a_flood_of_links_before_the_list_keeps_only_a_few() {let pairing = Pairing::default();diff --git a/src/windows/ui/model.test.ts b/src/windows/ui/model.test.tsindex d31e93f..ca94bc1 100644--- a/src/windows/ui/model.test.ts+++ b/src/windows/ui/model.test.ts@@ -134,13 +134,13 @@ describe('the running app', () => {]);});- it('adds the extension to a browser by opening its store page, and says it connects by itself', async () => {+ it('adds the extension to a browser by opening its store page, says it connects by itself, and keeps a code for a copy that asks', async () => {const model = await running();await until(model, (state) => state.browserRows.length > 0);await model.addExtension(model.offeredBrowsers.find((row) => row.id === 'edge')!);- expect([model.snapshot().pairing, model.snapshot().notice?.text]).toEqual([- undefined,- 'Press “Allow extensions from other stores” if Edge shows it at the top of the page, confirm, and press “Add to Chrome”. It connects to Browsentic Bridge by itself.',+ expect([model.snapshot().pairing?.code, model.snapshot().notice?.text]).toEqual([+ 'R4TW7KXE',+ 'Press “Allow extensions from other stores” if Edge shows it at the top of the page, confirm, and press “Add to Chrome”. It connects by itself. If it asks for a code, use the one below.',]);});diff --git a/src/windows/ui/model.ts b/src/windows/ui/model.tsindex fe23fc4..564ba2d 100644--- a/src/windows/ui/model.ts+++ b/src/windows/ui/model.ts@@ -115,6 +115,13 @@ export interface State {}const MINIMUM_NODE = 20;++/** What to do once the store has added the extension; the code is there for a copy that asks for one. */+const AFTER_ADDING: Record<PairingMode, (browser: string) => string> = {+ auto: () => 'It connects by itself. If it asks for a code, use the one below.',+ ask: () => 'Allow it here when it asks to connect. If it asks for a code instead, use the one below.',+ code: (browser) => `Then click Browsentic in ${browser}’s toolbar and enter the code below.`,+};const FINISH_UPDATE = 'browsentic/finishUpdateOnLaunch';const APPEARANCE = 'browsentic/appearance';const START_ON_LAUNCH = 'browsentic/startDaemonOnLaunch';@@ -477,11 +484,12 @@ export class Model {status,sessions,stamp,- pairingMode: status.pairing?.mode,+ pairingMode: isPairingMode(status.pairing?.mode) ? status.pairing.mode : undefined,daemon: state.daemon === 'stopping' ? 'stopping' : 'on',pairing: state.pairing && status.pairingPending && state.pairing.expiresAt > Date.now() ? state.pairing : undefined,}));this.announceArrivals(sessions);+ if (status.pairing) void this.loadPairRequests();if (!this.state.agents) await this.loadAgents();if (changed) void this.loadBrowsers();} catch {@@ -793,10 +801,8 @@ export class Model {return this.perform(`add:${row.id}`, async () => {const result = parseJson<SetupResult>(await this.backend.cli(['setup', '--browser', row.id, '--no-wait', '--no-self-update', '--json'], 120), 'setup');if (!result.chosen?.opened) await this.backend.openUrl(row.storeUrl);- if (this.state.pairingMode === 'auto') return this.say(`${row.steps[0]} It connects to Browsentic Bridge by itself.`);- if (this.state.pairingMode === 'ask') return this.say(`${row.steps[0]} Then allow it here when it asks to connect.`);if (result.pairingCode && result.expiresAt) this.set({ pairing: { code: result.pairingCode, expiresAt: result.expiresAt } });- this.say(`${row.steps[0]} Then click Browsentic in ${row.label}’s toolbar and enter the code below.`);+ this.say(`${row.steps[0]} ${AFTER_ADDING[this.state.pairingMode ?? 'code'](row.label)}`);});}diff --git a/src/windows/ui/views/browsers.tsx b/src/windows/ui/views/browsers.tsxindex 1057693..48210dd 100644--- a/src/windows/ui/views/browsers.tsx+++ b/src/windows/ui/views/browsers.tsx@@ -52,7 +52,7 @@ export function BrowsersView({ model, state }: { model: Model; state: State }) {key={session.id}session={session}busy={state.busy.includes('revoke') || state.busy.includes(`label:${session.id}`)}- onRename={() => setAsking({ kind: 'rename', session })}+ onRename={state.status?.pairing ? () => setAsking({ kind: 'rename', session }) : undefined}onUnpair={() => setAsking({ kind: 'unpair', session })}/>))@@ -89,9 +89,9 @@ export function BrowsersView({ model, state }: { model: Model; state: State }) {);}-function SessionRow({ session, busy, onRename, onUnpair }: { session: SessionSummary; busy: boolean; onRename: () => void; onUnpair: () => void }) {+function SessionRow({ session, busy, onRename, onUnpair }: { session: SessionSummary; busy: boolean; onRename?: () => void; onUnpair: () => void }) {const name = session.label ?? session.browser;- const paired = `${PAIRED_BY[session.pairedBy ?? 'code']} ${ago(session.pairedAt)}`;+ const paired = `${PAIRED_BY[session.pairedBy ?? 'code'] ?? 'Paired'} ${ago(session.pairedAt)}`;return (<div className="flex items-center gap-3 rounded-xl bg-ground-2 p-3"><GlowDot tint={session.connected ? 'lime' : 'faint'} pulsing={session.connected} />@@ -106,9 +106,11 @@ function SessionRow({ session, busy, onRename, onUnpair }: { session: SessionSum</p></div><Pill text={session.connected ? 'Connected' : 'Away'} tint={session.connected ? 'lime' : 'dim'} />- <QuietButton icon={PencilLine} disabled={busy} onClick={onRename}>- Rename- </QuietButton>+ {onRename && (+ <QuietButton icon={PencilLine} disabled={busy} onClick={onRename}>+ Rename+ </QuietButton>+ )}<QuietButton tint="danger" disabled={busy} onClick={onUnpair}>Unpair</QuietButton>