Build an engine helper
A TermSurf engine helper owns real browser tabs and surfaces, connects to the host with framed IPC, and streams page state—patterned on ah-chromiumd.
What you are building
An engine helper is a long-lived process that implements the tab and surface side of TermSurf. It does not own pane layout. The host binds panes to tabs and composites your surfaces into the window. Pane clients (apps, ahweb) never embed your binary.
Shipped reference
Product path today: ah-chromiumd (Chromium). Historical WebKit/Gecko helpers are not required for a current product build. This page describes the protocol role using the Chromium helper as the live reference.
Process placement
client (app / ahweb)
│ TERMSURF_SOCKET (pane client)
▼
host (ahterm)
│ --ipc-socket=… (engine connects here)
│ --listen-socket=… (optional; engine may listen)
▼
engine helper (ah-chromiumd)Unlike TermSurf apps, helpers are usually spawned by the host with argv—not via TERMSURF_SOCKET alone. App how-to: App.
Discovery / argv
| Flag | Role |
|---|---|
| --ipc-socket(required) | Connect to the host/GUI TermSurf Unix domain socket (required for live IPC). |
| --listen-socket | Optional: bind and accept additional local IPC clients; replay state on connect. |
| --user-data-dir | Browser profile data directory. |
| --browser-name | Browser family identity advertised in ServerRegister (e.g. chromium). |
Also product knobs such as --incognito, --termsurf-warmup, --version / --help on the shipped helper.
Startup sequence
- Initialize the engine runtime and browser context.
- If
--ipc-socketis set, connect a Unix domain socket to the host (same framing as clients— Wire). Without it, the shipped helper skips IPC. - Send ServerRegister with profile and browser family identity.
- Spawn a reader thread for host→engine frames.
- If
--listen-socketis set, bind, accept additional local clients, and replay state to them.
Inbound (host → engine)
Names only—fields on Messages. Representative groups from the live Chromium dispatch path:
Tab lifecycle
Presentation / state
Dialog / chooser / drop replies
Outbound (engine → host)
After register, emit tab readiness and ongoing page/surface state so the host can composite and keep chrome honest:
Surfaces and compositing
The engine reports surface or platform context (for example CaContext / RenderSurface) so the host can composite the tab into a pane. The host owns the window and pane geometry; you own the document and the buffer/layer identity.
Lifecycle and errors
- Missing
--ipc-socket: shipped helper continues without IPC (no host channel). - EOF / error on the GUI connection may quit the helper (product path treats host disconnect as fatal for the engine process).
- Optional traces:
TERMSURF_ENGINE_STARTUP_TRACE/_FILE(see Wire secondary env).
Do and don’t
- Do use the same length-prefixed
TermSurfMessageframes as clients. - Do register with
ServerRegisterbefore expecting tab work. - Don’t invent a public TCP TermSurf port.
- Don’t claim multiple product engines ship unless the install does—Chromium is the current product path.
- Don’t implement pane splits or client
SetOverlaylayout—that is host/app territory.
