feat(chat): unify reasoning and tool call visibility

This commit is contained in:
lc6464 2026-04-26 00:50:18 +08:00
parent 6d04d15ce0
commit 303ff8137d
No known key found for this signature in database
GPG key ID: 53C61B42FEC71D6D
4 changed files with 18 additions and 12 deletions

View file

@ -23,7 +23,7 @@ import { usePicoChat } from "@/hooks/use-pico-chat"
import { useSessionHistory } from "@/hooks/use-session-history" import { useSessionHistory } from "@/hooks/use-session-history"
import type { ConnectionState } from "@/store/chat" import type { ConnectionState } from "@/store/chat"
import type { ChatAttachment } from "@/store/chat" import type { ChatAttachment } from "@/store/chat"
import { showThoughtsAtom } from "@/store/chat" import { showAssistantDetailsAtom } from "@/store/chat"
import type { GatewayState } from "@/store/gateway" import type { GatewayState } from "@/store/gateway"
const MAX_IMAGE_SIZE_BYTES = 7 * 1024 * 1024 const MAX_IMAGE_SIZE_BYTES = 7 * 1024 * 1024
@ -112,7 +112,9 @@ export function ChatPage() {
const [hasScrolled, setHasScrolled] = useState(false) const [hasScrolled, setHasScrolled] = useState(false)
const [input, setInput] = useState("") const [input, setInput] = useState("")
const [attachments, setAttachments] = useState<ChatAttachment[]>([]) const [attachments, setAttachments] = useState<ChatAttachment[]>([])
const [showThoughts, setShowThoughts] = useAtom(showThoughtsAtom) const [showAssistantDetails, setShowAssistantDetails] = useAtom(
showAssistantDetailsAtom,
)
const { const {
messages, messages,
@ -271,12 +273,12 @@ export function ChatPage() {
> >
<div className="border-border/60 hidden items-center gap-2 rounded-lg border px-3 py-1.5 sm:flex"> <div className="border-border/60 hidden items-center gap-2 rounded-lg border px-3 py-1.5 sm:flex">
<span className="text-muted-foreground text-sm"> <span className="text-muted-foreground text-sm">
{t("chat.showThoughts")} {t("chat.showAssistantDetails")}
</span> </span>
<Switch <Switch
checked={showThoughts} checked={showAssistantDetails}
onCheckedChange={setShowThoughts} onCheckedChange={setShowAssistantDetails}
aria-label={t("chat.showThoughts")} aria-label={t("chat.showAssistantDetails")}
size="sm" size="sm"
/> />
</div> </div>
@ -323,7 +325,10 @@ export function ChatPage() {
)} )}
{messages.map((msg) => { {messages.map((msg) => {
if (msg.kind === "thought" && !showThoughts) { if (
!showAssistantDetails &&
(msg.kind === "thought" || msg.kind === "tool_calls")
) {
return null return null
} }

View file

@ -63,7 +63,7 @@
"toolCallsLabel": "Tool calls", "toolCallsLabel": "Tool calls",
"toolCallExplanationLabel": "Call note", "toolCallExplanationLabel": "Call note",
"toolCallFunctionLabel": "Call summary", "toolCallFunctionLabel": "Call summary",
"showThoughts": "Show reasoning", "showAssistantDetails": "Show reasoning and tool calls",
"toolLabel": "Tool", "toolLabel": "Tool",
"history": "History", "history": "History",
"noHistory": "No chat history yet", "noHistory": "No chat history yet",

View file

@ -63,7 +63,7 @@
"toolCallsLabel": "工具调用", "toolCallsLabel": "工具调用",
"toolCallExplanationLabel": "调用提示", "toolCallExplanationLabel": "调用提示",
"toolCallFunctionLabel": "调用摘要", "toolCallFunctionLabel": "调用摘要",
"showThoughts": "展示思考过程", "showAssistantDetails": "展示思考过程与工具调用",
"toolLabel": "工具", "toolLabel": "工具",
"history": "历史记录", "history": "历史记录",
"noHistory": "暂无对话历史", "noHistory": "暂无对话历史",

View file

@ -65,7 +65,8 @@ export interface ChatStoreState {
type ChatStorePatch = Partial<ChatStoreState> type ChatStorePatch = Partial<ChatStoreState>
const SHOW_THOUGHTS_STORAGE_KEY = "picoclaw:chat-show-thoughts" // Keep the legacy storage value so existing user preferences survive the rename.
const SHOW_ASSISTANT_DETAILS_STORAGE_KEY = "picoclaw:chat-show-thoughts"
const DEFAULT_CHAT_STATE: ChatStoreState = { const DEFAULT_CHAT_STATE: ChatStoreState = {
messages: [], messages: [],
@ -76,8 +77,8 @@ const DEFAULT_CHAT_STATE: ChatStoreState = {
} }
export const chatAtom = atom<ChatStoreState>(DEFAULT_CHAT_STATE) export const chatAtom = atom<ChatStoreState>(DEFAULT_CHAT_STATE)
export const showThoughtsAtom = atomWithStorage<boolean>( export const showAssistantDetailsAtom = atomWithStorage<boolean>(
SHOW_THOUGHTS_STORAGE_KEY, SHOW_ASSISTANT_DETAILS_STORAGE_KEY,
true, true,
) )