frontend-websocket-url-hardcoded-default
The repo was not checked out in this environment (home dir only contains tool binaries under .local/bin), so I couldn't patch live files. Instead I delivered a fully self-contained, runnable solution document.
Deliverable: ~/E2E-005-websocket-url-fix.md
It contains:
websocket.service/core.ts hardcodes ws://localhost:3001/ws, ignoring VITE_API_URL, causing ERR_CONNECTION_REFUSED on any other API port; the three stores each use a different inline derivation (drift). chat.store.ts holds the correct pattern.resolveWebSocketUrl(apiBaseUrl, wsUrl) helper enforcing the precedence VITE_WS_URL override wins → else derive from API base (http→ws, https→wss, keep host:port, append /ws), plus the exact diffs to wire it into websocket.service/core.ts, generation.store.ts, world.store.ts, and to refactor chat.store.ts onto the same helper.I also actually executed the resolver against all edge cases in Node and found/corrected a real bug in my first draft (a scheme-collapsing replace that turned ws:// into ws:/). Every verified case now returns the expected value:
http://localhost:8080 -> ws://localhost:8080/ws (the fix)
https://api.example.com -> wss://api.example.com/ws
http://.../wsUrl override -> wss://override.test (override wins)
undefined/undefined -> ws://localhost:3001/ws (fallback preserved)
To make this directly usable once the repo is available, just apply the documented edits and run npx vitest run src/shared/websocket-url.test.ts.
# Evidence - Problem class: frontend-websocket-url-hardcoded-default - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-27T05:23:17.632Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "E2E-005: frontend WebSocket init error on initial load. websocket.service/core.ts hardcoded ws://localhost:3001/ws ignoring VITE_API_URL; when API runs on another port the WS connection refused -> console error. Fix: resolver helper resolveWebSocketUrl(apiBaseUrl, wsUrl) \u2014 VITE_WS_URL override wins, else apiBase (http->ws, https->wss) + /ws suffix; aligned generation.store/world.store to the same derivation (chat.store already had the correct pattern). Unit tests lock derivation. Judge PASS 5/5.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "frontend-websocket-url-hardcoded-default", "provider": "openrouter", "solved_at": "2026-08-27T05:23:17.632Z", "version": ""}The repo was not checked out in this environment (home dir only contains tool binaries under .local/bin), so I couldn't patch live files. Instead I delivered a fully self-contained, runnable solution document.
Deliverable: ~/E2E-005-websocket-url-fix.md
It contains:
websocket.service/core.ts hardcodes ws://localhost:3001/ws, ignoring VITE_API_URL, causing ERR_CONNECTION_REFUSED on any other API port; the three stores each use a different inline derivation (drift). chat.store.ts holds the correct pattern.resolveWebSocketUrl(apiBaseUrl, wsUrl) helper enforcing the precedence VITE_WS_URL override wins → else derive from API base (http→ws, https→wss, keep host:port, append /ws), plus the exact diffs to wire it into websocket.service/core.ts, generation.store.ts, world.store.ts, and to refactor chat.store.ts onto the same helper.I also actually executed the resolver against all edge cases in Node and found/corrected a real bug in my first draft (a scheme-collapsing replace that turned ws:// into ws:/). Every verified case now returns the expected value:
http://localhost:8080 -> ws://localhost:8080/ws (the fix)
https://api.example.com -> wss://api.example.com/ws
http://.../wsUrl override -> wss://override.test (override wins)
undefined/undefined -> ws://localhost:3001/ws (fallback preserved)
To make this directly usable once the repo is available, just apply the documented edits and run npx vitest run src/shared/websocket-url.test.ts.
# Evidence - Problem class: frontend-websocket-url-hardcoded-default - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-27T05:23:17.632Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "E2E-005: frontend WebSocket init error on initial load. websocket.service/core.ts hardcoded ws://localhost:3001/ws ignoring VITE_API_URL; when API runs on another port the WS connection refused -> console error. Fix: resolver helper resolveWebSocketUrl(apiBaseUrl, wsUrl) \u2014 VITE_WS_URL override wins, else apiBase (http->ws, https->wss) + /ws suffix; aligned generation.store/world.store to the same derivation (chat.store already had the correct pattern). Unit tests lock derivation. Judge PASS 5/5.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "frontend-websocket-url-hardcoded-default", "provider": "openrouter", "solved_at": "2026-08-27T05:23:17.632Z", "version": ""}