fix: command.join() is not a function (#270)

* fix: command.join() is not a function

* fix: better typing
This commit is contained in:
Brace Sproul 2025-06-19 12:57:27 -07:00 • committed by GitHub
parent 530c62da40
commit a71f17f1d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 29 deletions

View file

@ -12,6 +12,18 @@ import {
MessageSquare,
FileText,
} from "lucide-react";
import {
createApplyPatchToolFields,
createShellToolFields,
} from "@open-swe/shared/open-swe/tools";
import { z } from "zod";
// Used only for Zod type inference.
const dummyRepo = { owner: "dummy", repo: "dummy" };
const shellTool = createShellToolFields(dummyRepo);
type ShellToolArgs = z.infer<typeof shellTool.schema>;
const applyPatchTool = createApplyPatchToolFields(dummyRepo);
type ApplyPatchToolArgs = z.infer<typeof applyPatchTool.schema>;
// Common props for all action types
type BaseActionProps = {
@ -21,23 +33,23 @@ type BaseActionProps = {
summaryText?: string;
};
// Shell command specific props
type ShellActionProps = BaseActionProps & {
actionType: "shell";
command: string[];
workdir?: string;
output?: string;
errorCode?: number;
};
// Shell command specific props. We need to wrap the args in Partial<...>
// because even though they're required, they may be undefined at a point in time
// due to streaming.
type ShellActionProps = BaseActionProps &
Partial<ShellToolArgs> & {
actionType: "shell";
output?: string;
errorCode?: number;
};
// Apply patch specific props
type PatchActionProps = BaseActionProps & {
actionType: "apply-patch";
file: string;
diff?: string;
errorMessage?: string;
fixedDiff?: string;
};
type PatchActionProps = BaseActionProps &
Partial<ApplyPatchToolArgs> & {
actionType: "apply-patch";
errorMessage?: string;
fixedDiff?: string;
};
// Union type for all possible action props
export type ActionStepProps =
@ -137,14 +149,14 @@ export function ActionStep(props: ActionStepProps) {
</div>
)}
<code className="text-foreground/80 text-xs font-normal">
{props.command.join(" ")}
{props.command?.join(" ")}
</code>
</div>
);
} else {
return (
<code className="text-foreground/80 flex-1 text-xs font-normal">
{props.file}
{props.file_path}
</code>
);
}

View file

@ -128,7 +128,7 @@ export function mapToolMessageToActionStepProps(
actionType: "apply-patch",
status,
success,
file: args.file_path || "",
file_path: args.file_path || "",
diff: args.diff,
reasoningText,
errorMessage: !success ? getContentString(message.content) : undefined,
@ -222,24 +222,18 @@ export function AssistantMessage({
actionType={aiToolCallName === shellTool.name ? "shell" : "apply-patch"}
status="generating"
command={
aiToolCallName === shellTool.name
? aiToolCallArgs?.command || []
: undefined
aiToolCallName === shellTool.name ? aiToolCallArgs?.command || [] : []
}
workdir={
aiToolCallName === shellTool.name
? aiToolCallArgs?.workdir
: undefined
aiToolCallName === shellTool.name ? aiToolCallArgs?.workdir : ""
}
file={
file_path={
aiToolCallName === applyPatchTool.name
? aiToolCallArgs?.file_path || ""
: undefined
: ""
}
diff={
aiToolCallName === applyPatchTool.name
? aiToolCallArgs?.diff
: undefined
aiToolCallName === applyPatchTool.name ? aiToolCallArgs?.diff : ""
}
reasoningText={contentString}
/>