feat: refine mindspace asset card actions
This commit is contained in:
@@ -39,14 +39,6 @@ function CheckIcon() {
|
||||
);
|
||||
}
|
||||
|
||||
function ToolSpinnerIcon() {
|
||||
return (
|
||||
<span className="tool-badge-spinner" aria-hidden="true">
|
||||
<span />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function ToolDoneIcon() {
|
||||
return (
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
@@ -61,6 +53,16 @@ function ToolDoneIcon() {
|
||||
);
|
||||
}
|
||||
|
||||
function resolveToolCallName(
|
||||
tool: Extract<Message['content'][number], { type: 'toolRequest' }>,
|
||||
): string {
|
||||
const toolCall = tool.toolCall as {
|
||||
functionName?: string;
|
||||
value?: { name?: string };
|
||||
};
|
||||
return String(toolCall.functionName ?? toolCall.value?.name ?? '').trim();
|
||||
}
|
||||
|
||||
function ToolBadge({ message }: { message: Message }) {
|
||||
const tools = message.content.filter((c) => c.type === 'toolRequest' || c.type === 'toolResponse');
|
||||
if (tools.length === 0) return null;
|
||||
@@ -72,7 +74,7 @@ function ToolBadge({ message }: { message: Message }) {
|
||||
<div className="tool-badges">
|
||||
{tools.map((tool, i) => {
|
||||
const isRequest = tool.type === 'toolRequest';
|
||||
const toolName = isRequest ? String(tool.toolCall.functionName ?? '').trim() : '';
|
||||
const toolName = isRequest ? resolveToolCallName(tool) : '';
|
||||
|
||||
let label: string;
|
||||
if (isRequest && !toolName) {
|
||||
@@ -86,7 +88,7 @@ function ToolBadge({ message }: { message: Message }) {
|
||||
key={`${message.id}-${i}`}
|
||||
className={`tool-badge${isRequest ? ' is-pending' : ' is-complete'}`}
|
||||
>
|
||||
{isRequest ? <ToolSpinnerIcon /> : <ToolDoneIcon />}
|
||||
{!isRequest ? <ToolDoneIcon /> : null}
|
||||
<span>{label}</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user