Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

1.1 KB
Raw Blame
import { IconPlayerPause } from "@tabler/icons-react";
import { useMutation, useQuery } from "@tanstack/react-query";
import { Button } from "@/components/ui/button";
import { setBotPausedMutationOptions } from "@/lib/bot-lifecycle/mutations";
import { botLifecycleQueryOptions } from "@/lib/bot-lifecycle/queries";
import { queryClient } from "@/query-client";

/**
 * "Paused, tap to resume", wherever a paused Bot is shown.
 *
 * Renders nothing while the Bot runs, or while its state is loading, so a surface can drop it in
 * above a conversation or a profile without deciding anything itself.
 */
export function BotPausedBanner({ agentId }: { agentId: string }) {
  const lifecycle = useQuery(botLifecycleQueryOptions(agentId));
  const resume = useMutation(setBotPausedMutationOptions(queryClient));
  if (!lifecycle.data?.paused) return null;
  return (
    <Button
      className="w-full justify-center gap-2"
      disabled={resume.isPending}
      onClick={() => resume.mutate({ agentId, paused: false })}
      variant="secondary"
    >
      <IconPlayerPause />
      {resume.isPending ? "Resuming…" : "Paused. Resume"}
    </Button>
  );
}