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(android): on Windows the adb server the Bridge starts no longer holds open the folder the Bridge started in, adb is found where winget, Scoop and Chocolatey put it and where a platform-tools zip unpacks in Downloads, and a named adb is shown with forward slashes, which JSON reads; on the phone tab AltGr and Option type their characters, and only the main mouse button taps

Shahriar1ec81be7f494
diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md
index a33083a..0b43df1 100644
--- a/docs/guide/configuration.md
+++ b/docs/guide/configuration.md
@@ -107,7 +107,7 @@ settings page shows but will not change.
| Key | Default | Notes |
| --- | --- | --- |
| `android.enabled` | `true` | `false` stops the Bridge using adb at all: it never looks for phones, and the side panel shows no Android switch. See [Android phone](features/android.md) |
-| `android.adb` | found | Absolute path to the adb to use. Without it the Bridge looks on `PATH`, under `ANDROID_HOME` and `ANDROID_SDK_ROOT`, in Android Studio's SDK, where Homebrew puts it, and on Windows where winget unpacks it. Name one when you have several, since two adb versions stop each other's server |
+| `android.adb` | found | Absolute path to the adb to use. Without it the Bridge looks on `PATH`, under `ANDROID_HOME` and `ANDROID_SDK_ROOT`, in Android Studio's SDK, where Homebrew puts it, and on Windows where winget, Scoop and Chocolatey put it and in `Downloads`. Name one when you have several, since two adb versions stop each other's server. On Windows write the path with forward slashes, `"C:/platform-tools/adb.exe"`: a single backslash is not valid JSON, and the Bridge then ignores the whole file |
## Site mapping
diff --git a/docs/guide/features/android.md b/docs/guide/features/android.md
index 7c1e614..3e0646c 100644
--- a/docs/guide/features/android.md
+++ b/docs/guide/features/android.md
@@ -14,7 +14,8 @@ swipes on the phone instead of mouse clicks. Nothing is installed on the phone.
- **adb**, Android's debugging tool, from Google's
[platform-tools](https://developer.android.com/tools/releases/platform-tools). The Bridge looks
for it on your `PATH`, under `ANDROID_HOME` or `ANDROID_SDK_ROOT`, in Android Studio's SDK, where
- Homebrew puts it, and on Windows where winget unpacks it. If it is somewhere else, name it in
+ Homebrew puts it, and on Windows where winget, Scoop and Chocolatey put it and in your Downloads
+ folder, where Windows unzips the platform-tools download. If it is somewhere else, name it in
[`config.json`](../configuration.md#android).
- An Android phone with Google Chrome, connected by USB, or over Wi-Fi once it has been paired with
adb.
diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md
index a51b03f..de7cccb 100644
--- a/docs/guide/troubleshooting.md
+++ b/docs/guide/troubleshooting.md
@@ -114,7 +114,7 @@ names the one that fails. See [Android phone](features/android.md) for setting a
| --- | --- | --- |
| No Android switch in the side panel | The Bridge sees no phone, the Bridge predates Android, or the browser is Firefox | Run `browsentic android`. Update the Bridge if it does not know the command. Firefox has no Android switch |
| `ANDROID_OFF` | `"android": { "enabled": false }` is set in `config.json` | Set it to `true`, or remove it |
-| `ADB_MISSING` | adb, from Android's platform-tools, is not installed, or not where the Bridge looks | Install platform-tools (the check prints the command for your system), or name your adb with `"android": { "adb": "/path/to/adb" }` |
+| `ADB_MISSING` | adb, from Android's platform-tools, is not installed, or not where the Bridge looks | Install platform-tools (the check prints the command for your system), or name your adb with `"android": { "adb": "/path/to/adb" }`. On Windows, unzip the download in `Downloads`, or name it with forward slashes: `"C:/path/to/adb.exe"` |
| `ADB_BROKEN` | The adb the Bridge found does not run | Reinstall platform-tools, or name a working adb in `config.json` |
| `NO_DEVICE` | No phone is connected, USB debugging is off, or the cable only charges | Turn on USB debugging and connect with a data cable. On Windows, see the next row |
| adb sees nothing on Windows | Many phones need their maker's USB driver, or Google's, before Windows lets adb see them | Install the driver from Android's [OEM USB drivers](https://developer.android.com/studio/run/oem-usb) page, then plug the phone in again |
diff --git a/src/daemon/android/adb.test.ts b/src/daemon/android/adb.test.ts
index 7dd27ff..1dfe0bc 100644
--- a/src/daemon/android/adb.test.ts
+++ b/src/daemon/android/adb.test.ts
@@ -1,4 +1,4 @@
-import { mkdtempSync, readFileSync } from 'node:fs';
+import { mkdtempSync, readFileSync, realpathSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { describe, expect, test } from 'vitest';
@@ -28,18 +28,23 @@ describe('where adb is looked for', () => {
]);
});
- test('Windows: adb.exe on PATH however the variable is spelled, the SDK under LOCALAPPDATA, then where winget unpacks it', () => {
+ test('Windows: adb.exe on PATH however the variable is spelled, the SDK under LOCALAPPDATA, winget, Scoop, Chocolatey, then a zip unpacked in Downloads', () => {
expect(
adbCandidates({
platform: 'win32',
home: 'C:\\Users\\me',
- env: { Path: '"C:\\Tools";C:\\Windows', LOCALAPPDATA: 'C:\\Users\\me\\AppData\\Local' },
+ env: { Path: '"C:\\Tools";C:\\Windows', LOCALAPPDATA: 'C:\\Users\\me\\AppData\\Local', ProgramFiles: 'D:\\Programs' },
}),
).toEqual([
'C:\\Tools\\adb.exe',
'C:\\Windows\\adb.exe',
'C:\\Users\\me\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe',
'C:\\Users\\me\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Google.PlatformTools_Microsoft.Winget.Source_8wekyb3d8bbwe\\platform-tools\\adb.exe',
+ 'D:\\Programs\\WinGet\\Packages\\Google.PlatformTools_Microsoft.Winget.Source_8wekyb3d8bbwe\\platform-tools\\adb.exe',
+ 'C:\\Users\\me\\scoop\\shims\\adb.exe',
+ 'C:\\ProgramData\\chocolatey\\bin\\adb.exe',
+ 'C:\\Users\\me\\Downloads\\platform-tools\\adb.exe',
+ 'C:\\Users\\me\\Downloads\\platform-tools-latest-windows\\platform-tools\\adb.exe',
]);
});
@@ -85,6 +90,13 @@ describe('finding adb', () => {
expect(isProgram(fake('adb-runs', ''))).toBe(true);
});
+ // stubCli is a .cmd on Windows, which spawn refuses without a shell; a real adb is an .exe.
+ test.skipIf(process.platform === 'win32')('start-server runs in adb\'s own folder, which the server it forks keeps as its working folder', async () => {
+ const where = join(dir, 'start-server-cwd.txt');
+ expect(await startServer(fake('adb-where', `require('node:fs').writeFileSync(${JSON.stringify(where)}, process.cwd());`))).toBe(true);
+ expect(readFileSync(where, 'utf8')).toBe(realpathSync(dir));
+ });
+
test.skipIf(process.platform === 'win32')('start-server is judged by its exit, not by output a forked server could hold open', async () => {
const forks = fake('adb-forks', `require('node:child_process').spawn(process.execPath, ['-e', 'setTimeout(() => {}, 20000)'], { stdio: 'inherit', detached: true }).unref();`);
const started = Date.now();
diff --git a/src/daemon/android/adb.ts b/src/daemon/android/adb.ts
index 0a3bdff..dd10272 100644
--- a/src/daemon/android/adb.ts
+++ b/src/daemon/android/adb.ts
@@ -1,7 +1,7 @@
import { spawn } from 'node:child_process';
import { accessSync, constants, statSync } from 'node:fs';
import { homedir } from 'node:os';
-import { posix, win32 } from 'node:path';
+import { dirname, posix, win32 } from 'node:path';
import { spawnCli, stopTree, variable } from '../agent/runners/command';
const VERSION_TIMEOUT_MS = 5_000;
@@ -23,12 +23,16 @@ export interface Where {
home?: string;
}
-/** Where adb is looked for, first match first: the user's own setting, PATH, the SDK variables, then where installers put it. */
+/**
+ * Where adb is looked for, first match first: the user's own setting, PATH, the SDK variables, then where installers put it.
+ * A Bridge keeps the PATH it started with, so on Windows that means winget, Scoop, Chocolatey and a platform-tools zip unpacked in Downloads.
+ */
export function adbCandidates({ configured, env = process.env, platform = process.platform, home = homedir() }: Where = {}): string[] {
const windows = platform === 'win32';
const path = windows ? win32 : posix;
const exe = windows ? 'adb.exe' : 'adb';
const localAppData = variable(env, 'LOCALAPPDATA') ?? path.join(home, 'AppData', 'Local');
+ const downloads = path.join(home, 'Downloads');
const sdkRoots = [
variable(env, 'ANDROID_HOME'),
variable(env, 'ANDROID_SDK_ROOT'),
@@ -44,7 +48,16 @@ export function adbCandidates({ configured, env = process.env, platform = proces
.filter(Boolean)
.map((dir) => path.join(dir, exe)),
...sdkRoots.filter((root): root is string => !!root).map((root) => path.join(root, 'platform-tools', exe)),
- ...(windows ? [path.join(localAppData, 'Microsoft', 'WinGet', 'Packages', WINGET_PLATFORM_TOOLS, 'platform-tools', exe)] : ['/opt/homebrew/bin/adb', '/usr/local/bin/adb']),
+ ...(windows
+ ? [
+ path.join(localAppData, 'Microsoft', 'WinGet', 'Packages', WINGET_PLATFORM_TOOLS, 'platform-tools', exe),
+ path.join(variable(env, 'PROGRAMFILES') ?? 'C:\\Program Files', 'WinGet', 'Packages', WINGET_PLATFORM_TOOLS, 'platform-tools', exe),
+ path.join(variable(env, 'SCOOP') ?? path.join(home, 'scoop'), 'shims', exe),
+ path.join(variable(env, 'CHOCOLATEYINSTALL') ?? 'C:\\ProgramData\\chocolatey', 'bin', exe),
+ path.join(downloads, 'platform-tools', exe),
+ path.join(downloads, 'platform-tools-latest-windows', 'platform-tools', exe),
+ ]
+ : ['/opt/homebrew/bin/adb', '/usr/local/bin/adb']),
];
return [...new Set(candidates.filter((candidate): candidate is string => !!candidate))];
}
@@ -74,11 +87,12 @@ export function versionOf(output: string): string | undefined {
/**
* Started only when no server answers: `adb start-server` against a running server of another
* version would kill it. Its output is not read, because the server it forks keeps any pipe it
- * inherits open for as long as it runs.
+ * inherits open for as long as it runs. It starts in adb's own folder because the server keeps its
+ * working folder too, and on Windows a folder in use cannot be deleted, renamed or updated.
*/
export function startServer(path: string): Promise<boolean> {
return new Promise((resolve) => {
- const child = spawn(path, ['start-server'], { stdio: 'ignore', windowsHide: true });
+ const child = spawn(path, ['start-server'], { cwd: dirname(path), stdio: 'ignore', windowsHide: true });
const timer = setTimeout(() => {
stopTree(child, 'SIGKILL');
resolve(false);
diff --git a/src/daemon/android/readiness.test.ts b/src/daemon/android/readiness.test.ts
index 69228e9..a095a72 100644
--- a/src/daemon/android/readiness.test.ts
+++ b/src/daemon/android/readiness.test.ts
@@ -45,9 +45,10 @@ describe('readiness', () => {
const rows: [string, Observed, AndroidProblemCode, Partial<{ ready: boolean; says: RegExp; fix: string; action: string }>?][] = [
['switched off in config.json', observed([], { enabled: false, adb: undefined }), 'ANDROID_OFF', { says: /config\.json/, fix: '"android": { "enabled": true }' }],
['no adb on macOS', observed([], { adb: null }), 'ADB_MISSING', { fix: 'brew install --cask android-platform-tools' }],
- ['no adb on Windows', observed([], { adb: null, platform: 'win32' }), 'ADB_MISSING', { fix: 'winget install Google.PlatformTools' }],
+ ['no adb on Windows', observed([], { adb: null, platform: 'win32' }), 'ADB_MISSING', { says: /unzip it in your Downloads folder/, fix: 'winget install Google.PlatformTools' }],
['no adb on Linux', observed([], { adb: null, platform: 'linux' }), 'ADB_MISSING', { fix: 'sudo apt install adb' }],
['an adb that does not run', observed([], { adb: { path: ADB.path, broken: 'Bad CPU type in executable' } }), 'ADB_BROKEN', { says: /Bad CPU type in executable\. Reinstall/ }],
+ ['an adb that does not run on Windows, named with forward slashes, which JSON takes unescaped', observed([], { adb: { path: 'C:\\adb.exe', broken: 'boom' }, platform: 'win32' }), 'ADB_BROKEN', { says: /forward slashes/, fix: '"android": { "adb": "C:/path/to/adb.exe" }' }],
['adb\'s server that will not start', observed([], { serverError: 'start-server did not start adb\'s server' }), 'ADB_BROKEN'],
['adb with no phone', observed([]), 'NO_DEVICE', { says: /USB debugging/ }],
['a phone waiting for Allow', observed([phone({ state: 'unauthorized', adbState: 'unauthorized' })]), 'DEVICE_UNAUTHORIZED', { says: /tap Allow/ }],
diff --git a/src/daemon/android/readiness.ts b/src/daemon/android/readiness.ts
index 596c539..88f2f39 100644
--- a/src/daemon/android/readiness.ts
+++ b/src/daemon/android/readiness.ts
@@ -30,14 +30,24 @@ export const PROBLEMS = {
}),
adbMissing: (platform: NodeJS.Platform): AndroidProblem => ({
code: 'ADB_MISSING',
- message: `Browsentic reaches your phone through adb, from Android's platform-tools, and it is not installed. Install it with the command below or download it from ${PLATFORM_TOOLS_URL}.`,
+ message:
+ platform === 'win32'
+ ? `Browsentic reaches your phone through adb, from Android's platform-tools, and it is not installed. Install it with the command below, or download it from ${PLATFORM_TOOLS_URL} and unzip it in your Downloads folder.`
+ : `Browsentic reaches your phone through adb, from Android's platform-tools, and it is not installed. Install it with the command below or download it from ${PLATFORM_TOOLS_URL}.`,
fix: INSTALL_ADB[platform] ?? PLATFORM_TOOLS_URL,
}),
- adbBroken: (path: string, why: string): AndroidProblem => ({
- code: 'ADB_BROKEN',
- message: `adb at ${path} does not run: ${why}. Reinstall platform-tools, or name a working adb in ~/.browsentic/config.json.`,
- fix: '"android": { "adb": "/path/to/adb" }',
- }),
+ adbBroken: (path: string, why: string, platform: NodeJS.Platform): AndroidProblem =>
+ platform === 'win32'
+ ? {
+ code: 'ADB_BROKEN',
+ message: `adb at ${path} does not run: ${why}. Reinstall platform-tools, or name a working adb in ~/.browsentic/config.json, with forward slashes in its path.`,
+ fix: '"android": { "adb": "C:/path/to/adb.exe" }',
+ }
+ : {
+ code: 'ADB_BROKEN',
+ message: `adb at ${path} does not run: ${why}. Reinstall platform-tools, or name a working adb in ~/.browsentic/config.json.`,
+ fix: '"android": { "adb": "/path/to/adb" }',
+ },
noDevice: (platform: NodeJS.Platform): AndroidProblem => ({
code: 'NO_DEVICE',
message:
@@ -99,8 +109,8 @@ export function judge(observed: Observed): AndroidState {
if (!enabled) return stopped(PROBLEMS.off());
if (!adb) return stopped(PROBLEMS.adbMissing(platform), true);
- if (adb.broken) return stopped(PROBLEMS.adbBroken(adb.path, adb.broken), true);
- if (serverError) return stopped(PROBLEMS.adbBroken(adb.path, serverError), true);
+ if (adb.broken) return stopped(PROBLEMS.adbBroken(adb.path, adb.broken, platform), true);
+ if (serverError) return stopped(PROBLEMS.adbBroken(adb.path, serverError, platform), true);
const devices = observed.devices.map(({ device, facts }) => describe(device, facts));
const ready = devices.find(isDrivable);
diff --git a/src/extension/entrypoints/phone/use-mirror.ts b/src/extension/entrypoints/phone/use-mirror.ts
index 20d797c..5a6f26f 100644
--- a/src/extension/entrypoints/phone/use-mirror.ts
+++ b/src/extension/entrypoints/phone/use-mirror.ts
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { browser, type Browser } from 'wxt/browser';
import type { LensCommand } from '@/lib/actions/page/lens';
-import { PHONE_PORT, isMirrorKey, touchPoint, type FrameMetadata, type MirrorCommand, type MirrorMessage, type PageState } from '@/lib/phone/mirror';
+import { PHONE_PORT, isMirrorKey, touchPoint, typedText, type FrameMetadata, type MirrorCommand, type MirrorMessage, type PageState } from '@/lib/phone/mirror';
const RECONNECT_MS = 500;
const ERROR_SHOWN_MS = 5_000;
@@ -18,6 +18,8 @@ export interface Mirror {
send(command: MirrorCommand): void;
}
+const MAC = /mac/i.test((navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData?.platform ?? navigator.platform ?? '');
+
const decode = (data: string) => new Blob([Uint8Array.from(atob(data), (char) => char.charCodeAt(0))], { type: 'image/jpeg' });
/** The page's half of the mirror: frames in and drawn, then acked; touches, wheel and keys out as the phone takes them, or to A-Eye's lens while it waits. */
@@ -104,6 +106,7 @@ export function useMirror(watching: boolean): Mirror {
};
const lens = (command: LensCommand) => send({ op: 'lens', lens: command });
const press = (event: PointerEvent) => {
+ if (event.button !== 0) return;
target.setPointerCapture(event.pointerId);
target.focus();
event.preventDefault();
@@ -145,11 +148,12 @@ export function useMirror(watching: boolean): Mirror {
event.preventDefault();
};
const key = (event: KeyboardEvent) => {
- if (event.metaKey || event.ctrlKey || event.altKey) return;
+ const text = typedText(event, MAC);
+ if (text === undefined && (event.metaKey || event.ctrlKey || event.altKey)) return;
if (pickingNow.current && event.key === 'Escape') lens({ op: 'cancel' });
else if (pickingNow.current && event.key === 'ArrowUp') lens({ op: 'wider' });
else if (isMirrorKey(event.key)) send({ op: 'key', key: event.key });
- else if (event.key.length === 1) send({ op: 'text', text: event.key });
+ else if (text !== undefined) send({ op: 'text', text });
else return;
event.preventDefault();
};
diff --git a/src/lib/phone/mirror.test.ts b/src/lib/phone/mirror.test.ts
index bafa323..a4182e6 100644
--- a/src/lib/phone/mirror.test.ts
+++ b/src/lib/phone/mirror.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
-import { addressOf, isMirrorKey, keyEvents, touchPoint } from './mirror';
+import { addressOf, isMirrorKey, keyEvents, touchPoint, typedText } from './mirror';
describe('a click on the mirror', () => {
test('lands where spike Q8 measured it: the frame is the visual viewport, scaled by the zoom', () => {
@@ -33,6 +33,32 @@ describe('keys on the mirror', () => {
expect(isMirrorKey('a')).toBe(false);
expect(isMirrorKey('F5')).toBe(false);
});
+
+ const press = (key: string, held: { meta?: boolean; ctrl?: boolean; alt?: boolean; altGraph?: boolean } = {}) => ({
+ key,
+ metaKey: !!held.meta,
+ ctrlKey: !!held.ctrl,
+ altKey: !!held.alt,
+ getModifierState: (name: string) => name === 'AltGraph' && !!held.altGraph,
+ });
+
+ test('AltGr types on Windows, where it reads as Ctrl+Alt, and on Linux, where it is AltGraph alone', () => {
+ expect(typedText(press('@', { ctrl: true, alt: true }), false)).toBe('@');
+ expect(typedText(press('€', { ctrl: true, alt: true, altGraph: true }), false)).toBe('€');
+ expect(typedText(press('{', { altGraph: true }), false)).toBe('{');
+ });
+
+ test('Option types on a Mac; elsewhere Alt alone is a shortcut', () => {
+ expect(typedText(press('@', { alt: true }), true)).toBe('@');
+ expect(typedText(press('f', { alt: true }), false)).toBeUndefined();
+ });
+
+ test('Ctrl, Command and named keys never type', () => {
+ expect(typedText(press('a'), false)).toBe('a');
+ expect(typedText(press('c', { ctrl: true }), false)).toBeUndefined();
+ expect(typedText(press('v', { meta: true }), true)).toBeUndefined();
+ expect(typedText(press('Enter'), false)).toBeUndefined();
+ });
});
describe('the address bar', () => {
diff --git a/src/lib/phone/mirror.ts b/src/lib/phone/mirror.ts
index 9ca0f14..ce62c12 100644
--- a/src/lib/phone/mirror.ts
+++ b/src/lib/phone/mirror.ts
@@ -19,6 +19,18 @@ export type MirrorKey = (typeof MIRROR_KEYS)[number];
export const isMirrorKey = (key: string): key is MirrorKey => (MIRROR_KEYS as readonly string[]).includes(key);
+type KeyPress = Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'altKey' | 'getModifierState'>;
+
+/**
+ * The character a key press types, or undefined for a shortcut. AltGr reads as Ctrl+Alt on Windows,
+ * and Option alone types on a Mac, so both type: that is how `@`, `€` or `{` come on many layouts.
+ */
+export function typedText(press: KeyPress, mac: boolean): string | undefined {
+ if (press.key.length !== 1 || press.metaKey) return undefined;
+ if (press.getModifierState('AltGraph') || press.ctrlKey === press.altKey) return press.key;
+ return mac && press.altKey ? press.key : undefined;
+}
+
export type MirrorCommand =
| { op: 'watch' }
| { op: 'unwatch' }