Files
claude-code/src/components/messages/AssistantThinkingMessage.tsx
claude-code-best ae7b92f673 style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files)
纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-04 22:49:52 +08:00

67 lines
1.5 KiB
TypeScript

import type {
ThinkingBlock,
ThinkingBlockParam,
} from '@anthropic-ai/sdk/resources/index.mjs'
import React from 'react'
import { Box, Text } from '../../ink.js'
import { CtrlOToExpand } from '../CtrlOToExpand.js'
import { Markdown } from '../Markdown.js'
type Props = {
// Accept either full ThinkingBlock/ThinkingBlockParam or a minimal shape with just type and thinking
param:
| ThinkingBlock
| ThinkingBlockParam
| { type: 'thinking'; thinking: string }
addMargin: boolean
isTranscriptMode: boolean
verbose: boolean
/** When true, hide this thinking block entirely (used for past thinking in transcript mode) */
hideInTranscript?: boolean
}
export function AssistantThinkingMessage({
param: { thinking },
addMargin = false,
isTranscriptMode,
verbose,
hideInTranscript = false,
}: Props): React.ReactNode {
if (!thinking) {
return null
}
if (hideInTranscript) {
return null
}
const shouldShowFullThinking = isTranscriptMode || verbose
const label = '∴ Thinking'
if (!shouldShowFullThinking) {
return (
<Box marginTop={addMargin ? 1 : 0}>
<Text dimColor italic>
{label} <CtrlOToExpand />
</Text>
</Box>
)
}
return (
<Box
flexDirection="column"
gap={1}
marginTop={addMargin ? 1 : 0}
width="100%"
>
<Text dimColor italic>
{label}
</Text>
<Box paddingLeft={2}>
<Markdown dimColor>{thinking}</Markdown>
</Box>
</Box>
)
}