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

未关闭 适合新手
#35,357 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react, typescript, vite
领域
frontend, web-dev

调研方向

阅读 apps/web/src/components/settings/SettingInheritance.tsx,重点查看 formatValue 和 settingInheritanceLayers,然后将现有标签处理方式与 BranchNamingSettings.tsx、runtimeModeConfig.ts 和 SettingsPanels.tsx 中的控件进行比较。Issue 提供了一个复现脚本以及 SettingInheritance.test.ts 中的相关测试,作为起点。完成标准是所有继承层都为这三个设置显示对应的标签,同时保持现有标签情况和自由文本不变。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
24.8k
派生
6.4k
平均合并
4 小时 16 分钟
30 天内合并 PR
352

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pingdotgg/t3code 的其他 Issue

查看 pingdotgg/t3code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。