mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat(chat): unify reasoning and tool call visibility
This commit is contained in:
@@ -23,7 +23,7 @@ import { usePicoChat } from "@/hooks/use-pico-chat"
|
||||
import { useSessionHistory } from "@/hooks/use-session-history"
|
||||
import type { ConnectionState } 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"
|
||||
|
||||
const MAX_IMAGE_SIZE_BYTES = 7 * 1024 * 1024
|
||||
@@ -112,7 +112,9 @@ export function ChatPage() {
|
||||
const [hasScrolled, setHasScrolled] = useState(false)
|
||||
const [input, setInput] = useState("")
|
||||
const [attachments, setAttachments] = useState<ChatAttachment[]>([])
|
||||
const [showThoughts, setShowThoughts] = useAtom(showThoughtsAtom)
|
||||
const [showAssistantDetails, setShowAssistantDetails] = useAtom(
|
||||
showAssistantDetailsAtom,
|
||||
)
|
||||
|
||||
const {
|
||||
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">
|
||||
<span className="text-muted-foreground text-sm">
|
||||
{t("chat.showThoughts")}
|
||||
{t("chat.showAssistantDetails")}
|
||||
</span>
|
||||
<Switch
|
||||
checked={showThoughts}
|
||||
onCheckedChange={setShowThoughts}
|
||||
aria-label={t("chat.showThoughts")}
|
||||
checked={showAssistantDetails}
|
||||
onCheckedChange={setShowAssistantDetails}
|
||||
aria-label={t("chat.showAssistantDetails")}
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
@@ -323,7 +325,10 @@ export function ChatPage() {
|
||||
)}
|
||||
|
||||
{messages.map((msg) => {
|
||||
if (msg.kind === "thought" && !showThoughts) {
|
||||
if (
|
||||
!showAssistantDetails &&
|
||||
(msg.kind === "thought" || msg.kind === "tool_calls")
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"toolCallsLabel": "Tool calls",
|
||||
"toolCallExplanationLabel": "Call note",
|
||||
"toolCallFunctionLabel": "Call summary",
|
||||
"showThoughts": "Show reasoning",
|
||||
"showAssistantDetails": "Show reasoning and tool calls",
|
||||
"toolLabel": "Tool",
|
||||
"history": "History",
|
||||
"noHistory": "No chat history yet",
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"toolCallsLabel": "工具调用",
|
||||
"toolCallExplanationLabel": "调用提示",
|
||||
"toolCallFunctionLabel": "调用摘要",
|
||||
"showThoughts": "展示思考过程",
|
||||
"showAssistantDetails": "展示思考过程与工具调用",
|
||||
"toolLabel": "工具",
|
||||
"history": "历史记录",
|
||||
"noHistory": "暂无对话历史",
|
||||
|
||||
@@ -65,7 +65,8 @@ export interface 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 = {
|
||||
messages: [],
|
||||
@@ -76,8 +77,8 @@ const DEFAULT_CHAT_STATE: ChatStoreState = {
|
||||
}
|
||||
|
||||
export const chatAtom = atom<ChatStoreState>(DEFAULT_CHAT_STATE)
|
||||
export const showThoughtsAtom = atomWithStorage<boolean>(
|
||||
SHOW_THOUGHTS_STORAGE_KEY,
|
||||
export const showAssistantDetailsAtom = atomWithStorage<boolean>(
|
||||
SHOW_ASSISTANT_DETAILS_STORAGE_KEY,
|
||||
true,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user