feat: support binding dev server to all network interfaces via --host#12
Open
hackxixi wants to merge 2 commits into
Open
feat: support binding dev server to all network interfaces via --host#12hackxixi wants to merge 2 commits into
hackxixi wants to merge 2 commits into
Conversation
- Pass PEAKCODE_HOST and VITE_WS_PORT through turbo globalEnv so child processes (Vite, server) receive the host configuration - Read PEAKCODE_HOST in vite.config.ts to bind Vite's dev server to the configured interface instead of always defaulting to localhost - Inject VITE_WS_PORT when binding to a wildcard address (0.0.0.0 / ::) so the browser can construct the correct WS URL from window.location.hostname + the server port, rather than a hardcoded loopback address - Fix wsTransport.ts fallback URL: was using window.location.port (Vite port 5733) instead of the WS server port (3773), breaking external connections - Add VITE_WS_URL and VITE_WS_PORT to ImportMetaEnv type declarations - Conditionalise hmr.host: pin to localhost for local/Electron paths (BrowserWindow reliability), omit when binding to a wildcard address so remote devices can reach HMR via their own window.location.hostname Usage: bun run dev -- --host 0.0.0.0 Claude-Session: https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC
These errors were introduced by prior commits (gateway / model-channel
changes) and caused bun typecheck to fail on main before this PR.
Turbo's early-exit behaviour hid most of them behind the first failure.
Fixing them here so the codebase passes full typecheck as required by
AGENTS.md.
- anthropicAdapter.ts: narrow error-body via Record<string, unknown>
cast before accessing .error (Property does not exist on
OpenAIChatResponse)
- gateway.ts: add explicit return-type annotation on the flatMap
callback in responsesContentToChatContent (TypeScript inferred the
union too narrowly against the declared parts type)
- http.ts: cast entry to string | undefined after the Array.isArray
guard (ReadonlyArray is not narrowed out by Array.isArray, so TS
kept string | readonly string[] in the else branch)
- _chat.settings.tsx: pass disabled={props.disabled ?? false} to
SecretSlotRow so the value is always boolean, not boolean | undefined
(exactOptionalPropertyTypes incompatibility)
Claude-Session: https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC
Collaborator
❌ Changes RequestedThis PR has merge conflicts with the base branch and cannot be merged as-is. Issues:
Action Required:
Please update and re-request review. |
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.
Summary
--hostsupport tobun run devso the dev server can bind to any network interface (e.g.bun run dev -- --host 0.0.0.0), enabling LAN access from phones/tablets/remote machines.wsTransport.tswhere the WS fallback URL usedwindow.location.port(the Vite web port, 5733) instead of the actual WS server port (3773), breaking external connections.hmr.hostso hot-module reloading works for remote devices (previously pinned tolocalhost, causing HMR to fail on LAN clients).bun typecheckonce the first failure was resolved.Changes
Host binding (5 files):
turbo.json— addPEAKCODE_HOSTandVITE_WS_PORTtoglobalEnvso child processes receive themscripts/dev-runner.ts— computeisWildcardHost; for wildcard binds injectVITE_WS_PORTand clearVITE_WS_URL(browser constructs the URL fromwindow.location.hostname+ port); for explicit hosts setVITE_WS_URLdirectlyapps/web/vite.config.ts— bindserver.hosttoPEAKCODE_HOST; defineVITE_WS_PORT; conditionalisehmr.host(omit for wildcard so remote HMR works, pin tolocalhostfor local/Electron)apps/web/src/wsTransport.ts— fix fallback URL to useVITE_WS_PORTinstead ofwindow.location.portapps/web/src/vite-env.d.ts— declareVITE_WS_URLandVITE_WS_PORTinImportMetaEnvPre-existing typecheck fixes (4 files):
apps/server/src/anthropicAdapter.ts— narrow error-body viaRecord<string, unknown>before accessing.error(didn't exist onOpenAIChatResponse)apps/server/src/gateway.ts— add explicit return-type annotation onflatMapcallback (union inferred too narrowly)apps/server/src/http.ts— castentry as string | undefinedafterArray.isArrayguard (ReadonlyArrayis not narrowed out)apps/web/src/routes/_chat.settings.tsx— passdisabled={props.disabled ?? false}to avoidexactOptionalPropertyTypesmismatchTest plan
bun fmt && bun lint && bun typecheck— all pass (verified locally)bun.lock— zero changes (verified:git diff --stat bun.lockis empty)bun run dev(no flags) still serves onlocalhost:5733bun run dev -- --host 0.0.0.0, openhttp://<LAN_IP>:5733from another device — app loads and WS connects (ws://<LAN_IP>:3773/wsstatus 101)https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC