diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx index cffefd5634d..dccb4b8ccb6 100644 --- a/packages/app/src/pages/layout.tsx +++ b/packages/app/src/pages/layout.tsx @@ -94,6 +94,7 @@ export default function Layout(props: ParentProps) { const dialog = useDialog() const command = useCommand() const theme = useTheme() + const [pendingArchive, setPendingArchive] = createSignal() const availableThemeEntries = createMemo(() => Object.entries(theme.themes())) const colorSchemeOrder: ColorScheme[] = ["system", "light", "dark"] const colorSchemeLabel: Record = { @@ -519,6 +520,7 @@ export default function Layout(props: ParentProps) { const index = sessions.findIndex((s) => s.id === session.id) const nextSession = sessions[index + 1] ?? sessions[index - 1] + setPendingArchive(undefined) await globalSDK.client.session.update({ directory: session.directory, sessionID: session.id, @@ -589,7 +591,12 @@ export default function Layout(props: ParentProps) { disabled: !params.dir || !params.id, onSelect: () => { const session = currentSessions().find((s) => s.id === params.id) - if (session) archiveSession(session) + if (!session) return + if (pendingArchive() === session.id) { + archiveSession(session) + } else { + setPendingArchive(session.id) + } }, }, { @@ -852,12 +859,25 @@ export default function Layout(props: ParentProps) { const status = sessionStore.session_status[props.session.id] return status?.type === "busy" || status?.type === "retry" }) + const isConfirming = () => pendingArchive() === props.session.id + const handleArchiveClick = (e: MouseEvent) => { + e.preventDefault() + e.stopPropagation() + if (isConfirming()) { + archiveSession(props.session) + } else { + setPendingArchive(props.session.id) + } + } return ( <>
{ + if (isConfirming()) setPendingArchive(undefined) + }} >