feat(vscode-ide-companion): 新增共享 UI 组件 FileLink

- 新增 FileLink 组件用于显示文件链接
- 更新 LayoutComponents 增加通用布局组件
- 新增 utils.ts 提供工具函数

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
yiliang114
2025-11-21 01:51:50 +08:00
parent 9ba99177b9
commit 1eedd36542
4 changed files with 299 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
*/
import type React from 'react';
import { FileLink } from '../../shared/FileLink.js';
/**
* Props for ToolCallCard wrapper
@@ -20,11 +21,11 @@ interface ToolCallCardProps {
* Main card wrapper with icon
*/
export const ToolCallCard: React.FC<ToolCallCardProps> = ({
icon,
icon: _icon,
children,
}) => (
<div className="tool-call-card">
<div className="tool-call-icon">{icon}</div>
{/* <div className="tool-call-icon">{icon}</div> */}
<div className="tool-call-grid">{children}</div>
</div>
);
@@ -95,15 +96,12 @@ interface LocationsListProps {
}
/**
* List of file locations
* List of file locations with clickable links
*/
export const LocationsList: React.FC<LocationsListProps> = ({ locations }) => (
<>
<div className="locations-list">
{locations.map((loc, idx) => (
<div key={idx}>
{loc.path}
{loc.line !== null && loc.line !== undefined && `:${loc.line}`}
</div>
<FileLink key={idx} path={loc.path} line={loc.line} showFullPath={true} />
))}
</>
</div>
);

View File

@@ -76,6 +76,41 @@ export const getKindIcon = (kind: string): string => {
export const shouldShowToolCall = (kind: string): boolean =>
!kind.includes('internal');
/**
* Check if a tool call has actual output to display
* Returns false for tool calls that completed successfully but have no visible output
*/
export const hasToolCallOutput = (
toolCall: import('./types.js').ToolCallData,
): boolean => {
// Always show failed tool calls (even without content)
if (toolCall.status === 'failed') {
return true;
}
// Show if there are locations (file paths)
if (toolCall.locations && toolCall.locations.length > 0) {
return true;
}
// Show if there is content
if (toolCall.content && toolCall.content.length > 0) {
const grouped = groupContent(toolCall.content);
// Has any meaningful content?
if (
grouped.textOutputs.length > 0 ||
grouped.errors.length > 0 ||
grouped.diffs.length > 0 ||
grouped.otherData.length > 0
) {
return true;
}
}
// No output, don't show
return false;
};
/**
* Group tool call content by type to avoid duplicate labels
*/