mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 05:03:15 +00:00
* cancel run: manager, programmer, planner * improve error handling + useCancelStream hook abstraction * cancel stream button * minor format * Code review * CR: remove duplicate stream * Apply suggestions from code review * cr * use cancelStreamButton * cleanup and fix flash * cr --------- Co-authored-by: Brace Sproul <braceasproul@gmail.com>
43 lines
906 B
TypeScript
43 lines
906 B
TypeScript
import { Button } from "@/components/ui/button";
|
|
import { Loader2 } from "lucide-react";
|
|
import { UseStream } from "@langchain/langgraph-sdk/react";
|
|
import { useCancelStream } from "@/hooks/useCancelStream";
|
|
|
|
interface CancelStreamButtonProps {
|
|
stream: UseStream<any>;
|
|
threadId?: string;
|
|
runId?: string;
|
|
streamName: "Planner" | "Programmer";
|
|
}
|
|
|
|
export function CancelStreamButton({
|
|
stream,
|
|
threadId,
|
|
runId,
|
|
streamName,
|
|
}: CancelStreamButtonProps) {
|
|
const { cancelRun } = useCancelStream({
|
|
stream,
|
|
threadId,
|
|
runId,
|
|
streamName,
|
|
});
|
|
|
|
const shouldShow = stream.isLoading && threadId && runId;
|
|
|
|
if (!shouldShow) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
onClick={cancelRun}
|
|
size="sm"
|
|
variant="destructive"
|
|
className="h-8 px-3 text-xs"
|
|
>
|
|
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
|
|
Stop {streamName}
|
|
</Button>
|
|
);
|
|
}
|