"use client"; import { useState, useCallback } from "react"; import { IconRotateClockwise2 } from "@tabler/icons-react"; import { GridSpinner } from "@/components/grid-spinner"; import { Button } from "@kandev/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { getWebSocketClient } from "@/lib/ws/connection"; export function ResetContextButton({ sessionId }: { sessionId: string }) { const [confirmOpen, setConfirmOpen] = useState(false); const [isResetting, setIsResetting] = useState(false); const handleReset = useCallback(async () => { setIsResetting(true); try { const client = getWebSocketClient(); if (!client) return; await client.request("session.reset_context", { session_id: sessionId }, 30000); } catch (error) { console.error("Failed to reset agent context:", error); } finally { setIsResetting(false); setConfirmOpen(false); } }, [sessionId]); return ( <> Reset agent context — clears conversation history, preserves workspace Reset agent context? This will clear the agent's conversation history and start a fresh context. Your workspace, files, and git state will be preserved. Cancel {isResetting ? "Resetting..." : "Reset Context"} ); }