Unify workspace service URLs (#1288)

* Unify workspace service proxying

* Clean up service proxy review issues
This commit is contained in:
Mohamed Boudra
2026-06-02 19:49:58 +08:00
committed by GitHub
parent 5666b3014a
commit 4f3116d28a
38 changed files with 2664 additions and 1538 deletions
+2
View File
@@ -2325,6 +2325,8 @@ export const WorkspaceScriptPayloadSchema = z.object({
type: z.enum(["script", "service"]).optional().default("service"),
hostname: z.string(),
port: z.number().int().positive().nullable(),
localProxyUrl: z.string().nullable().optional(),
publicProxyUrl: z.string().nullable().optional(),
proxyUrl: z.string().nullable().optional().default(null),
lifecycle: WorkspaceScriptLifecycleSchema,
health: WorkspaceScriptHealthSchema.nullable(),
@@ -5,6 +5,7 @@ import {
SessionInboundMessageSchema,
SessionOutboundMessageSchema,
WorkspaceDescriptorPayloadSchema,
WorkspaceScriptPayloadSchema,
} from "./messages.js";
describe("workspace message schemas", () => {
@@ -485,6 +486,53 @@ describe("workspace message schemas", () => {
});
});
test("parses workspace service payloads from old daemons without split proxy URLs", () => {
const parsed = WorkspaceScriptPayloadSchema.parse({
scriptName: "web",
type: "service",
hostname: "web--repo.localhost",
port: 3000,
proxyUrl: "http://web--repo.localhost:6767",
lifecycle: "running",
health: "healthy",
});
expect(parsed.localProxyUrl).toBeUndefined();
expect(parsed.publicProxyUrl).toBeUndefined();
expect(parsed.proxyUrl).toBe("http://web--repo.localhost:6767");
});
test("parses workspace service payloads with split local and public proxy URLs", () => {
const parsed = WorkspaceScriptPayloadSchema.parse({
scriptName: "web",
type: "service",
hostname: "web--repo.localhost",
port: 3000,
localProxyUrl: "http://web--repo.localhost:6767",
publicProxyUrl: "https://web--repo.services.example.com",
proxyUrl: "https://web--repo.services.example.com",
lifecycle: "running",
health: "healthy",
});
expect(parsed.localProxyUrl).toBe("http://web--repo.localhost:6767");
expect(parsed.publicProxyUrl).toBe("https://web--repo.services.example.com");
expect(parsed.proxyUrl).toBe("https://web--repo.services.example.com");
});
test("defaults omitted workspace script proxyUrl to null", () => {
const parsed = WorkspaceScriptPayloadSchema.parse({
scriptName: "typecheck",
type: "script",
hostname: "typecheck",
port: null,
lifecycle: "stopped",
health: null,
});
expect(parsed.proxyUrl).toBeNull();
});
test("parses workspace_setup_progress payload", () => {
const parsed = SessionOutboundMessageSchema.parse({
type: "workspace_setup_progress",