Skip to content

fix(server): tell a CodeWork server runs from its URL, not its pid - #134

Merged
sanchitrk merged 1 commit into
canaryfrom
claude/server-url-health
Nov 3, 2026
Merged

sanchitrk merged 1 commit into
canaryfrom
claude/server-url-health

Conversation

@sanchitrk

Copy link
Copy Markdown
Contributor

Summary

The app read a server as running only while the pid in its service.json was alive on the app's machine. A CodeWork server in WSL registers a Linux pid the Windows app can't see, so Settings always said "Stopped", even with Home pointed at \\wsl.localhost\<distro>\home\<you>\.codework.

Status now comes from the registration's URL:

  • Codework.reachable(url): opens a WebSocket to the URL (2-second open timeout) and closes it, with no RPC call.
  • liveAt: a home's server is live while its URL answers. This drives status for every server and the health poll's 5-second check of the default.
  • The default server still calls server.info and checks that the pid it reports is the registration's. That works across OSes, since both come from the same server, so another server on that port still reads "Unreachable".
  • A stale registration with nothing listening, left by a crash, now reads "Stopped" instead of "Unreachable", even when its pid happens to be alive.
  • alive(pid) moves into server.ts, its only remaining user: the app server's own parent check.

Home stays the way the app finds a local server: read <home>/service.json, take the URL, connect.

Testing

  • apps/server/test/health.test.ts now runs the real CLI (codework serve --port 0 from source) and covers:
    • A real server: "Running".
    • The same server, registered in a second home with a pid no process here has: "Running". This is the Windows + WSL case.
    • Killed with SIGKILL, registration left behind: "Stopped" for both.
    • A registration with a live pid but nothing at its URL: "Stopped".
  • On the old code the test fails with expected 'Stopped' to be 'Running'.
  • The test now reads only the app server's ready line, as the desktop app does. It used to parse every stdout line, which broke once the app server logged.
  • Passed three runs in a row on macOS; the artifact is stable.
  • vp check and vp run typecheck pass.
  • Not tried on Windows yet.

🤖 Generated with Claude Code

A home's service.json counted only while its pid was alive here. A server in
WSL registers a Linux pid the Windows app cannot see, so it always read as
stopped. The app now opens the registration's URL instead: a server that
answers runs, whatever OS it is on, and a registration left behind with
nothing listening is stopped rather than unreachable. The default server
still checks that the pid it reports is the registration's.

The health test runs the real CLI and covers a pid from another OS and a
server killed outright.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit 49f5e34 into canary Nov 3, 2026
1 check passed
@sanchitrk
sanchitrk deleted the claude/server-url-health branch November 3, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant