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.

refactor(extension): the menu paints from its description in one pass, toggling the panel reads as one choice, the shortcuts hook starts undefined like its reader expects, and the comments keep only the browser's constraints

Shahriard9c1a6d70517
diff --git a/src/extension/components/extension-settings.tsx b/src/extension/components/extension-settings.tsx
index 1fb07f1..cca66bb 100644
--- a/src/extension/components/extension-settings.tsx
+++ b/src/extension/components/extension-settings.tsx
@@ -8,7 +8,6 @@ import { openShortcutSettings, useContextMenuChoice, usePushToTalk, useShortcuts
import { useHandsFreeSupported } from '@/lib/bridge/use-speech';
import { cn } from '@/lib/utils';
-/** What belongs to this browser alone: where Browsentic shows up in it, and how it is reached from the keyboard. */
export function ExtensionSettings() {
const handsFree = useHandsFreeSupported();
return (
diff --git a/src/lib/bridge/context-menu.ts b/src/lib/bridge/context-menu.ts
index 665ff9b..f66fe6d 100644
--- a/src/lib/bridge/context-menu.ts
+++ b/src/lib/bridge/context-menu.ts
@@ -4,7 +4,6 @@ export const CONTEXT_MENU_KEY = 'browsentic/contextMenu';
export const PANEL_ITEM = 'open-side-panel';
export const HANDS_FREE_ITEM = 'open-hands-free';
-/** Which right-click items this browser shows. Both are on until switched off. */
export interface ContextMenuChoice {
panel: boolean;
handsFree: boolean;
@@ -21,7 +20,6 @@ export async function readContextMenuChoice(): Promise<ContextMenuChoice> {
export interface MenuState {
choice: ContextMenuChoice;
- /** Whether hands-free can exist in this browser at all. */
speech: boolean;
panelOpen: boolean;
handsFree: boolean;
@@ -32,7 +30,6 @@ export interface MenuItem {
title: string;
}
-/** Each item reads as what a click will do now: the one showing its surface offers to close it. */
export function describeMenu({ choice, speech, panelOpen, handsFree }: MenuState): MenuItem[] {
const panel = { id: PANEL_ITEM, title: panelOpen ? 'Close Browsentic' : 'Open Browsentic' };
const mic = { id: HANDS_FREE_ITEM, title: handsFree ? 'Close Browsentic (Hands Free)' : 'Open Browsentic (Hands Free)' };
diff --git a/src/lib/bridge/launchers.ts b/src/lib/bridge/launchers.ts
index f5e7d98..780b91f 100644
--- a/src/lib/bridge/launchers.ts
+++ b/src/lib/bridge/launchers.ts
@@ -19,28 +19,23 @@ function repaintMenu(): void {
async function paintMenu(): Promise<void> {
const [choice, speech, handsFree] = await Promise.all([readContextMenuChoice(), handsFreeSupported(), readHandsFree()]);
await browser.contextMenus.removeAll();
- for (const item of describeMenu({ choice, speech, panelOpen, handsFree: handsFree !== null })) {
- browser.contextMenus.create({ ...item, contexts: ['all'] });
- }
+ describeMenu({ choice, speech, panelOpen, handsFree: handsFree !== null }).forEach((item) =>
+ browser.contextMenus.create({ ...item, contexts: ['all'] }),
+ );
}
/** Called with a user gesture that the first await would spend, so the panel opens before anything is awaited. */
function togglePanel(windowId: number): void {
- if (!panelOpen) {
- void openSidePanel(windowId);
- return;
- }
- if (import.meta.env.FIREFOX) void closeSidebar();
+ if (!panelOpen) void openSidePanel(windowId);
+ else if (import.meta.env.FIREFOX) void closeSidebar();
else closePanels();
}
-/** Starting it closes every panel, and the orb takes the microphone once the background paints it. */
async function toggleHandsFree(): Promise<void> {
if (await readHandsFree()) return endHandsFree();
if (await handsFreeSupported()) await startHandsFree();
}
-/** The ways into Browsentic from outside its own pages: the right-click menu and the keyboard shortcuts. */
export function serveLaunchers(): void {
onPanelPresence((open) => {
panelOpen = open;
diff --git a/src/lib/bridge/panel-view.ts b/src/lib/bridge/panel-view.ts
index 96a531f..61e0a2f 100644
--- a/src/lib/bridge/panel-view.ts
+++ b/src/lib/bridge/panel-view.ts
@@ -33,10 +33,9 @@ export function writeHandsFree(state: HandsFreeState | null): Promise<void> {
: browser.storage.session.remove(HANDS_FREE_KEY);
}
-/** Hold to talk: the orb listens only while left Control is held. Kept across restarts, unlike hands-free itself. */
export const PUSH_TO_TALK_KEY = 'browsentic/pushToTalk';
-export const startHandsFree =(): Promise<void> => writeHandsFree({ muted: false, since: Date.now() });
+export const startHandsFree = (): Promise<void> => writeHandsFree({ muted: false, since: Date.now() });
export const endHandsFree = (): Promise<void> => writeHandsFree(null);
diff --git a/src/lib/bridge/use-extension-settings.ts b/src/lib/bridge/use-extension-settings.ts
index d7da87c..f0f70bf 100644
--- a/src/lib/bridge/use-extension-settings.ts
+++ b/src/lib/bridge/use-extension-settings.ts
@@ -41,9 +41,8 @@ export const useContextMenuChoice = (): [ContextMenuChoice, (next: ContextMenuCh
export const usePushToTalk = (): [boolean, (on: boolean) => void] => useLocalSetting(PUSH_TO_TALK_KEY, isOn);
-/** Read again whenever this page comes back into view, since the keys are changed on the browser's own page. */
-export function useShortcuts(): Shortcut[] | null {
- const [shortcuts, setShortcuts] = useState<Shortcut[] | null>(null);
+export function useShortcuts(): Shortcut[] | undefined {
+ const [shortcuts, setShortcuts] = useState<Shortcut[]>();
useEffect(() => {
let live = true;
diff --git a/src/lib/settings/shortcuts.ts b/src/lib/settings/shortcuts.ts
index 4a42ffa..70106ce 100644
--- a/src/lib/settings/shortcuts.ts
+++ b/src/lib/settings/shortcuts.ts
@@ -1,9 +1,3 @@
-/**
- * The keyboard shortcuts the manifest declares. The browser keeps the keys, not Browsentic:
- * it assigns the suggested ones on install unless something else holds them, and the user
- * changes them on the browser's own shortcuts page.
- */
-
export const PANEL_SHORTCUT = 'toggle-side-panel';
export const HANDS_FREE_SHORTCUT = 'toggle-hands-free';
@@ -16,7 +10,6 @@ interface ManifestCommand {
suggested_key?: { default: string };
}
-/** Firefox has its own names for the popup and the sidebar, and no hands-free to start. */
export function manifestCommands(firefox: boolean): Record<string, ManifestCommand> {
if (firefox) {
return {
@@ -47,7 +40,6 @@ export interface Shortcut {
keys: string[];
}
-/** The browser's own list, in the order the settings page shows it, each named the same way everywhere. */
export function shortcutsOf(commands: readonly { name?: string; description?: string; shortcut?: string }[]): Shortcut[] {
return commands
.flatMap(({ name, description, shortcut }) =>
@@ -69,6 +61,5 @@ export function keysOf(shortcut: string): string[] {
return [...modifiers, ...(key ? [key] : [])];
}
-/** Edge answers to its own scheme; every other Chromium browser takes chrome://. */
export const shortcutsPageFor = (brand: string | undefined): string =>
brand === 'Microsoft Edge' ? 'edge://extensions/shortcuts' : 'chrome://extensions/shortcuts';