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

open1
main
GitHub fork: feat/environment-label-override
opened4d agobyZzeroknots
View on GitHubTwo-way sync enabledPR last imported 9h ago

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

sh
1vp test run apps/server/src/environment/ServerEnvironmentLabel.test.ts apps/server/src/environment/ServerEnvironment.test.ts
2vp run check:changed origin/main --concurrency 1
  • Focused resolver/environment suite: 42 passed. Covers absent, empty, ASCII/Unicode-whitespace values, all fallback tiers, Unicode labels, distinct accounts sharing one host, and overrides avoiding host probes.
  • The restart test changes the label and verifies that every other descriptor field, including the persistent environment ID, stays equal.
  • Before implementation and with the override deliberately removed: 7 failed / 35 passed. Restoring it returns the suite to green.
  • Final branch-specific changed-file check: 44 tests across three files passed, plus formatting, lint, both knip phases, generated GraphQL validation, and affected-package typechecks. Duration: 41.362 seconds. Valid repository task-cache results were reused for typechecking.

Verified on Linux with Node 26.13.0, pnpm 12.14.0, and project-pinned Vite+ 1.4.0. The exact Node 26.12.1 runtime and live client/server activation were not exercised. Fork CI remains queued for unassigned inherited Blacksmith runners and is not presented as passing CI. No live T3 instance or credentials were changed.

Model: GPT-6.1 Sol. Harness: Claude Code.

Fixes pingdotgg/t3code#25505

Checks

22 successful · 8 skipped
All checks passed
d4a995a

Added 1 commit

  • feat(server): allow explicit environment display labelsd4a995a
Synced from GitHub

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.

Synced from GitHub

Explain Change →

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

Possibly related issues

  • pingdotgg/t3code#25505 proposes a custom environment label that overrides the macOS ComputerName. This change adds an environment-variable override, but does not address the issue’s separate proposal to add the OS username to the default label.

Possibly related PRs

  • pingdotgg/t3code#27950: This PR also changes resolveServerEnvironmentLabel and adds label-related tests. Both changes add a label source before host probes.

Suggested reviewers: t3dotgg, macroscopeapp, juliusmarminge

Merge Risk: External image Minimal · up to d4a99

The documented restart instruction is clear in context, and no merge-blocking issue is established.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title "feat(server): allow explicit environment display labels" matches the main change. The PR adds optional T3CODE_ENVIRONMENT_LABEL support to the server label resolver, so an operator can set …
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe description covers the problem, the change, scope, and verification. It explains that the option configures an established label capability, identifies what it controls, and states which behavior …
Full details: Title check

Explanation

The title "feat(server): allow explicit environment display labels" matches the main change. The PR adds optional T3CODE_ENVIRONMENT_LABEL support to the server label resolver, so an operator can set a display label for each server environment. The title is short, follows conventional commit style, and names the primary change.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification. It explains that the option configures an established label capability, identifies what it controls, and states which behavior remains unchanged. It also reports test results, limitations, and the model and harness used.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
CcoderabbitaiBotreviewed4d ago
Synced from GitHub
External image Additional comments: 1

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

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

External image 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

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

External image Run configuration

External image Commits

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

External image 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.

Synced from GitHub

+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.