feat: native Windows support for browse tool#191
Open
fqueiro wants to merge 3 commits intogarrytan:mainfrom
Open
feat: native Windows support for browse tool#191fqueiro wants to merge 3 commits intogarrytan:mainfrom
fqueiro wants to merge 3 commits intogarrytan:mainfrom
Conversation
Bun's subprocess pipe handling breaks Playwright's CDP connection on
Windows, causing chromium.launch() to hang indefinitely. On Windows,
the server now runs under Node (via tsx) instead of Bun, with a
dedicated server-node.mjs entry point using Node's http module.
Changes by category:
Cross-platform path handling:
- New platform.ts with TEMP_DIR, getSafeDirectories(), isPathWithin()
- Replace hardcoded /tmp with os.tmpdir() across all modules
- Fix path validation to use path.sep instead of hardcoded /
- Fix dev mode detection to use path.isAbsolute() not startsWith('/')
Windows process management:
- cli.ts: Use child_process.spawn with detached:true on Windows
- cli.ts: killServer() uses process.kill(pid) on Windows (no SIGTERM)
- cli.ts: Skip legacy /tmp cleanup on Windows
- cli.ts: Resolve bun.exe through npm .cmd shims
- server.ts: Add process.on('exit') handler for state file cleanup
Cross-runtime compatibility:
- config.ts: Bun.spawnSync → child_process.spawnSync
- write-commands.ts: Bun.spawn → child_process.spawn for URL open
- cookie-import-browser.ts: Dynamic import for bun:sqlite
- cookie-import-browser.ts: Platform guard (macOS-only) for browser
cookie import
- find-browse.ts: .exe suffix for binary discovery on Windows
New files:
- server-node.mjs: Node-compatible HTTP server for Windows
- platform.ts: Shared cross-platform helpers
- launch-chromium.mjs: Node-based Chromium launcher helper
Adds tsx as devDependency for Node TypeScript support on Windows.
Fixes garrytan#69
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Delete dead launch-chromium.mjs (unused debugging artifact) - Fix broken tests: listDomains is now async, use rejects.toThrow - Fix cookie-picker crash in server-node.mjs (Node IncomingMessage lacks .json()) - Fix silent fallback: resolveNodeServerScript throws on Windows if missing - Fix command injection in Bun.which shim: validate input before shell interpolation - Fix stale comment: --experimental-strip-types → --import tsx - Inline await_import_child_process, remove extra blank lines Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Create server-shared.ts with generateHelpText, wrapError, and dispatchCommand — shared between server.ts (Bun) and server-node.mjs (Node) to eliminate 156 lines of duplication - Fix uncaught JSON.parse crash in server-node.mjs that left HTTP responses hanging on malformed input - Add top-level try/catch in Node server request handler to prevent unhandled promise rejections - Add platform.test.ts (12 tests) and server-shared.test.ts (13 tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server-node.mjsentry pointplatform.tsmodule replaces all hardcoded/tmppaths,startsWith('/')checks, anddir + '/'path comparisons with OS-aware equivalentsKey changes
browse/src/platform.ts— new shared module:IS_WINDOWS,IS_MACOS,TEMP_DIR,getSafeDirectories(),isPathWithin()browse/src/server-node.mjs— Node-compatible server entry point for Windows with Bun API shim (Bun.which,Bun.sleep)browse/src/server-shared.ts— extractedgenerateHelpText(),wrapError(),dispatchCommand()shared between Bun and Node serversbrowse/src/cli.ts— Windows: resolve.cmdshim to realbun.exe, usechild_process.spawnwithdetached:true, usenode --import tsxfor serverbrowse/src/config.ts— replaceBun.spawnSyncwith NodespawnSyncfor git commandsbrowse/src/cookie-import-browser.ts— dynamicbun:sqliteimport, macOS-only guards, asynclistDomains()browse/src/find-browse.ts— look forbrowse.exeon Windowsbrowse/src/meta-commands.ts,read-commands.ts,snapshot.ts,write-commands.ts— useplatform.tsfor safe pathspackage.json— addtsxdevDependency for Windows Node serverTest plan
platform.test.ts(12) +server-shared.test.ts(13) — all pass on Windows, platform-agnosticcookie-import-browser.test.tsupdated for asynclistDomains()— passesfind-browse.test.ts— passes (findsbrowse.exe)$B goto <url>works end-to-end on Windows — ✅ tested: server starts, navigates, screenshots, snapshots with refs all work🤖 Generated with Claude Code