Skip to content

Commit cee2c7f

Browse files
authored
feat: add PLANNOTATOR_BROWSER for browser selection (#48)
Allow users to specify which browser opens plan files via environment variable. Default behavior unchanged - only activates when env var is set. - macOS: Set to app name ("Google Chrome") or path - Linux/Windows: Set to executable path Closes #42
1 parent 03a19f5 commit cee2c7f

4 files changed

Lines changed: 41 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ claude --plugin-dir ./apps/hook
5353
|----------|-------------|
5454
| `PLANNOTATOR_REMOTE` | Set to `1` or `true` for remote mode (devcontainer, SSH). Uses fixed port and skips browser open. |
5555
| `PLANNOTATOR_PORT` | Fixed port to use. Default: random locally, `19432` for remote sessions. |
56+
| `PLANNOTATOR_BROWSER` | Custom browser to open plans in. macOS: app name or path. Linux/Windows: executable path. |
5657

5758
**Legacy:** `SSH_TTY` and `SSH_CONNECTION` are still detected. Prefer `PLANNOTATOR_REMOTE=1` for explicit control.
5859

apps/hook/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ When Claude Code calls `ExitPlanMode`, this hook intercepts and:
7070
3. Approve → Claude proceeds with implementation
7171
4. Request changes → Your annotations are sent back to Claude
7272

73+
## Environment Variables
74+
75+
| Variable | Description |
76+
|----------|-------------|
77+
| `PLANNOTATOR_REMOTE` | Set to `1` for remote mode (devcontainer, SSH). Uses fixed port and skips browser open. |
78+
| `PLANNOTATOR_PORT` | Fixed port to use. Default: random locally, `19432` for remote sessions. |
79+
| `PLANNOTATOR_BROWSER` | Custom browser to open plans in. macOS: app name or path. Linux/Windows: executable path. |
80+
7381
## Remote / Devcontainer Usage
7482

7583
When running Claude Code in a remote environment (SSH, devcontainer, WSL), set these environment variables:

apps/opencode-plugin/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ Restart OpenCode. The `submit_plan` tool is now available.
4949
- **Private sharing**: Plans and annotations compress into the URL itself—share a link, no accounts or backend required
5050
- **Obsidian integration**: Auto-save approved plans to your vault with frontmatter and tags
5151
52+
## Environment Variables
53+
54+
| Variable | Description |
55+
|----------|-------------|
56+
| `PLANNOTATOR_REMOTE` | Set to `1` for remote mode (devcontainer, SSH). Uses fixed port and skips browser open. |
57+
| `PLANNOTATOR_PORT` | Fixed port to use. Default: random locally, `19432` for remote sessions. |
58+
| `PLANNOTATOR_BROWSER` | Custom browser to open plans in. macOS: app name or path. Linux/Windows: executable path. |
59+
5260
## Devcontainer / Docker
5361
54-
Works in containerized environments. Set two env vars and forward the port:
62+
Works in containerized environments. Set the env vars and forward the port:
5563
5664
```json
5765
{

packages/server/browser.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,35 @@
55
import { $ } from "bun";
66

77
/**
8-
* Open a URL in the default browser
8+
* Open a URL in the browser
9+
*
10+
* Uses PLANNOTATOR_BROWSER env var if set, otherwise uses system default.
11+
* - macOS: Set to app name ("Google Chrome") or path ("/Applications/Firefox.app")
12+
* - Linux/Windows: Set to executable path ("/usr/bin/firefox")
13+
*
914
* Fails silently if browser can't be opened
1015
*/
1116
export async function openBrowser(url: string): Promise<boolean> {
1217
try {
18+
const browser = process.env.PLANNOTATOR_BROWSER;
1319
const platform = process.platform;
14-
if (platform === "win32") {
15-
await $`cmd /c start ${url}`.quiet();
16-
} else if (platform === "darwin") {
17-
await $`open ${url}`.quiet();
20+
21+
if (browser) {
22+
// Custom browser specified
23+
if (platform === "darwin") {
24+
await $`open -a ${browser} ${url}`.quiet();
25+
} else {
26+
await $`${browser} ${url}`.quiet();
27+
}
1828
} else {
19-
await $`xdg-open ${url}`.quiet();
29+
// Default system browser
30+
if (platform === "win32") {
31+
await $`cmd /c start ${url}`.quiet();
32+
} else if (platform === "darwin") {
33+
await $`open ${url}`.quiet();
34+
} else {
35+
await $`xdg-open ${url}`.quiet();
36+
}
2037
}
2138
return true;
2239
} catch {

0 commit comments

Comments
 (0)