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, MessageSquare,
FileText, FileText,
} from "lucide-react"; } 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 // Common props for all action types
type BaseActionProps = { type BaseActionProps = {
@ -21,23 +33,23 @@ type BaseActionProps = {
summaryText?: string; summaryText?: string;
}; };
// Shell command specific props // Shell command specific props. We need to wrap the args in Partial<...>
type ShellActionProps = BaseActionProps & { // because even though they're required, they may be undefined at a point in time
actionType: "shell"; // due to streaming.
command: string[]; type ShellActionProps = BaseActionProps &
workdir?: string; Partial<ShellToolArgs> & {
output?: string; actionType: "shell";
errorCode?: number; output?: string;
}; errorCode?: number;
};
// Apply patch specific props // Apply patch specific props
type PatchActionProps = BaseActionProps & { type PatchActionProps = BaseActionProps &
actionType: "apply-patch"; Partial<ApplyPatchToolArgs> & {
file: string; actionType: "apply-patch";
diff?: string; errorMessage?: string;
errorMessage?: string; fixedDiff?: string;
fixedDiff?: string; };
};
// Union type for all possible action props // Union type for all possible action props
export type ActionStepProps = export type ActionStepProps =
@ -137,14 +149,14 @@ export function ActionStep(props: ActionStepProps) {
</div> </div>
)} )}
<code className="text-foreground/80 text-xs font-normal"> <code className="text-foreground/80 text-xs font-normal">
{props.command.join(" ")} {props.command?.join(" ")}
</code> </code>
</div> </div>
); );
} else { } else {
return ( return (
<code className="text-foreground/80 flex-1 text-xs font-normal"> <code className="text-foreground/80 flex-1 text-xs font-normal">
{props.file} {props.file_path}
</code> </code>
); );
} }

View file

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