Skip to main content

Module WebkitServer

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:

ValueMountain layerCocoon layer
unset, 0, false, offoffoff
1, true, ononoff (compat)
mountain, monoff
cocoon, c, ehoffon
both, allonon

Ports: DebugServerPort (legacy alias DebugServerPortMountain, default 9933) - Mountain. Cocoon uses DebugServerPortCocoon (default 9934).

ยงEndpoints

MethodPathPurpose
GET/healthLayer identity + capability advertisement
GET/layersDiscoverability: lists every reachable layer
GET/eval?js=โ€ฆEval JS in the renderer; returns parsed JSON
POST/executeBody {js,target?}; target=renderer|iframe:<id>
GET/iframesWalk DOM iframes (src/id/name)
GET/consoleDrain the renderer console mirror buffer
GET/commandsEnumerate registered workbench commands
POST/commandBody {id,args?} - invoke a workbench command
POST/vscode/diffBody {left,right,title?} - open diff editor
GET/extensionsProxies 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ยง

LayerMode ๐Ÿ”’
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.