Skip to content

fix: use ~/.agent-browser for socket files instead of TMPDIR#180

Merged
ctate merged 3 commits into
vercel-labs:mainfrom
mmhiyoko:fix/use-fixed-socket-directory
Jan 22, 2026
Merged

fix: use ~/.agent-browser for socket files instead of TMPDIR#180
ctate merged 3 commits into
vercel-labs:mainfrom
mmhiyoko:fix/use-fixed-socket-directory

Conversation

@mmhiyoko

@mmhiyoko mmhiyoko commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix socket path to use ~/.agent-browser/ instead of TMPDIR. Fixes #163.

Different tools (tmux, VSCode, IntelliJ) set different TMPDIR values, causing CLI and daemon to look
for sockets in different locations.

Socket directory priority:

  1. AGENT_BROWSER_SOCKET_DIR (explicit override)
  2. $XDG_RUNTIME_DIR/agent-browser (Linux standard)
  3. ~/.agent-browser/ (fallback, like Docker Desktop)

Test plan

  • npm test passes
  • Manual test: different TMPDIR values use same socket
  • Manual test: --session option works with different TMPDIR
  • Manual test: AGENT_BROWSER_SOCKET_DIR override works

Notes

Breaking Change

Socket files are now stored in ~/.agent-browser/ instead of $TMPDIR/.
Old CLI + new daemon (or vice versa) won't work together.

Backward Compatibility Considered

I considered adding fallback to check old paths (similar to docker-modem's approach),
but decided against it because:

  • v0.x allows breaking changes
  • CLI and daemon are installed together, reducing version mismatch risk
  • Keeps the code simple

Let me know if you'd prefer backward compatibility added.

🤖 Generated with Claude Code

This fixes issue vercel-labs#163 where different TMPDIR values (common with
tmux/screen/VSCode/IntelliJ) caused the CLI and daemon to use
different socket paths.

Socket directory priority:
1. AGENT_BROWSER_SOCKET_DIR (explicit override)
2. $XDG_RUNTIME_DIR/agent-browser (Linux standard)
3. ~/.agent-browser (fallback, like Docker Desktop)

Both CLI (Rust) and daemon (Node.js) now use the same logic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

@mmhiyoko is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The session list command looks for pid files in temp directory but they are now stored in socket directory, causing it to fail to find any sessions

Fix on Vercel

Comment thread cli/src/connection.rs
}

// 3. Home directory fallback (like Docker Desktop's ~/.docker/run/)
if let Some(home) = dirs::home_dir() {

@vercel vercel Bot Jan 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing use dirs; import causes compilation error when dirs::home_dir() is called

Fix on Vercel

Comment thread src/daemon.ts Outdated
}

// 3. Home directory fallback (like Docker Desktop's ~/.docker/run/)
return path.join(os.homedir(), '.agent-browser');

@vercel vercel Bot Jan 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript getSocketDir() function now has proper error handling for os.homedir() that can throw ERR_OS_HOMEDIR_UNAVAILABLE in restricted environments, matching the Rust implementation's robustness

Fix on Vercel

mmhiyoko and others added 2 commits January 21, 2026 01:25
- Make get_socket_dir() public in connection.rs
- Update session list to use get_socket_dir() instead of temp_dir()
- Update pid file pattern from agent-browser-{session}.pid to {session}.pid
- Add tmpdir fallback to daemon.ts when homedir is unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive tests for get_socket_dir/getSocketDir to verify:
- AGENT_BROWSER_SOCKET_DIR takes priority
- Empty strings are ignored (fixes Rust/TypeScript consistency)
- XDG_RUNTIME_DIR fallback works correctly
- Home directory fallback when env vars unset

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ctate

ctate commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Great call, thanks for your contribution!

@ctate ctate merged commit 946d236 into vercel-labs:main Jan 22, 2026
1 of 2 checks passed
@mmhiyoko mmhiyoko deleted the fix/use-fixed-socket-directory branch January 26, 2026 23:56
timothywangdev pushed a commit to timothywangdev/banana-browser that referenced this pull request Mar 17, 2026
…labs#180)

* fix: use ~/.agent-browser for socket files instead of TMPDIR

This fixes issue vercel-labs#163 where different TMPDIR values (common with
tmux/screen/VSCode/IntelliJ) caused the CLI and daemon to use
different socket paths.

Socket directory priority:
1. AGENT_BROWSER_SOCKET_DIR (explicit override)
2. $XDG_RUNTIME_DIR/agent-browser (Linux standard)
3. ~/.agent-browser (fallback, like Docker Desktop)

Both CLI (Rust) and daemon (Node.js) now use the same logic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: session list now looks in correct socket directory

- Make get_socket_dir() public in connection.rs
- Update session list to use get_socket_dir() instead of temp_dir()
- Update pid file pattern from agent-browser-{session}.pid to {session}.pid
- Add tmpdir fallback to daemon.ts when homedir is unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add unit tests for socket directory resolution

Add comprehensive tests for get_socket_dir/getSocketDir to verify:
- AGENT_BROWSER_SOCKET_DIR takes priority
- Empty strings are ignored (fixes Rust/TypeScript consistency)
- XDG_RUNTIME_DIR fallback works correctly
- Home directory fallback when env vars unset

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent-browser fails to start in Claude Code environment due to TMPDIR mismatch

2 participants