"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"; /** 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; }) { return ( Delete session?

This will permanently delete the conversation history with this session.

{isPrimary && sessionCount > 1 && (

This is the primary session. Another session will be set as primary.

)} {sessionCount === 1 && (

This is the only session for this task.

)}
Cancel { onOpenChange(false); onConfirm(); }} className="cursor-pointer bg-destructive text-destructive-foreground hover:bg-destructive/90" > 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; }) { return ( Rename… Set as Primary {sessionState && isStoppable(sessionState) && ( Stop )} {sessionState && isResumable(sessionState) && ( Resume )} {sessionState && isDeletable(sessionState) && ( Delete )} {canShare && ( <> Share )} {taskId && sessionId && ( <> )} Close Others ); } /** 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} /> )} ); }