feat: add toggle to show/hide thinking and tool call messages

- Add showThinkingAndTools preference to ChatContext (default false, persisted in localStorage)
- Filter thinking and tool_call messages in MessageList based on preference
- Add toggle switch in Settings > Other panel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 18:04:42 +08:00
parent dd13d21c6a
commit cb2fe96a6e
3 changed files with 64 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import type { PromptFile } from "../api/prompts";
import * as settingsApi from "../api/settings";
import { useAvatars } from "../context/AvatarContext";
import { useBootstrap } from "../context/BootstrapContext";
import { useChatContext } from "../context/ChatContext";
import type { AgentToolInfo, EnvironmentInfo, EnvironmentToolsInfo, ExtensionInfo, McpServerInfo, RuntimeInfo, SettingsPaneId, SkillInfo } from "../types/events";
import type { McpToolInfo } from "../types/events";
import { renderMarkdown } from "../utils/markdown";
@@ -309,6 +310,7 @@ function McpToolItem({
export function SettingsPage() {
const { markRouteReady } = useBootstrap();
const { updateAvatars } = useAvatars();
const { showThinkingAndTools, toggleShowThinkingAndTools } = useChatContext();
const [activePane, setActivePane] = useState<SettingsPaneId>("prompt");
const [systemPrompt, setSystemPrompt] = useState("");
const [systemPromptPath, setSystemPromptPath] = useState("");
@@ -1348,6 +1350,23 @@ export function SettingsPage() {
<p className={styles.fieldHint}>
http / https
</p>
<div className={styles.field}>
<span className={styles.fieldLabel}></span>
<label className={styles.skillToggle}>
<input
type="checkbox"
checked={showThinkingAndTools}
onChange={toggleShowThinkingAndTools}
/>
<span className={styles.skillToggleUi} aria-hidden />
<span className={styles.skillToggleLabel}>
{showThinkingAndTools ? "已开启" : "已关闭"}
</span>
</label>
<p className={styles.fieldHint}>
AI
</p>
</div>
</div>
{statusText && activePane === "other" ? (
<div className={`${styles.status} ${statusClass}`}>{statusText}</div>