feat(server,app,website): prefix service URLs with project slug

Service hostnames now follow DNS convention with a project label so
independently opened projects no longer collide on routes like
`web.localhost`. Format becomes `{script}.{project}.localhost` for
default branches and `{script}.{branch}.{project}.localhost` for other
branches. The project slug comes from the GitHub repository name when a
remote exists, otherwise from the workspace directory basename.

Server changes:
- `buildScriptHostname` takes `{ projectSlug, branchName, scriptName }`
  and slugifies all labels at the boundary; `untitled` fallback only
  applies at hostname-label sites, never to shared `slugify`.
- `deriveProjectSlug(cwd)` and `parseGitHubRepoNameFromRemote` derive
  the slug; GitHub URL parsing now requires `host === "github.com"` to
  avoid embedded-path false matches.
- `ScriptRouteEntry` carries `projectSlug`; branch-rename handler reuses
  it instead of re-reading git in hot paths.
- Status projection derives slug once per call and uses route hostname
  when available; only falls back to building when no route exists.
- Spawn cleanup removes routes by `{ workspaceId, scriptName }` so
  cleanup after a branch rename doesn't leave a stale entry behind.

App and shared message tests updated to the new fixture shape; service
URLs continue to be opaque server-provided strings.

Landing-page service URL examples updated; allowlist docs unchanged.
This commit is contained in:
Mohamed Boudra
2026-04-18 19:31:23 +07:00
parent 23b20169ef
commit 7819019cea
23 changed files with 680 additions and 224 deletions
@@ -138,9 +138,9 @@ describe("workspace message schemas", () => {
scripts: [
{
scriptName: "web",
hostname: "web.localhost",
hostname: "web.paseo.localhost",
port: 3000,
proxyUrl: "http://web.localhost:6767",
proxyUrl: "http://web.paseo.localhost:6767",
lifecycle: "running",
health: "healthy",
},
@@ -157,9 +157,9 @@ describe("workspace message schemas", () => {
{
scriptName: "web",
type: "service",
hostname: "web.localhost",
hostname: "web.paseo.localhost",
port: 3000,
proxyUrl: "http://web.localhost:6767",
proxyUrl: "http://web.paseo.localhost:6767",
lifecycle: "running",
health: "healthy",
exitCode: null,
@@ -204,7 +204,7 @@ describe("workspace message schemas", () => {
scripts: [
{
scriptName: "web",
hostname: "web.localhost",
hostname: "web.paseo.localhost",
port: null,
proxyUrl: null,
lifecycle: "stopped",