Repository navigation
Servers list: show a branch-aware URL extracted from the script's stdout (proxy/tunnel dev servers) #42453
Davidhidalgo
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Dev servers commonly run behind a local reverse proxy that gives them a stable, branch-aware hostname. Examples:
portless(stable*.localhostURLs derived from the git branch), ngrok, cloudflared, local-ssl-proxy, mkcert + custom host.Today the Servers list shows the raw
localhost:<port>of the process T3 Code detected (it reads the actual TCP port the process holds). That's the URL users least want: the whole point of the proxy is thatlocalhost:<port>is an implementation detail, and with branch-aware proxies like portless the stable URL changes per worktree branch — so the detectedlocalhost:<port>doesn't even correspond to the URL the developer actually browses to.The
previewUrlfield already exists and opens "as written" in the in-app browser preview, but:Real example (portless, in a worktree on branch
t3-json-actions):Servers shows
localhost:4696. The URL the developer wants is the one portless already printed:https://t3-json-actions.dashboard-react-qa.localhost.Proposal
Add an optional
serverUrlPattern(regex) toT3ProjectFileScript(int3.jsonand the per-project Actions UI). When set, T3 Code applies it to the stdout of the process the script launches and shows the first match in the Servers list (and uses it as thepreviewUrlwhen no staticpreviewUrlis declared).{ "name": "Dashboard React - qa", "command": "pnpm nx run dashboard-react:serve:qa", "stopOnSettle": true, "serverUrlPattern": "->\\s+(https://[^\\s]+\\.localhost)" }This is branch-aware for free: the proxy prints the already-resolved URL for the current worktree's branch, and T3 Code surfaces it. It's also tool-agnostic — ngrok, cloudflared, local-ssl-proxy all print a resolvable URL; each project picks the pattern that matches its proxy's output.
When unset, today's behavior (show the detected
localhost:<port>) is unchanged. The detected port could stay available as a secondary "raw port" disclosure on the row.Why env-var interpolation in
previewUrlisn't enoughI first considered letting
previewUrlinterpolate env vars (e.g.${PORTLESS_URL}), but it doesn't compose with how proxies actually run:pnpm ...→ which spawnsportless run -- ....PORTLESS_URL=...in vite's environment (its child).So
PORTLESS_URLonly exists in the environment of the grandchild process (vite), not in the environment of the shell process T3 Code launched. Resolving${PORTLESS_URL}at script start would find nothing — the var is defined by a process that hasn't started yet, and inside a child of the script at that. Injecting it into the script command doesn't help either, because the definer (portless) is the script's own child.Reading the grandchild's env is racy, tool-specific, and couples T3 to the process tree. Reading the script's own stdout with a regex is simpler and already sufficient — the proxy prints the resolved URL on a line the project can match.
Smallest useful scope
T3ProjectFileScriptschema gains an optionalserverUrlPattern: string.localhost:<port>when present.t3.jsonfield and the existing Actions editor cover it.Alternatives considered
previewUrlstatic string. Already exists; doesn't handle branch-aware proxies and doesn't affect Servers.All reactions