mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
- 新增 InProgressToolCall 组件用于展示进行中的工具调用状态 - 重构 InputForm 为独立组件,提升代码可维护性 - 改进 tool_call_update 处理逻辑,支持创建缺失的初始工具调用 - 添加思考块(thought chunk)日志以便调试 AI 思维过程 - 更新样式以支持新的进行中工具调用卡片显示 - 在权限请求时自动创建对应的工具调用记录 ```
101 lines
2.4 KiB
TypeScript
101 lines
2.4 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Qwen Team
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* In-progress tool call component - displays active tool calls with Claude Code style
|
|
*/
|
|
|
|
import type React from 'react';
|
|
import type { ToolCallData } from './toolcalls/shared/types.js';
|
|
import { FileLink } from './shared/FileLink.js';
|
|
|
|
interface InProgressToolCallProps {
|
|
toolCall: ToolCallData;
|
|
}
|
|
|
|
/**
|
|
* Format the kind name to a readable label
|
|
*/
|
|
const formatKind = (kind: string): string => {
|
|
const kindMap: Record<string, string> = {
|
|
read: 'Read',
|
|
write: 'Write',
|
|
edit: 'Edit',
|
|
execute: 'Execute',
|
|
bash: 'Execute',
|
|
command: 'Execute',
|
|
search: 'Search',
|
|
grep: 'Search',
|
|
glob: 'Search',
|
|
find: 'Search',
|
|
think: 'Think',
|
|
thinking: 'Think',
|
|
fetch: 'Fetch',
|
|
delete: 'Delete',
|
|
move: 'Move',
|
|
};
|
|
|
|
return kindMap[kind.toLowerCase()] || 'Tool Call';
|
|
};
|
|
|
|
/**
|
|
* Get status display text
|
|
*/
|
|
const getStatusText = (status: string): string => {
|
|
const statusMap: Record<string, string> = {
|
|
pending: 'Pending',
|
|
in_progress: 'In Progress',
|
|
completed: 'Completed',
|
|
failed: 'Failed',
|
|
};
|
|
|
|
return statusMap[status] || status;
|
|
};
|
|
|
|
/**
|
|
* Component to display in-progress tool calls with Claude Code styling
|
|
* Shows kind, status, and file locations
|
|
*/
|
|
export const InProgressToolCall: React.FC<InProgressToolCallProps> = ({
|
|
toolCall,
|
|
}) => {
|
|
const { kind, status, title, locations } = toolCall;
|
|
|
|
// Format the kind label
|
|
const kindLabel = formatKind(kind);
|
|
|
|
// Get status text
|
|
const statusText = getStatusText(status || 'in_progress');
|
|
|
|
return (
|
|
<div className="in-progress-tool-call">
|
|
<div className="in-progress-tool-call-header">
|
|
<span className="in-progress-tool-call-kind">{kindLabel}</span>
|
|
<span
|
|
className={`in-progress-tool-call-status ${status || 'in_progress'}`}
|
|
>
|
|
{statusText}
|
|
</span>
|
|
</div>
|
|
|
|
{title && title !== kindLabel && (
|
|
<div className="in-progress-tool-call-title">{title}</div>
|
|
)}
|
|
|
|
{locations && locations.length > 0 && (
|
|
<div className="in-progress-tool-call-locations">
|
|
{locations.map((loc, idx) => (
|
|
<FileLink
|
|
key={idx}
|
|
path={loc.path}
|
|
line={loc.line}
|
|
showFullPath={false}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|