,
-): string {
- const toolCall = tool.toolCall as {
- functionName?: string;
- value?: { name?: string };
- };
- return String(toolCall.functionName ?? toolCall.value?.name ?? '').trim();
+function ToolBadgeItem({ spinning }: { spinning: boolean }) {
+ return (
+
+
+ 工具调用
+
+ );
}
-function ToolBadge({ message }: { message: Message }) {
+function hasToolActivity(message: Message) {
+ return message.content.some((c) => c.type === 'toolRequest' || c.type === 'toolResponse');
+}
+
+function isToolOnlyAssistantMessage(message: Message) {
+ return (
+ message.role === 'assistant' &&
+ hasToolActivity(message) &&
+ !getDisplayText(message).trim() &&
+ !getThinking(message) &&
+ getImageUrls(message).length === 0
+ );
+}
+
+function ToolBadge({ message, active }: { message: Message; active: boolean }) {
+ if (message.role !== 'assistant') return null;
const tools = message.content.filter((c) => c.type === 'toolRequest' || c.type === 'toolResponse');
if (tools.length === 0) return null;
- const completed = tools.filter((t) => t.type === 'toolResponse').length;
- const total = tools.length;
-
return (
- {tools.map((tool, i) => {
- const isRequest = tool.type === 'toolRequest';
- const toolName = isRequest ? resolveToolCallName(tool) : '';
-
- let label: string;
- if (isRequest && !toolName) {
- label = `正在加载 tools (${completed}/${total})`;
- } else {
- label = isRequest ? toolName : '工具完成';
- }
-
- return (
-
- {!isRequest ? : null}
- {label}
-
- );
- })}
+ {tools.map((tool, i) => (
+
+ ))}
);
}
@@ -198,6 +185,7 @@ function MessageRow({
publishUsername,
sessionId,
compact = false,
+ activeToolMessage = false,
}: {
message: Message;
avatarUrl: string | null;
@@ -208,6 +196,7 @@ function MessageRow({
publishUsername?: string;
sessionId?: string;
compact?: boolean;
+ activeToolMessage?: boolean;
}) {
const [actionsOpen, setActionsOpen] = useState(false);
const rawText = getDisplayText(message);
@@ -224,7 +213,7 @@ function MessageRow({
);
@@ -273,7 +262,7 @@ function MessageRow({
dangerouslySetInnerHTML={{ __html: renderMarkdown(text) }}
/>
)}
-
+
{showActionsToggle && (