import { Button, Icon, IconTooltip, InlineCode, LoadingIcon } from "@yaakapp-internal/ui"; import classNames from "classnames"; import { useAtomValue } from "jotai"; import type { ReactNode } from "react"; import { useRpcMutation } from "../hooks/useRpcMutation"; import { encryptingPercent } from "../lib/encrypting"; import { proxyStateAtom } from "../lib/store"; import { useCopyEnvironment, useProxySetup, useSystemProxySwitch } from "./ProxyStatus"; type StepState = "todo" | "next" | "wait" | "done" | "fail"; /** * The list's empty state until traffic arrives: turn on the system proxy, then see traffic. The * certificate is trusted at the first Decrypt, not here, as nothing needs it before. Not * dismissable and nothing remembered; the first flow replaces it. Copy environment beside it * serves someone who wants one terminal proxied and nothing system-wide. */ export function FirstRun() { const proxyState = useAtomValue(proxyStateAtom); const setup = useProxySetup(); const { systemProxy, setSystemProxy } = setup; const systemSwitch = useSystemProxySwitch(setup); const execute = useRpcMutation("execute_action"); const retry = useRpcMutation("take_over"); const copyEnvironment = useCopyEnvironment(); const running = proxyState?.state === "running"; // Changed only by the process that owns the engine, so not from here while the CLI does. const otherOwner = proxyState?.otherOwner != null; const recording = proxyState?.recording !== false; const systemSupported = systemProxy.data?.supported !== false; const systemOn = systemProxy.data?.enabled === true; const systemState: StepState = setSystemProxy.isPending ? "wait" : systemOn ? "done" : systemSwitch.failed ? "fail" : "next"; const ready = systemOn || !systemSupported; const encrypting = !running && !otherOwner ? encryptingPercent(proxyState) : null; const trafficState: StepState = encrypting != null ? "wait" : !running && !otherOwner ? "fail" : ready ? "wait" : "todo"; return (
Set up Yaak Proxy
{systemSupported ? "Traffic from every app on this Mac will be recorded." : "Traffic appears here as apps send it."}
{systemSupported && ( setSystemProxy.mutate({ enabled: true })} > {systemState === "fail" ? "Retry" : "Enable"} ) : null } /> )} retry.mutate({})} > Retry ) : !recording && running ? ( ) : null } />
To proxy a single terminal instead, copy the environment.
Agents can connect through yaak mcp.
Recorded traffic is encrypted on disk.
); } function Step({ n, state, title, description, action, }: { n: number; state: StepState; title: string; description: ReactNode; action: ReactNode; }) { return (
{title}
{description}
{action}
); } function StepMark({ n, state }: { n: number; state: StepState }) { const base = "w-[1.4rem] h-[1.4rem] rounded-full grid place-items-center text-xs"; switch (state) { case "done": return ( ); case "fail": return ( ); case "wait": return ( ); case "next": return {n}; case "todo": return {n}; } }