"use client"; import { useEffect, useRef, useState } from "react"; import { Button } from "@kandev/ui/button"; import { IconArrowBackUp, IconLoader2 } from "@tabler/icons-react"; interface HunkActionBarProps { changeBlockId: string; onRevert: () => Promise | void; onMouseEnter: () => void; onMouseLeave: () => void; } export function HunkActionBar({ changeBlockId, onRevert, onMouseEnter, onMouseLeave, }: HunkActionBarProps) { const [loading, setLoading] = useState(false); const mountedRef = useRef(true); useEffect( () => () => { mountedRef.current = false; }, [], ); const handleClick = async () => { setLoading(true); try { await onRevert(); } catch { // Revert failures are surfaced by the caller; keep this overlay from // turning a failed async action into an unhandled event rejection. } finally { if (!mountedRef.current) return; setLoading(false); } }; return (
); }