feat: add cancellation button

This commit is contained in:
Tat Dat Duong
2025-03-04 16:11:44 +01:00
parent b3099e1419
commit 3e99310995

View File

@@ -14,7 +14,7 @@ import {
} from "@/lib/ensure-tool-responses"; } from "@/lib/ensure-tool-responses";
import { LangGraphLogoSVG } from "../icons/langgraph"; import { LangGraphLogoSVG } from "../icons/langgraph";
import { TooltipIconButton } from "./tooltip-icon-button"; import { TooltipIconButton } from "./tooltip-icon-button";
import { ArrowDown, SquarePen } from "lucide-react"; import { ArrowDown, LoaderCircle, SquarePen } from "lucide-react";
import { StringParam, useQueryParam } from "use-query-params"; import { StringParam, useQueryParam } from "use-query-params";
import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom"; import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
@@ -211,12 +211,19 @@ export function Thread() {
/> />
<div className="flex items-center justify-end p-2 pt-0"> <div className="flex items-center justify-end p-2 pt-0">
{stream.isLoading ? (
<Button key="stop" onClick={() => stream.stop()}>
<LoaderCircle className="w-4 h-4 animate-spin" />
Cancel
</Button>
) : (
<Button <Button
type="submit" type="submit"
disabled={isLoading || !input.trim()} disabled={isLoading || !input.trim()}
> >
Send Send
</Button> </Button>
)}
</div> </div>
</form> </form>
</div> </div>