Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { commonMessages } from "@/i18n/common.messages";
import { useT } from "@/i18n/use-translation";
import { cn } from "@/lib/cn";
import { runtimeStatusMessages as m } from "../runtime-status/runtime-status.messages";
/**
* Cancels one Task's current turn. The Room's Meta is told and can resume
* it later, so no confirmation is asked.
*/
export function CancelTaskButton({
cancel,
prominent = false,
title,
}: {
cancel: () => Promise<void>;
/** A dialog's own action button, rather than a quiet link in a list row. */
prominent?: boolean;
title: string;
}) {
const t = useT();
const [state, setState] = useState<"idle" | "pending" | "error">("idle");
return (
<Button
aria-label={
state === "error"
? t(m.cancelTaskNotConfirmed, { title })
: t(m.cancelTask, { title })
}
className={cn(
!prominent &&
"h-7 px-1.5 text-[12px] font-medium hover:bg-transparent hover:text-app-danger",
state === "error" ? "text-app-danger" : !prominent && "text-app-muted",
)}
disabled={state === "pending"}
onClick={() => {
setState("pending");
cancel().then(
() => setState("idle"),
() => setState("error"),
);
}}
size="compact"
tone={prominent ? "secondary" : "ghost"}
type="button"
>
{state === "pending"
? t(m.canceling)
: state === "error"
? t(commonMessages.retry)
: prominent
? t(m.cancelTaskAction)
: t(commonMessages.cancel)}
</Button>
);
}