"use client"; import { ContextMenuContent, ContextMenuItem, ContextMenuSeparator } from "@kandev/ui/context-menu"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { isSessionStoppable as isStoppable, isSessionDeletable as isDeletable, isSessionResumable as isResumable, } from "@/hooks/domains/session/use-session-actions"; import { ShareDialog } from "@/components/task/share/share-dialog"; import { HandoffContextMenuSub } from "@/components/task/handoff-profile-menu-items"; import { NewSessionDialog, type HandoffPreset } from "@/components/task/new-session-dialog"; import type { TaskSessionState } from "@/lib/types/http"; import { useTranslation } from "react-i18next"; /** Lifecycle callbacks the context menu needs from the owning tab. */ export type SessionTabMenuActions = { handleSetPrimary: () => void; handleStop: () => void; handleResume: () => void; handleCloseOthers: () => void; }; export function DeleteSessionDialog({ open, onOpenChange, isPrimary, sessionCount, onConfirm, }: { open: boolean; onOpenChange: (open: boolean) => void; isPrimary: boolean; sessionCount: number; onConfirm: () => void; }) { const { t } = useTranslation(); return ( {t("task:deleteSession")} {t("task:thisWillPermanentlyDeleteTheConversation")} {isPrimary && sessionCount > 1 && ( {t("task:thisIsThePrimarySessionAnother")} )} {sessionCount === 1 && ( {t("task:thisIsTheOnlySessionFor")} )} {t("common:cancel")} { onOpenChange(false); onConfirm(); }} className="cursor-pointer bg-destructive text-destructive-foreground hover:bg-destructive/90" > {t("task:delete")} ); } export function SessionContextMenuItems({ sessionState, isPrimary, canShare, taskId, sessionId, actions, onDelete, onShare, onHandoffProfile, onStartRename, }: { sessionState: TaskSessionState | null; isPrimary: boolean; canShare: boolean; taskId: string | null; sessionId: string | undefined; actions: SessionTabMenuActions; onDelete: () => void; onShare: () => void; onHandoffProfile: (profileId: string) => void; onStartRename: () => void; }) { const { t } = useTranslation(); return ( {t("task:rename2")} {t("task:setAsPrimary")} {sessionState && isStoppable(sessionState) && ( {t("task:stop")} )} {sessionState && isResumable(sessionState) && ( {t("task:resume")} )} {sessionState && isDeletable(sessionState) && ( {t("task:delete")} )} {canShare && ( <> {t("task:share")} > )} {taskId && sessionId && ( <> > )} {t("task:closeOthers")} ); } /** Delete / share / handoff dialogs rendered alongside the tab. */ export function SessionTabDialogs({ confirmDelete, setConfirmDelete, isPrimary, sessionCount, onConfirmDelete, taskId, sessionId, shareOpen, setShareOpen, handoffOpen, setHandoffOpen, handoffPreset, setHandoffPreset, groupId, }: { confirmDelete: boolean; setConfirmDelete: (open: boolean) => void; isPrimary: boolean; sessionCount: number; onConfirmDelete: () => void; taskId: string | null; sessionId: string | undefined; shareOpen: boolean; setShareOpen: (open: boolean) => void; handoffOpen: boolean; setHandoffOpen: (open: boolean) => void; handoffPreset: HandoffPreset | null; setHandoffPreset: (preset: HandoffPreset | null) => void; groupId: string | undefined; }) { return ( <> {taskId && sessionId && ( )} {taskId && handoffPreset && ( { setHandoffOpen(open); if (!open) setHandoffPreset(null); }} taskId={taskId} groupId={groupId} handoff={handoffPreset} /> )} > ); }
{t("task:thisWillPermanentlyDeleteTheConversation")}
{t("task:thisIsThePrimarySessionAnother")}
{t("task:thisIsTheOnlySessionFor")}