Repository navigation
refactor(serve): split serve.zig into focused modules - #436
Conversation
serve.zig (2,156 lines) becomes a thin root re-exporting the same public API (serveAndOpen, installCancelHandler, RebuildFn, WatchConfig, watchIgnorePath; the stop flag stays reachable as cancel.cancel_requested) over src/cli/serve/: server.zig serveAndOpen, the accept loop, browser launch http.zig request handling, target resolution, MIME, live-reload cancel.zig signal / console handler and the waker watch.zig WatchConfig, WatchState, debounce, watchLoop baseline.zig WatchBaseline follow-up / cap / ceiling policy tree.zig TreeSignature, TreeSnapshot, key sets, the walk testing.zig shared test helpers Moves plus import/pub fixes only; tests move with their code and every file is referenced from the root's test block (48 named tests before and after). The four new files carrying the moved platform words join the agnosticism guard allowlist; serve.zig stays on it. Claude-Session: https://claude.ai/code/session_01R2K5sJDL5Msn1uRTkybiDP
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Refactor only.
src/cli/serve.zigwas 2,156 lines, over the toolkit's 1,000-line limit. It is now a thin root that re-exports the same public API oversrc/cli/serve/, following the same pattern as the labelle-bgfxgfx/split. Nothing changes behaviour: code was moved, and imports andpubmarkers were fixed to match. Tests moved with the code they cover.File map
src/cli/serve.zigserveAndOpen,installCancelHandler,RebuildFn,WatchConfig,watchIgnorePath,pub const cancelsocancel.cancel_requestedis still reachable), and atest {}block that references every moduleserve/server.zigserveAndOpen,serveLoop(the accept loop),openBrowser, and the serveLoop testserve/http.zighandleConnection,resolveTarget,resolveRoot, MIME table, live-reload endpoint, reload client,injectReloadScript, and their testsserve/cancel.zigcancel_requested,installCancelHandler, the POSIX signal handler, the WindowsSetConsoleCtrlHandlerhandler,wakeListener/wakeLoop, and the wakeLoop testserve/watch.zigRebuildFn,WatchConfig,WatchState,shouldRebuild,watchLoop, and the debounce testsserve/baseline.zigWatchBaseline(follow-up, cap and ceiling policy) and its 10 testsserve/tree.zigTreeSignature,TreeSnapshot,changedPaths, the key-set helpers, the walk and its skip rules (build output, declared outputs, nested checkouts), and their testsserve/testing.zigtestSig,testDelta,testBindFreePortOne test changed files for a reason other than following its code.
computeSignature: a same-size in-place edit triggers a rebuildnow lives inwatch.zigbecause it assertsshouldRebuild. Its comment now says "test in tree.zig" instead of "test above".Agnosticism guard allowlist delta
cli/serve/http.zig,cli/serve/server.zig,cli/serve/tree.zig,cli/serve/watch.zig. They carry the platform words that moved out ofserve.zig:web_dir, the WASM rebuild log line,emcc, and theraylib_wasmtest fixture path.cli/serve.zig. The root keeps the original module doc ("serving WASM builds"), so it is still dirty. The existing stale-entry test that names it is unchanged.cancel.zig,baseline.zig,testing.zig.Test counts (
zig build test --summary all)test "…"decls in serveThe +1 is the new unnamed
test {}aggregator block inserve.zig, which the runner counts as a test. Since the named-test set is identical and the runner total is exactly +1, all 48 moved tests still run and none were dropped by lazy analysis.Verification
Each command's exit code was checked on its own:
zig fmt --check: 0zig build: 0zig build -Dtarget=x86_64-windows: 0 (covers the Windows console-control path)zig build test: 0test/provider_dispatch_e2e.py,provider_github_e2e.py,provider_config_e2e.py,provider_hooks_e2e.py,provider_targets_e2e.py,plugin_compat_e2e.py: all 0https://claude.ai/code/session_01R2K5sJDL5Msn1uRTkybiDP
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.