Skip to content

feat: prefix the project name on environment display labels - #229

Merged
nicknisi merged 3 commits into
mainfrom
nicknisi/project-prefixed-env-names
Aug 26, 2026
Merged

feat: prefix the project name on environment display labels#229
nicknisi merged 3 commits into
mainfrom
nicknisi/project-prefixed-env-names

Conversation

@nicknisi

Copy link
Copy Markdown
Member

Follow-up to #228.

Why

Teams can hold multiple projects, and environment names are only unique per project — two projects can each have a Staging. Everywhere the CLI prints a bare environment name (profile list, the picker, environment use confirmations), that name is ambiguous exactly when disambiguation matters.

What

Environment labels are now Project > Environment:

    Name        Type      Endpoint   Environment
    staging     Sandbox   default    Nick's Team's Project > test12
▸   staging-3   Sandbox   default    cli-branding-smoke > Staging
  • projectName is stored on profiles alongside environmentName, captured by every resolution path (login clientId join, picker, healing, environment use) and healed the same way — existing profiles backfill on the next environment-scoped command with no migration
  • Applied to: profile list (table + --json field), the profile switch hint, the environment picker labels, and the environment use confirmation (human + --json)
  • environment list is unchanged — it already has a dedicated Project column
  • New formatEnvironmentLabel() shared by the TeamEnvironment-shaped call sites

Verification

  • 2707 tests passing (3 new), typecheck clean
  • Live against a real two-project team: labels render project-prefixed, heal backfilled projectName onto pre-existing profiles, environment use round-trip confirmed

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown

Greptile Summary

The PR disambiguates environment display labels by prefixing environment names with their owning project and persists that project metadata on local profiles.

  • Maps each fetched environment to its owning project name.
  • Persists and opportunistically heals projectName alongside environment IDs and names.
  • Uses project-prefixed labels in profile listings, pickers, switch hints, and environment-use output.
  • Adds regression coverage that passes a project-bearing GraphQL response through profile resolution.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/lib/environment-target.ts Correctly maps project ownership onto environments, propagates it through profile resolution and healing, and centralizes project-prefixed labels.
src/lib/environment-target.spec.ts Adds the requested end-to-end regression coverage proving that a project name from the GraphQL response reaches the stored profile.
src/lib/config-store.ts Extends persisted environment profiles and no-op write detection to include project names.
src/commands/environment.ts Persists the selected project name and includes the disambiguated label and structured project field in environment-use output.
src/commands/env.ts Displays project-prefixed environment labels and exposes the stored project name in JSON profile listings.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Team projects response] --> B[Map environments with owning projectName]
    B --> C[Resolve or select environment]
    C --> D[Persist environmentId, environmentName, and projectName]
    D --> E[Format Project > Environment]
    E --> F[Profile list, switch hint, picker, and use confirmation]
Loading

Reviews (3): Last reviewed commit: "test: cover the GraphQL project-name map..." | Re-trigger Greptile

Comment thread src/lib/environment-target.spec.ts
nicknisi added a commit that referenced this pull request Aug 25, 2026
The formatter tests passed projectName directly, leaving the actual
fetchTeamEnvironments project->environment copy uncovered — a regression
there would keep the formatter tests green while labels went ambiguous
and profiles stopped backfilling projectName. Feed a project-name-bearing
teamProjectsV2 response through tryResolveProfileEnvironmentId and assert
the name persists onto the profile.

Addresses PR #229 review.
Teams can hold multiple projects, and environment names are only unique
per project — two projects can each have a 'Staging'. Bare names are
ambiguous exactly where profiles/pickers try to disambiguate.

- store projectName on profiles alongside environmentName, captured and
  healed by every resolution path (login join, picker, healing, use)
- display 'Project > Environment' in profile list, the profile switch
  hint, the environment picker, and the environment use confirmation
- profile list --json gains projectName per profile; environment use
  --json gains projectName in its payload
- shared formatEnvironmentLabel() for TeamEnvironment-shaped call sites
The formatter tests passed projectName directly, leaving the actual
fetchTeamEnvironments project->environment copy uncovered — a regression
there would keep the formatter tests green while labels went ambiguous
and profiles stopped backfilling projectName. Feed a project-name-bearing
teamProjectsV2 response through tryResolveProfileEnvironmentId and assert
the name persists onto the profile.

Addresses PR #229 review.
@nicknisi
nicknisi force-pushed the nicknisi/project-prefixed-env-names branch from a629031 to 184f4ae Compare August 26, 2026 19:18
@nicknisi
nicknisi merged commit cc51696 into main Aug 26, 2026
5 checks passed
@nicknisi
nicknisi deleted the nicknisi/project-prefixed-env-names branch August 26, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant