import { Button, Icon } from "@yaakapp-internal/ui"; import { useAtomValue } from "jotai"; import { useRpcMutation } from "../hooks/useRpcMutation"; import { proxyStateAtom } from "../lib/store"; /** * A quiet strip while another process, the CLI daemon, owns the engine: flows still list, read * from the database, and Take over stops that process's proxy and starts this app's. Never done * without the person asking. */ export function TakeOverBanner() { const other = useAtomValue(proxyStateAtom)?.otherOwner; const takeOver = useRpcMutation("take_over"); if (other == null) return null; const since = new Date(other.startedAt).toLocaleTimeString([], { hour: "numeric", minute: "2-digit", }); const cli = other.owner === "cli"; const who = cli ? "Running from the CLI" : "Running in another Yaak Proxy"; return (
{who} {other.owner === "cli" && ( yaak proxy start )} {!cli ? ( // Stopping another app halts its engine without releasing it, so it can't be taken over. "Another Yaak Proxy window owns the engine. Quit it to use this one." ) : takeOver.error != null ? ( {takeOver.error.message} ) : ( `pid ${other.pid}, since ${since}. Flows still list here, read from the capture database.` )} {cli && ( )}
); }