Studio UI integration
Studio UI is Surfpool’s graphical workspace for viewing and working with a running local environment. The surfpool-studio-ui package joins a released web interface to Surfpool’s HTTP service, so one Surfpool process can serve the page and the data that powers it. This page is a child of User interfaces and automation and relates to the CLI and HTTP server, Interactive terminal UI, and Runbook automation pages.
Graphical workspace
The Studio UI gives a user a browser-based view of Surfpool while the CLI remains the main way to start and configure the environment. The UI receives connection details from the running service and uses the same Surfpool session to show runtime data and manage scenario-oriented work.
User-facing role
Studio is the graphical counterpart to the terminal dashboard. It is useful when a user needs a visual workspace rather than a log stream or terminal view. Surfpool can disable it with --no-studio when a graphical surface is not needed.
References: crates/…/mod.rs• L392-412 crates/…/mod.rs• L332-349
Service relationship
The graphical page and its data service share the Studio listener. This keeps the browser entry point, Surfpool connection settings, scenario templates, and loaded scenarios aligned with the same running environment instead of creating a separate client service.
References: crates/…/mod.rs• L44-55 crates/…/mod.rs• L57-110
Workspace package
The workspace package is the Rust boundary between the released Studio web application and Surfpool’s server. It exposes a library that the CLI can attach to its HTTP service and a build step that makes the web assets available to that library.
Library boundary
crates/…/Cargo.toml defines surfpool-studio-ui as a workspace package. The package can be used as a Rust library and as a dynamic library, while its web-serving concerns stay separate from the CLI’s process and runtime control. The library exposes the Studio asset service used by the HTTP server.
References: crates/…/Cargo.toml• L1-33 crates/…/lib.rs• L1-9
Build asset delivery
The build step supplies a web distribution to the package and embeds it into the compiled artifact. A build can use a local distribution path through STUDIO_UI_DIST, or fetch a versioned release through STUDIO_UI_VERSION; without either value it uses the latest published Studio distribution. This makes the runtime independent of a separate web server.
References: crates/…/build.rs• L1-63
Studio service flow
Surfpool creates the Studio endpoint during simnet startup, then gives the browser the URLs needed to reach the active runtime. The following flow shows how the packaged page becomes a user-facing interface.
flowchart LR
A[Surfpool start] --> B[Resolve Studio bind and public URLs]
B --> C[Start HTTP service]
C --> D[Serve embedded Studio page]
C --> E[Expose config and scenario API]
D --> F[Browser workspace]
F --> E
E --> G[Live Surfpool environment]
Endpoint coordination
Endpoint resolution separates where Studio listens from the URL that Surfpool shows to users. This supports local use and deployments behind a proxy. The resolved Studio URL is placed in the sanitized configuration together with the RPC, WebSocket, and query-service URLs so the page can connect to the intended environment.
References: crates/…/endpoints.rs• L10-22 crates/…/endpoints.rs• L50-113 crates/…/types.rs• L859-878
Static page serving
The library serves the embedded web files from the Studio listener. A root request returns the page entry point, while known file and route forms resolve to their matching assets. Browser routes can fall back to that entry point so the graphical application can handle navigation itself.
References: crates/…/lib.rs• L5-37
Browser data access
The same service exposes the data boundary used by Studio. It returns the active connection configuration, lists scenario templates, and lets the UI create, read, update, and remove loaded scenarios. An explicit /v1 guard returns a JSON not-found response for unknown API paths instead of treating them as browser routes.
References: crates/…/mod.rs• L44-55 crates/…/mod.rs• L132-161 crates/…/mod.rs• L164-258 crates/…/mod.rs• L260-319 crates/…/mod.rs• L476-519
Runtime integration
Studio is an optional presentation layer on top of the running Surfpool services. The CLI starts the shared server with Studio enabled by default, records its handle for process control, and displays either the Studio URL or the direct data source URL when Studio is disabled.
Startup contract
Simnet startup resolves the endpoint set before it starts the Studio and scenario server. The server receives the sanitized configuration and the event channel that links the HTTP-facing layer to the active Surfpool runtime. If server startup fails, Surfpool reports the warning and continues the simnet startup without the Studio service.
References: crates/…/mod.rs• L127-165
URL and proxy behavior
Studio has separate controls for its bind address and its advertised URL. SURFPOOL_STUDIO_HOST changes the listener address, while SURFPOOL_PUBLIC_STUDIO_URL supplies the browser-facing address when a proxy or gateway publishes Studio elsewhere. A shared public host can provide a default when no Studio-specific public URL is set.
References: crates/…/endpoints.rs• L24-47 crates/…/endpoints.rs• L62-113
Change checklist
When these files or sections are changed, remember to consider these:
- When the Studio distribution format or release location changes, keep the build inputs and embedded asset path aligned with the published web package.
- When the browser connection contract changes, update the fields in
SanitizedConfigand the values assembled during simnet startup together. - When Studio API paths change, preserve the
/v1boundary so unknown API requests do not receive the single-page application entry point. - When listener or proxy behavior changes, keep bind settings and advertised URL settings separate in endpoint resolution.
- When Studio is disabled or its startup fails, keep CLI URL display and the direct data-source fallback consistent with that state.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The Studio distribution cannot be opened, downloaded, or extracted during the build | The surfpool-studio-ui package cannot provide the graphical page | Supply a valid local distribution or a reachable published release before building |
| Studio’s bind address conflicts with another Surfpool listener | The shared HTTP service cannot bind and Studio is unavailable | Resolve the Studio endpoint with the runtime configuration and check listener conflicts before startup |
SURFPOOL_PUBLIC_STUDIO_URL does not describe the address that users can reach | The page may load but connect to the wrong runtime location | Set the advertised URL for the proxy or gateway that publishes Studio |
An unknown /v1 request is allowed to use the page fallback | API clients receive a misleading HTML success response | Keep the /v1 default route ahead of the Studio static-file service |
--no-studio is set | Surfpool runs without the graphical page and shows the direct data-source URL instead | Use the CLI or another client surface when Studio is intentionally disabled |
Key files
| File | Why to read it |
|---|---|
| crates/…/Cargo.toml | Defines the Studio workspace package and its library boundary. |
| crates/…/build.rs | Explains how the released web distribution enters the compiled package. |
| crates/…/lib.rs | Shows the asset-serving boundary used by the HTTP service. |
| crates/…/mod.rs | Shows the shared server, browser data API, and API-versus-page routing boundary. |
| crates/…/endpoints.rs | Defines the distinction between listener addresses and advertised Studio URLs. |
| crates/…/mod.rs | Connects endpoint resolution and Studio startup to the simnet lifecycle. |
| crates/…/types.rs | Defines the Studio configuration and the connection data sent to the UI. |