Repository navigation
Conversation
jserv
force-pushed
the
desktop
branch
2 times, most recently
from
October 18, 2026 14:19
8ad4c22 to
a158ef6
Compare
Without its arguments the binary falls back to web, which serves Setup until it is killed. A mutant that drops them, such as parse_agent_args returning nothing, then hangs whichever test ran the binary without a bound, and cargo mutants scores the caught mutant as a timeout, which fails the job. Only the refusal tests had a bound. Every run now goes through the bounded runner, which every caller already expected to exit, and so does the one test that started the binary itself.
A loopback bind keeps the network out but not a web page: any origin can repoint its own name at 127.0.0.1 and then read the server as same origin, including the reports behind it. The Host header is the one thing that still carries the foreign name. CODETRIAL_ALLOWED_HOSTS, or --allowed-hosts, names the Host values the server answers; anything else gets 421 before any route runs. It is empty by default, and the check is not installed at all then, because a reverse proxy forwarding the public name is an ordinary deployment.
A program that starts the server for someone, rather than an operator in a shell, chooses neither the working directory nor the folder the executable sits in, and both decide where the CLI looks for its config and writes its database, cold-start config and error log. An installed app's executable folder is read-only or inside a bundle. --data-dir DIR puts all of that in DIR and searches nowhere else. Such a launch also reads no configuration from the environment, so a shell that exported CODETRIAL_DB_PATH or NODE_ENV for a CLI deployment cannot move the install's reports depending on how it was started, and with no SESSION_SECRET in its config it makes and keeps its own key in DIR instead of signing cookies with the published default. A first launch into a folder that does not exist yet creates it for the error log, so the reason it failed is where its owner will look. One thing is taken from the environment: a first launch with the three LiveKit keys exported writes them, and the Google keys, into DIR's config as Setup would, and skips Setup. Without the flag nothing changes. That file and the key are written by the helper Setup now shares, owner-only and never over an existing name, which also removes a file a failed write cut short. The CLI tests start the server with an empty environment instead of a list of keys that had already fallen behind.
A program that starts the server as its child keeps it on a fixed port, and when that program crashes the server outlives it and holds the port, so the next launch cannot bind it. Parent-death signals and job objects differ on every platform; a pipe is closed by the kernel when its writer dies, however it dies, everywhere. With CODETRIAL_EXIT_WITH_STDIN set, the server exits once its standard input reaches end of file. It is read from the process environment even under --data-dir, because it describes the pipe the launcher handed over rather than configuring the server, and it has to hold while Setup serves. The exit does not print with eprintln, which would panic on the dead parent's stderr and end the watching thread instead.
Running CodeTrial means starting a server from a terminal and opening its address in a browser. desktop/ is a Tauri 2 app for macOS, Windows and Linux that starts the codetrial server as its child, in its own data folder on a fixed loopback port that only it may name, and shows the page in its own window. The server stays a separate program, so the CLI's startup is unchanged and the child is the binary its tests cover. The page gets no native access: only the server's origin and the app's starting page load in the window, the camera and microphone go to the server's page alone, and a close asks the page's leave-page guard first. Where WebKitGTK is built without WebRTC, which the interview's call needs, the interview opens in the default browser instead. The starting page takes the lobby's palette, accent and radii, copied since it loads before any server can serve them. The crate builds into target/desktop, and the gate builds and tests it where WebKitGTK is installed. CI does so whenever desktop/ or src/main.rs changes, since the crate's tests read the server's side of the launch from src/main.rs.
The desktop app has to reach people as installers, and the gate's unit tests never start a real server inside a real window. The desktop workflow builds the server and the app on Linux, macOS and Windows, packages them, and runs scripts/desktop-smoke.sh against each build: the server must answer, refuse a foreign Host, and exit when the app is killed outright. A desktop-vX.Y.Z tag whose version matches desktop/Cargo.toml publishes the installers as a prerelease, apart from the CLI's rolling latest release. Close #289
This comment has been minimized.
This comment has been minimized.
1 similar comment
Contributor
Author
|
Rebase latest |
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.
CodeTrial now ships as a desktop app for macOS, Windows and Linux. The app is a Tauri 2 shell in
desktop/that runs the samecodetrial webbinary as a child process and shows it in one window on a fixed127.0.0.1:3101, so no browser has to be opened by hand. Running the server as a child rather than linking it in keepssrc/main.rsclose to unchanged: the server gains three launcher options instead (--allowed-hosts,--data-dir,CODETRIAL_EXIT_WITH_STDIN), each an ordinary CLI option a non-desktop install can use too. The first launch asks for the LiveKit and Google keys on the server's Setup page, unless it was started from a terminal that already exportsLIVEKIT_URL,LIVEKIT_API_KEYandLIVEKIT_API_SECRET(and optionallyGOOGLE_API_KEYorGOOGLE_API_KEYS): those are written to the app's own config, checked as Setup checks them, and Setup is skipped.docs/desktop.mdhas the design, the file locations and the qualification list.The page gets no native access at all; navigation, camera and microphone permission, downloads and the close check are all decided from outside the page. Where WebKitGTK is built without WebRTC (Ubuntu 24.04, Debian 12 and Arch as packaged), the app opens the interview in the default browser and keeps the server running. The app's own starting page uses the visual system the interview pages now share: the lobby's palette on a light system and the warm dark one otherwise, the violet accent, and the same radii and type steps.
Verified with
scripts/test.shat the tip: exit 0, 1751 Rust tests, with the desktop and shellcheck lanes skipped because this host has neither WebKitGTK nor shellcheck; both ran separately. In a Debian 12 container with WebKitGTK 4.1 under xvfb: desktop clippy with-D warnings, the desktop unit tests, a release build, andscripts/desktop-smoke.sh(Setup answers, a foreignHostis refused, and SIGKILL of the app takes the server with it). Every commit builds, passes clippy and passes the server tests on its own. The screenshots come from that container at the app's 1280x860 window, light and dark from the system scheme; the Setup page is the server's own and is not changed here.Left out: GitHub sign-in and recording inside the window, signed installers, and automatic updates. An interview has not yet been run on real hardware in WKWebView, WebView2 or a WebRTC-enabled WebKitGTK; the checklist in
docs/desktop.mdis what a release needs before it is called more than a preview.Closes #289
Summary by cubic
CodeTrial now ships as a desktop app for macOS, Windows, and Linux. It starts the existing server in a child process and displays it in one window, so users don't need to launch a terminal or open a browser themselves.
Server and security
--data-dir,--allowed-hosts, andCODETRIAL_EXIT_WITH_STDINto isolate desktop state, reject unexpectedHostvalues, and stop the server if the app exits.Build and releases
Written for commit 60cb5ce. Summary will update on new commits.