From 65e79de845e9fcf4e68f7fa412558313a54f7b5b Mon Sep 17 00:00:00 2001
From: Jason
Date: Tue, 6 Oct 2026 09:48:53 +0800
Subject: [PATCH] feat(claude): explain each quick toggle with a help tip
The quick toggles above the Claude config editor had no explanation,
except a native title tooltip on the auto mode one. Put the standard "?"
help tip after each label: one sentence on what the toggle does, why
you would want it, and whether it is global or follows the provider.
Render the toggles from one list so every entry gets the same
checkbox + help layout, with copy under claudeConfig. and
claudeConfig.Help. The help button sits outside the , so
opening the tip never flips the checkbox.
---
.../providers/forms/CommonConfigEditor.tsx | 80 +++++++------------
src/i18n/locales/en.json | 6 +-
src/i18n/locales/ja.json | 6 +-
src/i18n/locales/zh-TW.json | 6 +-
src/i18n/locales/zh.json | 6 +-
tests/components/CommonConfigEditor.test.tsx | 22 +++++
6 files changed, 69 insertions(+), 57 deletions(-)
diff --git a/src/components/providers/forms/CommonConfigEditor.tsx b/src/components/providers/forms/CommonConfigEditor.tsx
index 96224ed25..8d235ab73 100644
--- a/src/components/providers/forms/CommonConfigEditor.tsx
+++ b/src/components/providers/forms/CommonConfigEditor.tsx
@@ -1,11 +1,21 @@
import { useTranslation } from "react-i18next";
import { useEffect, useState, useCallback, useMemo } from "react";
import { Label } from "@/components/ui/label";
+import { HelpTip } from "@/components/ui/help-tip";
import JsonEditor from "@/components/JsonEditor";
import type { ProviderEditorInactiveField } from "@/lib/api/providers";
import { CLAUDE_AUTO_MODE_SERVER_ENV } from "@/utils/claudeEditorOverlay";
import { InactiveFieldsPanel } from "./InactiveFieldsPanel";
+/** 编辑框上方的快捷开关,顺序即显示顺序;文案在 `claudeConfig.` 和 `claudeConfig.Help`。 */
+const QUICK_TOGGLES = [
+ "hideAttribution",
+ "enableToolSearch",
+ "disableAutoUpgrade",
+ "disableArtifact",
+ "disableAutoModeServer",
+] as const;
+
interface CommonConfigEditorProps {
value: string;
onChange: (value: string) => void;
@@ -107,7 +117,7 @@ export function CommonConfigEditor({
}, [localValue]);
const handleToggle = useCallback(
- (toggleKey: string, checked: boolean) => {
+ (toggleKey: (typeof QUICK_TOGGLES)[number], checked: boolean) => {
try {
const config = JSON.parse(localValue || "{}");
@@ -204,58 +214,22 @@ export function CommonConfigEditor({
})}
-
- handleToggle("hideAttribution", e.target.checked)}
- className="ui-checkbox"
- />
- {t("claudeConfig.hideAttribution")}
-
-
- handleToggle("enableToolSearch", e.target.checked)}
- className="ui-checkbox"
- />
- {t("claudeConfig.enableToolSearch")}
-
-
-
- handleToggle("disableAutoUpgrade", e.target.checked)
- }
- className="ui-checkbox"
- />
- {t("claudeConfig.disableAutoUpgrade")}
-
-
- handleToggle("disableArtifact", e.target.checked)}
- className="ui-checkbox"
- />
- {t("claudeConfig.disableArtifact")}
-
-
-
- handleToggle("disableAutoModeServer", e.target.checked)
- }
- className="ui-checkbox"
- />
- {t("claudeConfig.disableAutoModeServer")}
-
+ {QUICK_TOGGLES.map((key) => (
+
+
+ handleToggle(key, e.target.checked)}
+ className="ui-checkbox"
+ />
+ {t(`claudeConfig.${key}`)}
+
+
+ {t(`claudeConfig.${key}Help`)}
+
+
+ ))}
{
expect(JSON.parse(onChange.mock.calls[0][0])).toEqual({});
});
});
+
+describe("CommonConfigEditor quick toggle help", () => {
+ it("gives every toggle a help button that does not toggle it", () => {
+ const onChange = renderEditor("{}");
+
+ for (const key of [
+ "hideAttribution",
+ "enableToolSearch",
+ "disableAutoUpgrade",
+ "disableArtifact",
+ "disableAutoModeServer",
+ ]) {
+ const help = screen.getByRole("button", { name: `claudeConfig.${key}` });
+ expect(help).toHaveAccessibleDescription(`claudeConfig.${key}Help`);
+ fireEvent.click(help);
+ expect(
+ screen.getByRole("checkbox", { name: `claudeConfig.${key}` }),
+ ).not.toBeChecked();
+ }
+ expect(onChange).not.toHaveBeenCalled();
+ });
+});