[Bug]: Settings inheritance popover shows raw slugs for branch naming, default permissions and response streaming

Aperta Adatta ai principianti
#35,357 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript, vite
Ambito
frontend, web-dev

Direzione di ricerca

Leggi apps/web/src/components/settings/SettingInheritance.tsx, in particolare formatValue e settingInheritanceLayers, quindi confronta la gestione attuale delle etichette con i controlli in BranchNamingSettings.tsx, runtimeModeConfig.ts e SettingsPanels.tsx. L’issue fornisce uno script di riproduzione e i test correlati in SettingInheritance.test.ts come punti di partenza. Il lavoro è completo quando tutti i livelli di ereditarietà mostrano le etichette corrispondenti per le tre impostazioni, lasciando invariati i casi di etichette esistenti e il testo libero.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/web

Steps to reproduce

From the top-level checkout of the commit under Version or commit, with its locked dependencies installed, run the script below with env -u NODE_ENV sh repro.sh. It writes a temporary vitest file beside SettingInheritance.tsx, calls the exported settingInheritanceLayers (the function the popover renders) with an environment value and a project override for each key, records each layer's displayed value, and deletes the temporary file on exit. It asserts that the fixed keys show labels and that the three mode keys show slugs, so it exits 0 while the defect is present. In the app: open Settings, find Worktree branch naming (or Default permissions, or Response streaming), and open the row's inheritance popover.

Reproduction script: repro.sh
#!/bin/sh
# Run from the top-level checkout with locked dependencies installed: env -u NODE_ENV sh repro.sh
set -eu
checkout=$PWD
tmp=$(mktemp -d)
test_file="$checkout/apps/web/src/components/settings/inheritanceLabelsRepro.tmp.test.ts"
trap 'rm -f "$test_file"; rm -rf "$tmp"' EXIT HUP INT TERM
cat > "$test_file" <<'TS'
import { writeFileSync } from "node:fs";
import { DEFAULT_SERVER_SETTINGS, EnvironmentId, ProjectId } from "@t3tools/contracts";
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
import { expect, it } from "vite-plus/test";

import { settingInheritanceLayers } from "./SettingInheritance";

const environmentId = EnvironmentId.make("laptop");
const projectId = ProjectId.make("project");

function layers(key: string, environment: Record<string, unknown>, project: Record<string, unknown>) {
  const settings = {
    ...DEFAULT_SERVER_SETTINGS,
    ...environment,
    projectSettingsOverrides: { [projectId]: project },
  } as never;
  return Object.fromEntries(
    settingInheritanceLayers(
      { environmentId, label: "Laptop", projectId, ...resolveProjectSettings(settings, projectId) },
      settings,
      key as never,
    ).map((layer) => [layer.key, layer.value]),
  );
}

it("records the popover's layer values", () => {
  const rows = {
    // Keys whose popover values are not labelled.
    branchNamingMode: layers("branchNamingMode", { branchNamingMode: "semantic" }, { branchNamingMode: "custom" }),
    defaultRuntimeMode: layers("defaultRuntimeMode", { defaultRuntimeMode: "auto-accept-edits" }, { defaultRuntimeMode: "approval-required" }),
    responseStreamingMode: layers("responseStreamingMode", { responseStreamingMode: "turn" }, { responseStreamingMode: "paragraph" }),
    // Controls: keys whose labels #23450 and #23678 fixed, and a key formatValue already labels.
    worktreeCleanup: layers("worktreeCleanup", { worktreeCleanup: { mode: "custom", rules: DEFAULT_SERVER_SETTINGS.storageCleanup } }, { worktreeCleanup: { mode: "off" } }),
    backgroundActivity: layers("backgroundActivity", { backgroundActivity: { schemaVersion: 1, profile: "performance", overrides: {} } }, {}),
    worktreeSubmodules: layers("worktreeSubmodules", { worktreeSubmodules: "recursive" }, {}),
  };
  writeFileSync(process.env.REPRO_RESULT!, JSON.stringify(rows, null, 2));
  // Controls show labels.
  expect(rows.worktreeCleanup).toMatchObject({ project: "Off", environment: "Custom" });
  expect(rows.backgroundActivity).toMatchObject({ environment: "Performance", "built-in": "Balanced" });
  expect(rows.worktreeSubmodules).toMatchObject({ environment: "Recursive" });
  // Current defect: the three mode settings show storage slugs on every layer.
  expect(rows.branchNamingMode).toEqual({ project: "custom", environment: "semantic", "built-in": "static" });
  expect(rows.defaultRuntimeMode).toEqual({ project: "approval-required", environment: "auto-accept-edits", "built-in": "full-access" });
  expect(rows.responseStreamingMode).toEqual({ project: "paragraph", environment: "turn", "built-in": "paragraph" });
});
TS
cd "$checkout/apps/web"
if env -u NODE_ENV REPRO_RESULT="$tmp/result.json" ./node_modules/.bin/vp test run \
  src/components/settings/inheritanceLabelsRepro.tmp.test.ts >"$tmp/log" 2>&1; then
  cat "$tmp/result.json"; echo; echo "DEFECT PRESENT: controls are labelled, the three mode settings show raw slugs"
else
  cat "$tmp/log"; [ -f "$tmp/result.json" ] && cat "$tmp/result.json"; echo "assertions did not match the recorded defect"; exit 1
fi
Expected behavior

Each popover layer should show the same label the setting's own control shows for that value, as it already does for the other enumerated settings in this popover. #23450 established this for background activity profiles (its test expects Performance and Balanced) and #23678 for worktree cleanup modes (its test expects Off and Custom). The labels already exist in the app: MODES in apps/web/src/components/settings/BranchNamingSettings.tsx (static → Static prefix, semantic → Semantic prefix, custom → Custom instructions), runtimeModeConfig in apps/web/src/components/chat/runtimeModeConfig.ts (approval-required → Supervised, auto-accept-edits → Auto-accept edits, auto → Auto, full-access → Full access) and RESPONSE_STREAMING_MODE_LABELS in apps/web/src/components/settings/SettingsPanels.tsx (turn → Wait for the full response, paragraph → Show finished paragraphs). Each of these rows renders the popover through SettingsRow with serverScoped and settingKeys, and all three keys are in PROJECT_SCOPED_SERVER_SETTING_KEYS, so the popover can show project, environment and built-in layers for each.

Actual behavior

The inheritance popover that settings rows open to show where a value comes from (project override, environment, t3.json, built-in default) prints the stored slug instead of the human label for three mode settings: Worktree branch naming (branchNamingMode), Default permissions (defaultRuntimeMode) and Response streaming (responseStreamingMode). The popover shows semantic, auto-accept-edits and turn while the same row's own select shows Semantic prefix, Auto-accept edits and Wait for the full response. The built-in layer is affected too, so the popover shows static, full-access and paragraph even with untouched defaults. Other keys in the same popover already render labels: formatValue maps defaultThreadEnvMode, worktreeSubmodules, pullRequestMergeMethod and sourceControlWritingStyle, and #23450 and #23678 added labels for backgroundActivity and worktreeCleanup. The popover's choice of winning layer is correct; only its displayed text is wrong.

The script passed on the baseline commit from a clean checkout and left git status with no changes of its own. Its full output is under Logs or stack traces. The controls show labels (Off, Custom, Performance, Balanced, Recursive); branchNamingMode, defaultRuntimeMode and responseStreamingMode show slugs on every layer, including the built-in default:

branchNamingMode       project=custom             environment=semantic           built-in=static
defaultRuntimeMode     project=approval-required  environment=auto-accept-edits  built-in=full-access
responseStreamingMode  project=paragraph          environment=turn               built-in=paragraph
Evidence
  • Expected source: the label assertions added by #23450 and #23678 in apps/web/src/components/settings/SettingInheritance.test.ts, the existing label branches in formatValue (apps/web/src/components/settings/SettingInheritance.tsx lines 47-97), and each row's own select labels (BranchNamingSettings.tsx lines 16-20 and 64-66, ProjectDefaultsSettings.tsx lines 369-372, SettingsPanels.tsx lines 120-123 and 1990-1994).
  • Failure source: the reproduction output under Logs or stack traces, produced by the exported settingInheritanceLayers; formatValue returns the raw string at line 81 for any string key without a label branch, and settingInheritanceLayers uses it for the project, environment, t3.json and built-in layers (lines 110-145) that the popover renders at line 305.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

An earlier, separate run of a similar probe on the same baseline, with only environment overrides, showed the same slugs and the same Recursive control. The rendered popover in a running app was not captured; the reproduction calls the function whose value the popover prints verbatim.

Related

Open PR #28842 (part of a settings redesign stack marked as not ready to merge) adds a runtimeModeConfig label branch for defaultRuntimeMode in formatValue; it does not label branchNamingMode or responseStreamingMode. Merged #23450 (background activity profiles) and #23678 (worktree cleanup modes) fixed the same display problem for those two settings in this function.

Restoration check

With the script's input, the popover layers show Custom instructions, Semantic prefix and Static prefix for branchNamingMode; Supervised, Auto-accept edits and Full access for defaultRuntimeMode; and Show finished paragraphs, Wait for the full response and Show finished paragraphs for responseStreamingMode (project, environment and built-in layers respectively), matching each row's select. The script's slug assertions encode the current defect and fail once it is fixed. The controls keep passing: worktreeCleanup stays Off/Custom, backgroundActivity stays Performance/Balanced, worktreeSubmodules stays Recursive, and free-text project settings such as branchNamePrefix and threadTitleInstructions keep showing their text verbatim.

Impact

Cosmetic issue

Version or commit

T3 Code 0.1.9 at d9805b2ca667be7caec8c9035950564ab96704c3, rerun from a clean checkout. Upstream main at 4fd40e1a16e3800418b8f6a32932b68179098c8d has a byte-identical apps/web/src/components/settings/SettingInheritance.tsx; the script was not rerun there.

Environment

macOS on arm64, Node v26.12.1, vp test run from apps/web; no running app, server or provider needed.

Logs or stack traces

The script's output:

{
  "branchNamingMode": {
    "project": "custom",
    "environment": "semantic",
    "built-in": "static"
  },
  "defaultRuntimeMode": {
    "project": "approval-required",
    "environment": "auto-accept-edits",
    "built-in": "full-access"
  },
  "responseStreamingMode": {
    "project": "paragraph",
    "environment": "turn",
    "built-in": "paragraph"
  },
  "worktreeCleanup": {
    "project": "Off",
    "environment": "Custom",
    "built-in": "Not set"
  },
  "backgroundActivity": {
    "environment": "Performance",
    "built-in": "Balanced"
  },
  "worktreeSubmodules": {
    "project": "Inherits",
    "environment": "Recursive",
    "t3.json": "Inherits",
    "built-in": "Recursive"
  }
}
DEFECT PRESENT: controls are labelled, the three mode settings show raw slugs
Screenshots, recordings, or supporting files

No response

Workaround

Switching the settings scope to the project or environment shows that layer's value as a label in the row's own select, and the slugs map one-to-one onto the labels listed under Expected behavior.

Lingua principale
TypeScript
Stelle
24.8k
Fork
6.4k
Merge medio
4h 16m
PR unite (30g)
352

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pingdotgg/t3code

Tutte le issue di pingdotgg/t3code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.