fix: resolve the workspace WS endpoint from PUBLIC_WS_URL in one place, not sixteen literals - #93
Merged
Merged
Conversation
…UBLIC_WS_URL in one place, not sixteen literals Org Workbench rendered its chrome and nothing else on augment.didi.sh: no roster, no organizations, a red `closed` pill in the corner. The cause was a single line repeated across the app tree — every remote declared `const WS_URL = 'ws://localhost:3001/ws'` and never read the environment, so a deployed surface opened its data socket against the *visitor's* laptop. It could not have worked in production for two independent reasons: the host is wrong, and `ws://` from an `https://` origin is blocked as mixed content. Local dev hid it perfectly, because the operator's machine really is running workspace-service on :3001. Three of the sixteen affected remotes are deployed, which took down the whole Augment-from-DB flow rather than one surface. The endpoint now has exactly one home. `packages/workspace/src/ws-url.ts` exports `resolveWsUrl()` and `resolveHttpBase()`, and `TransportConfig.url` becomes optional — omit it and the transport resolves from PUBLIC_WS_URL on every connect attempt. That is the part that makes the bug structurally unavailable: the failure mode was never a logic error, it was copy-paste into a new remote, and the copy-pasteable thing no longer exists. Every call site was converted, including the two that had quietly got it right (chat, and corpora-curator's real client in curation.svelte.ts) so there is no second pattern to imitate, and the WorkspaceSwitcher tooltip stops telling operators that localhost is unreachable when the endpoint is somewhere else entirely. Verified by building org-workbench with PUBLIC_WS_URL set and reading the emitted bundle: the resolver compiles to the prod endpoint with localhost left only as the dead fallback branch. A new guard in the workspace suite sweeps apps/, shell/, and packages/ for the literal and fails with the offending filenames; planting the old line back into org-workbench makes it fail, so it is not vacuous. svelte-check is clean across all 17 surfaces. Deploy note: PUBLIC_* is baked at build time, so the three deployed remotes need a rebuild, not a restart, once their variables are set. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017HuzSPdPK4QEhs7eztHgoC
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.
Closes #91.
What was broken
Org Workbench rendered its chrome and nothing else on
augment.didi.sh— no roster, no organizations, a redclosedpill. Every remote declaredconst WS_URL = 'ws://localhost:3001/ws'and never read the environment, so a deployed surface opened its data socket against the visitor's laptop.It could not have worked in prod for two independent reasons: wrong host, and
ws://from anhttps://origin is blocked as mixed content. Local dev hid it perfectly, because the operator's machine really is running workspace-service on:3001.Three of the sixteen affected remotes are deployed, so this took down the whole Augment-from-DB flow, not one surface.
The Railway config was already correct — all three services have
PUBLIC_WS_URL=wss://ws.augment.didi.sh/wstoday. The value simply landed where no source line read it. No variable changes are needed.The fix
packages/workspace/src/ws-url.tsexportsresolveWsUrl()/resolveHttpBase(), andTransportConfig.urlbecomes optional — omit it and the transport resolves fromPUBLIC_WS_URLon each connect attempt.That optionality is the part that matters: the failure mode was never a logic error, it was copy-paste into a new remote, and the copy-pasteable thing no longer exists. All 22 call sites were converted, including the two that had quietly got it right (
chat, and corpora-curator's real client incuration.svelte.ts) so there is no second pattern to imitate. TheWorkspaceSwitchertooltip also stops claiming localhost is unreachable when the endpoint is elsewhere.Verification
PUBLIC_WS_URLset; the resolver compiles tofunction d(){let e="wss://ws.augment.didi.sh/ws";return"string"==typeof e&&e.length>0?e:"ws://localhost:3001/ws"}. Prod value inlined, localhost only as the dead fallback branch.apps/,shell/,packages/for the literal and fails with the offending filenames. Planting the old line back into org-workbench makes it fail, so it is not vacuous.svelte-checkclean across all 17 surfaces;@augment-it/workspacesuite 7/7.Deploy note
PUBLIC_*is baked at build time, so after merge the three deployed remotes needrailway redeploy --service <name> --from-source, not a restart:org-workbench,search-and-add,search-results.🤖 Generated with Claude Code
https://claude.ai/code/session_017HuzSPdPK4QEhs7eztHgoC