fix: fix broken when SSE

This commit is contained in:
Henry Li
2026-01-16 23:15:53 +08:00
parent facde645d7
commit 34ca58ed1b
3 changed files with 16 additions and 16 deletions

View File

@@ -222,19 +222,16 @@ function ToolCall({
);
} else if (name === "present_files") {
return (
<ChainOfThoughtStep
key={id}
label={`Present file${(args as { filepaths: string[] }).filepaths.length > 1 ? "s" : ""}`}
icon={FileTextIcon}
>
<ChainOfThoughtStep key={id} label="Present files" icon={FileTextIcon}>
<ChainOfThoughtSearchResult>
{(args as { filepaths: string[] }).filepaths.map(
(filepath: string) => (
<ChainOfThoughtSearchResult key={filepath}>
{filepath}
</ChainOfThoughtSearchResult>
),
)}
{Array.isArray((args as { filepaths: string[] }).filepaths) &&
(args as { filepaths: string[] }).filepaths.map(
(filepath: string) => (
<ChainOfThoughtSearchResult key={filepath}>
{filepath}
</ChainOfThoughtSearchResult>
),
)}
</ChainOfThoughtSearchResult>
</ChainOfThoughtStep>
);
@@ -344,7 +341,7 @@ function describeStep(step: CoTStep | undefined): {
label = "Execute command";
icon = <SquareTerminalIcon className="size-4" />;
} else if (step.name === "present_files") {
label = `Present file${(step.args as { filepaths: string[] }).filepaths.length > 1 ? "s" : ""}`;
label = "Present files";
icon = <FileTextIcon className="size-4" />;
} else {
label = `Call tool "${step.name}"`;

View File

@@ -12,7 +12,7 @@ import { getFileExtension, getFileName } from "@/core/utils/files";
export function PresentFileList({ files }: { files: string[] }) {
return (
<ul className="w-full">
<ul className="flex w-full flex-col gap-4">
{files.map((file) => (
<Card key={file}>
<CardHeader>

View File

@@ -159,9 +159,12 @@ export function extractPresentFilesFromMessage(message: Message) {
if (message.type !== "ai" || !hasPresentFiles(message)) {
return [];
}
const files = [];
const files: string[] = [];
for (const toolCall of message.tool_calls ?? []) {
if (toolCall.name === "present_files") {
if (
toolCall.name === "present_files" &&
Array.isArray(toolCall.args.filepaths)
) {
files.push(...(toolCall.args.filepaths as string[]));
}
}