Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(server): allow explicit environment display labels #32333

Closedzeroknots(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/32333/headopened View on GitHub

zeroknots(GitHub profile, opens in a new tab)commented

Problem

Several T3 servers can run on the same machine, each with a different account, data directory, or purpose. They currently derive their display label from the same host, making otherwise distinct environments difficult to tell apart. Container hostnames can also be opaque or change when a container is recreated even though its persisted T3 identity remains the same.

A server-side label is useful for headless services, containers, and declaratively managed hosts: the operator can name each environment alongside its existing process configuration, without changing the machine's hostname or relying on a manual client-side rename.

Change

Honor optional T3CODE_ENVIRONMENT_LABEL in the existing server label resolver:

  • Trim surrounding whitespace and use a nonblank value before host probes.
  • Preserve the existing friendly-host, hostname, directory, and default fallbacks when unset or blank.
  • Keep the persistent environment ID, network configuration, other descriptor fields, and saved client aliases unchanged.

The background-service guide includes service.env and manual-launch examples. No new CLI flag, wire contract, persistence mechanism, or UI control is introduced.

Scope and approval

This is focused configuration of the established environment-label capability, submitted under the configuration-option route in CONTRIBUTING.md. It does not change product defaults or introduce a new connection or authorization workflow. No separate maintainer feature approval is claimed.

Earlier proposals established the same need. This independently implemented change includes executed tests and the tooling disclosure requested in their closure feedback:

https://github.com/pingdotgg/t3code/pull/13985

https://github.com/pingdotgg/t3code/pull/12559

Verification

Updated at 031ff3adab after merging current main without rebasing. Conflict resolution retains WSL naming and the five-second hostname probe timeout regression test. The restart instruction now clearly says to wait for any running agent work to finish.

  • Blacksmith: vp run check:changed github/main passed format, lint, both knip phases, GraphQL validation, affected-package typechecks, and 48 tests across three existing files.
  • Both focused environment suites passed: 46 tests.
  • Two independent scoped code reviews found no issues on this head.
  • Real Chrome client: automatic hostname before restart; T3CODE_ENVIRONMENT_LABEL=" Build server " shows Build server after restart against the same state.
  • Native mobile and Electron were not exercised; the change uses the existing shared descriptor with no client or wire changes.

automatic hostname before override

trimmed server label after override

Model: gpt-6.1-sol. Harness: Codex through T3 Code.

Fixes pingdotgg/t3code#25505

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at d4a995a

      Macroscope's review found this PR approvable — Adds an optional environment display label while preserving automatic naming when unset or blank. The change affects display metadata, not environment identity or network configuration.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The server now accepts T3CODE_ENVIRONMENT_LABEL as a display-label override. It trims the value and uses the existing fallback sequence when the value is unset or blank. Tests and background-service documentation cover the behavior.

      Changes: Environment label resolution

      Layer / File(s)Summary
      Override resolution and verification
      apps/server/src/environment/ServerEnvironmentLabel.ts, apps/server/src/environment/ServerEnvironmentLabel.test.ts, apps/server/src/environment/ServerEnvironment.test.ts, docs/user/background-service.md
      The resolver returns a trimmed, nonblank T3CODE_ENVIRONMENT_LABEL before running host probes. Tests cover override and fallback behavior and confirm that changing the label does not change other descriptor fields. The documentation explains how to configure the label and how it differs from other environment identifiers.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Feature · Severity of issue fixed: Medium

      Suggested reviewers: notzenco, t3dotgg, juliusmarminge

      Merge Risk: Minimal · up to 031ff

      This adds an optional environment-variable override for the server's display label, with a fallback to the current behavior when it is unset or blank. The change is small and reversible, and no merge-blocking risk was found.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title "feat(server): allow explicit environment display labels" matches the main change: the server now honors an optional T3CODE_ENVIRONMENT_LABEL override in the environment label resolver. It i…
      Linked Issues checkPassedDirectly linked issue [#25505] reports that machine-wide macOS ComputerName gives several user accounts the same environment label. It proposes either a custom label that overrides ComputerName, or ad…
      Out of Scope Changes checkPassedAll changed files relate to the single objective of a per-server environment label override. The code change is limited to ServerEnvironmentLabel.ts, which adds the override check before the existing …
      Description checkPassedThe description follows the repository template closely. It explains the problem (several T3 servers on one machine share a host-derived label, and container hostnames can be opaque or change) and the…
      Full details: Title check

      Explanation

      The title "feat(server): allow explicit environment display labels" matches the main change: the server now honors an optional T3CODE_ENVIRONMENT_LABEL override in the environment label resolver. It is a conventional commit title in plain language and names the scope (server) and the aspect changed.

      Full details: Linked Issues check

      Explanation

      Directly linked issue [#25505] reports that machine-wide macOS ComputerName gives several user accounts the same environment label. It proposes either a custom label that overrides ComputerName, or adding the OS username to the default label. The issue offers these as alternatives, so either one satisfies it. The PR implements the first option. In apps/server/src/environment/ServerEnvironmentLabel.ts, resolveServerEnvironmentLabel now reads T3CODE_ENVIRONMENT_LABEL from HostProcess.Environment, normalizes it, and returns it before any friendly-host, hostname, or directory probe runs. Blank or absent values fall through to the existing fallbacks. The ServerEnvironment.test.ts restart test checks that a changed label leaves the persistent environment ID and other descriptor fields unchanged. The new ServerEnvironmentLabel.test.ts cases cover unset, blank, whitespace-trimmed, Unicode, and fallback-precedence inputs, and check that overrides avoid host probes. The test results are reported by the PR author and were not re-run in this review. The implementation and test code were confirmed by the diff inspection.

      Full details: Out of Scope Changes check

      Explanation

      All changed files relate to the single objective of a per-server environment label override. The code change is limited to ServerEnvironmentLabel.ts, which adds the override check before the existing fallback chain. The test changes in ServerEnvironmentLabel.test.ts and ServerEnvironment.test.ts cover that override and verify that the environment ID and other descriptor fields stay unchanged. The docs/user/background-service.md change documents the new variable for service.env and manual launch. No CLI flag, wire contract, persistence mechanism, or UI control is added, as the PR description states. No change in the reviewed summary lacks a connection to the linked issue objective.

      Full details: Description check

      Explanation

      The description follows the repository template closely. It explains the problem (several T3 servers on one machine share a host-derived label, and container hostnames can be opaque or change) and the change (optional T3CODE_ENVIRONMENT_LABEL honored by the existing resolver, with trimming and unchanged fallbacks). The Scope section explains why this is configuration rather than a new feature, links earlier proposals, and states no separate maintainer approval is claimed. The Verification section lists concrete commands, test counts, a real Chrome before/after check with embedded screenshots, and what was not exercised (native mobile, Electron, exact Node runtime). Minor gaps: the Scope section does not link a maintainer request, and the verification text reports test counts that differ from the PR objectives summary (42 focused tests versus 46 in the description). The template's agent attribution line is present. Most required content is provided.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between def3722faa3695034c03058e6ca73c31db353e7c and 031ff3adab0af981e5cf2ed8dbe74873c7263829.

      Files selected for processing: 4

      • apps/server/src/environment/ServerEnvironment.test.ts
      • apps/server/src/environment/ServerEnvironmentLabel.test.ts
      • apps/server/src/environment/ServerEnvironmentLabel.ts
      • docs/user/background-service.md

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    4. Additional comments: 1

      docs/user/background-service.md-93-94: 1

      93-94: Minor · Maintainability & Code Quality · Quick win

      **Unverified finding** Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

      Fix the broken sentence in the restart instruction.

      The sentence "restart the service after running agent work has finished" is ambiguous. It can be read as "after running agent work". Rewrite it so the restart timing is clear. Restarting interrupts running agent turns, as the earlier text in this file states.

      📝 Proposed fix

      -service, put the variable in `service.env` and restart the service after running
      -agent work has finished. For a server in a terminal:
      +service, put the variable in `service.env`, then restart the service after any
      +running agent work has finished. For a server in a terminal:
      Review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 006d7e38f0485431c314a1afcc39fa823f379092 and d4a995ae5cb456405d5184ed9a67a363dceada0e.

      Files selected for processing: 4

      • apps/server/src/environment/ServerEnvironment.test.ts
      • apps/server/src/environment/ServerEnvironmentLabel.test.ts
      • apps/server/src/environment/ServerEnvironmentLabel.ts
      • docs/user/background-service.md

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    5. +1 for headless hosts. I run t3 serve on several VPS machines. Naming each one in its service environment would be simpler than changing the OS hostname, and the name would survive a rebuild that changes the hostname. This complements a client-side rename (#31948) rather than replacing it: the server label gives every client a good default.

    6. tanstack-source added labelsfeature

    7. +1 from another user with this setup. I have one server with two Linux users, and each one runs its own T3 server over SSH/Tailscale. Since the name comes from the host, both show up as the same name everywhere. Setting the env var per user would give each one its own name at the source, so every client would see the right name without me renaming it on each device. I agree with the earlier comment that this pairs well with #31948.

    8. @healingpro

      I have one server with two Linux users, and each one runs its own T3 server over SSH/Tailscale. Since the name comes from the host, both show up as the same name everywhere.

      Until this lands, there's a workaround that needs no patch, but only for one T3 server per machine. On Linux, T3 already checks the machine's "pretty" hostname before the real hostname (ServerEnvironmentLabel.ts, which reads PRETTY_HOSTNAME from /etc/machine-info). I named my VPS with:

      sudo hostnamectl set-hostname --pretty "My Custom VPS Name"

      After a restart of the T3 service, every client showed "My Custom VPS Name" instead of the provider's srv… hostname. The static hostname stayed the same, so nothing else on the box changed.

      That won't separate your two users, though. The pretty hostname covers the whole machine, so both servers would still show the same name. Your setup needs a per-process setting like T3CODE_ENVIRONMENT_LABEL, which is another reason this PR is worth merging.

    9. This would help our setup too. We run the desktop app's bundled server and a separate background T3 server on the same Linux machine, with different T3 homes. Both appear as complynx-work, so it is hard to tell which environment a task will run in.

      A per-server label override would let us name the desktop environment complynx-work · UI and distinguish it from the background server without changing the machine hostname. We would use this.

      Written by Codex (gpt-6.1-sol/Codex) on behalf of Daniel Drizhuk

    10. Reviewed d4a995a: I found no blocking issue in the label override, fallback behavior, or persistent identity handling. I ran the two focused environment suites; all 42 tests passed.

      One concrete rebase note: against main at 1219f62, git merge-tree reports an add/add conflict only in apps/server/src/environment/ServerEnvironmentLabel.test.ts. Main now contains the regression test falls back to the hostname when hostnamectl never answers, which covers the five-second probe timeout. Please retain that test alongside the new override cases when resolving the conflict. The resolver, restart test, and documentation merge automatically against that main snapshot.

      Written by Codex (gpt-6.1-sol/Codex) on behalf of Daniel Drizhuk

    11. This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

      See the conflict window.

    12. Note

      Written by gpt-6.1-sol on behalf of Maria

      Merged current main without rebasing and resolved the label conflicts while retaining WSL naming, the hostname-probe timeout regression, and the override cases. Clarified the restart instruction raised in review. The PR remains four files, with six resolver lines added against main.

      vp run check:changed github/main passed through Blacksmith: format, lint, knip, GraphQL validation, affected-package typechecks, and 48 tests. Two independent scoped reviews found no issues at 031ff3adab. The real Chrome client shows the trimmed override after restart using the same state; before/after evidence is in the PR body. Native mobile and Electron were not exercised.

    13. github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase

    14. Thanks for this. Main has the change since #39978.

      Main now honors T3CODE_ENVIRONMENT_LABEL before host detection, trims nonblank values, and preserves automatic naming when unset or blank. Compared your resolver implementation, fallback tests, descriptor identity assertions, and configuration examples against the merged resolver and override test; the requested runtime behavior is covered.

      Closing as superseded.

    15. juliusmarminge closed this

Sign in to join this conversation.