import { useIsMutating } from '@tanstack/react-query' import { ConfirmDialog } from '@/components/ui/ConfirmDialog' import { sessionArchiveMutationKey } from '@/hooks/mutations/useSessionActions' import { useTranslation } from '@/lib/use-translation' type DeleteSessionDialogProps = { isOpen: boolean sessionId: string onClose: () => void description: string onConfirm: () => Promise isPending: boolean } export function DeleteSessionDialog(props: DeleteSessionDialogProps) { // Closed dialogs (including the header's always-mounted wrapper) must not // subscribe to every mutation-cache notification across the session list. return props.isOpen ? : null } function OpenDeleteSessionDialog(props: DeleteSessionDialogProps) { const { t } = useTranslation() // A row may remount, or the archive may originate in another view. Observe // shared progress only while this dialog needs to gate deletion. const isArchiving = useIsMutating({ mutationKey: sessionArchiveMutationKey(props.sessionId), exact: true }) > 0 return ( ) }