Add web server mode for headless/remote access#28
Open
nandanadileep wants to merge 2 commits into
Open
Conversation
Implements an optional HTTP + WebSocket server that serves Switchboard from any browser without requiring Electron or a desktop environment. - web-server.js: standalone Node server (no new deps — uses built-in http plus the existing ws package). Mirrors all ipcMain.handle channels as POST /api/invoke endpoints. Terminal I/O and push events (terminal-data, projects-changed, cli-busy-state, etc.) flow over a single authenticated WebSocket connection. - public/web-api.js: browser-side shim that implements the same window.api interface as preload.js using fetch + WebSocket. No-ops in Electron mode (window.api already set by preload). - public/index.html: load web-api.js as the first script so it can define window.api before any other module runs. - package.json: add 'web' npm script for convenience. Usage: npm run web [-- --port 3000 --host 0.0.0.0] A bearer token is generated (or supplied via --token / SWITCHBOARD_TOKEN) and printed on startup. Append ?token=<token> to the URL or enter it when prompted. Closes doctly#23
Contributor
|
Sorry about the slowness, I should be able to get to this soon. |
4 tasks
ivandobskygithub
approved these changes
May 7, 2026
|
This is super, this helped me to use Switchboard for the WSL scenario. All my work is done inside WSL and Windows is just there as the host OS. The web interface runs inside WSL and I can actually do things now on the main browser, so yay! Previously this was impossible as the native electron app built on top of Linux was garbage and slow. The rendering was way off but since it was WSL I didn't want to setup too much GUI stuff inside it. This is cool though. |
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.
Implements the feature requested in #23 — an optional HTTP + WebSocket server mode that serves the Switchboard UI from any browser, no Electron or desktop environment required.
How it works
A single new entry point (
web-server.js) boots an HTTP server that:public/frontend as static filesPOST /api/invokeendpointterminal-data,projects-changed,cli-busy-state,mcp-open-diff, etc.)A browser-side shim (
public/web-api.js) implements the exact samewindow.apiinterface aspreload.jsusingfetch+ WebSocket. It's loaded as the first script inindex.htmland no-ops in Electron mode (wherewindow.apiis already set by the preload).No new runtime dependencies — the server uses Node's built-in
httpmodule plus thewspackage that was already independencies.Usage
On startup the token is printed to stdout:
All HTTP and WebSocket requests require a bearer token — either via
Authorization: Bearer <token>header or?token=<token>query parameter.Changes
web-server.jspublic/web-api.jswindow.apishim (~130 lines)public/index.htmlweb-api.jsas first scriptpackage.json"web": "node web-server.js"scriptElectron mode is completely unchanged.
Closes #23