From 5de48bb3f00bb824df68524d98625963fc0853da Mon Sep 17 00:00:00 2001 From: Ashish Huddar Date: Thu, 26 Mar 2026 10:57:51 +0530 Subject: [PATCH] Restore desktop confirm flow and rename session PR card --- packages/web/src/components/Dashboard.tsx | 59 +++++++++++-------- packages/web/src/components/SessionDetail.tsx | 6 +- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/packages/web/src/components/Dashboard.tsx b/packages/web/src/components/Dashboard.tsx index 8ee5bf042..66a87acf6 100644 --- a/packages/web/src/components/Dashboard.tsx +++ b/packages/web/src/components/Dashboard.tsx @@ -252,11 +252,31 @@ function DashboardInner({ } }, []); + const killSession = useCallback(async (sessionId: string) => { + const res = await fetch(`/api/sessions/${encodeURIComponent(sessionId)}/kill`, { + method: "POST", + }); + if (!res.ok) { + const text = await res.text(); + console.error(`Failed to kill ${sessionId}:`, text); + showToast(`Terminate failed: ${text}`, "error"); + } else { + showToast("Session terminated", "success"); + } + }, [showToast]); + const handleKill = useCallback((sessionId: string) => { const session = sessionsRef.current.find((s) => s.id === sessionId) ?? null; if (!session) return; + if (!isMobile) { + const confirmed = window.confirm("Terminate this session?"); + if (confirmed) { + void killSession(session.id); + } + return; + } setSheetState({ sessionId: session.id, mode: "confirm-kill" }); - }, []); + }, [isMobile, killSession]); const handlePreview = useCallback((session: DashboardSession) => { setSheetState({ sessionId: session.id, mode: "preview" }); @@ -272,17 +292,8 @@ function DashboardInner({ const session = sheetSession; setSheetState(null); if (!session) return; - const res = await fetch(`/api/sessions/${encodeURIComponent(session.id)}/kill`, { - method: "POST", - }); - if (!res.ok) { - const text = await res.text(); - console.error(`Failed to kill ${session.id}:`, text); - showToast(`Terminate failed: ${text}`, "error"); - } else { - showToast("Session terminated", "success"); - } - }, [sheetSession, showToast]); + await killSession(session.id); + }, [killSession, sheetSession]); const handleMerge = useCallback(async (prNumber: number) => { setSheetState(null); @@ -636,17 +647,19 @@ function DashboardInner({ orchestratorHref={orchestratorHref} /> ) : null} - setSheetState(null)} - onRequestKill={handleRequestKillFromPreview} - onMerge={handleMerge} - isMergeReady={ - sheetSession?.pr ? isPRMergeReady(sheetSession.pr) : false - } - /> + {isMobile ? ( + setSheetState(null)} + onRequestKill={handleRequestKillFromPreview} + onMerge={handleMerge} + isMergeReady={ + sheetSession?.pr ? isPRMergeReady(sheetSession.pr) : false + } + /> + ) : null} ); } diff --git a/packages/web/src/components/SessionDetail.tsx b/packages/web/src/components/SessionDetail.tsx index 03297c32d..9947bd08e 100644 --- a/packages/web/src/components/SessionDetail.tsx +++ b/packages/web/src/components/SessionDetail.tsx @@ -409,7 +409,7 @@ export function SessionDetail({ {pr ? (
- +
) : null} @@ -428,9 +428,9 @@ export function SessionDetail({ ); } -// ── PR Card ─────────────────────────────────────────────────────────── +// ── Session detail PR card ──────────────────────────────────────────── -function PRCard({ pr, sessionId }: { pr: DashboardPR; sessionId: string }) { +function SessionDetailPRCard({ pr, sessionId }: { pr: DashboardPR; sessionId: string }) { const [sendingComments, setSendingComments] = useState>(new Set()); const [sentComments, setSentComments] = useState>(new Set()); const [errorComments, setErrorComments] = useState>(new Set());