Expand description
Debug server for inspecting webview content via HTTP API. Only compiled in debug builds.
ยงLayered DebugServer (Mountain layer)
This is the Mountain half of the dual-layer DebugServer. It exposes
an HTTP surface bound to 127.0.0.1 for live inspection and command
invocation against the running renderer (workbench webview).
Activation is gated by the unified DebugServer env var:
| Value | Mountain layer | Cocoon layer |
|---|---|---|
unset, 0, false, off | off | off |
1, true, on | on | off (compat) |
mountain, m | on | off |
cocoon, c, eh | off | on |
both, all | on | on |
Ports: DebugServerPort (legacy alias DebugServerPortMountain,
default 9933) - Mountain. Cocoon uses DebugServerPortCocoon
(default 9934).
ยงEndpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /health | Layer identity + capability advertisement |
| GET | /layers | Discoverability: lists every reachable layer |
| GET | /eval?js=โฆ | Eval JS in the renderer; returns parsed JSON |
| POST | /execute | Body {js,target?}; target=renderer|iframe:<id> |
| GET | /iframes | Walk DOM iframes (src/id/name) |
| GET | /console | Drain the renderer console mirror buffer |
| GET | /commands | Enumerate registered workbench commands |
| POST | /command | Body {id,args?} - invoke a workbench command |
| POST | /vscode/diff | Body {left,right,title?} - open diff editor |
| GET | /extensions | Proxies Cocoon /extensions if reachable |
All responses are JSON. Mountain-layer endpoints execute in the renderer
via WebviewWindow::eval_with_callback. Cocoon-targeted requests are
HTTP-forwarded to the Cocoon DebugServer when present, transparently.
Enumsยง
- Layer
Mode ๐ - Parsed Mountain-layer activation mode. See module docs for the matrix.
Staticsยง
- WINDOW ๐
- Global storage for the webview window used by the debug server.
Functionsยง
- cocoon_
enabled ๐ - cocoon_
port ๐ - eval_js ๐
- Evaluates JavaScript in the webview and returns the result as a serde_json::Value.
- handle_
connection ๐ - Handles a single HTTP connection, dispatches based on method and path.
- install
- Installs the Mountain-layer debug server and stores a reference to the renderer webview window. Called once during app setup in debug builds.
- mountain_
enabled ๐ - mountain_
port ๐ - parse_
mode ๐ - proxy_
to_ ๐cocoon - Best-effort forward to the Cocoon DebugServer over loopback. Returns (status, json). If Cocoon is unreachable, returns 502.
- send_
json ๐ - Sends a JSON response with the given status code.
- start_
server ๐ - Main server loop listening for TCP connections.