diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index d4d179ba..372cbfb5 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -707,3 +707,6 @@ input:disabled, select:disabled { color: var(--color-ink-tertiary); background: .auth-panel h1 { font-size: var(--type-display-sm); } .admin-section { padding: var(--space-5); } } +.session-delete-confirmation { position: fixed; inset: auto var(--space-5) var(--space-5) auto; z-index: 100; width: min(360px, calc(100vw - var(--space-10))); padding: var(--space-5); border: 1px solid var(--border); border-radius: 8px; background: var(--background); box-shadow: 0 12px 32px rgb(0 0 0 / 18%); } +.session-delete-confirmation p { margin: 0 0 var(--space-4); } +.session-delete-confirmation div { display: flex; justify-content: flex-end; gap: var(--space-3); } diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index d1d1d054..a913639a 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -695,6 +695,7 @@ export default function Home() { const [archivedSessionIds, setArchivedSessionIds] = useState([]); const [showArchivedSessions, setShowArchivedSessions] = useState(false); const [sessionMenuId, setSessionMenuId] = useState(null); + const [pendingSessionDeletion, setPendingSessionDeletion] = useState(null); const [modelCatalog, setModelCatalog] = useState(null); const [activeSessionId, setActiveSessionId] = useState(""); const [draft, setDraft] = useState(""); @@ -1245,7 +1246,7 @@ export default function Home() { } async function deleteSession(session: ChatSession) { - if (!account || !window.confirm(`删除“${session.title}”?此操作不可恢复。`)) return; + if (!account) return; const previousSessions = sessions; const nextSessions = sessions.filter((item) => item.id !== session.id); setSessions(nextSessions); @@ -2308,7 +2309,7 @@ export default function Home() { onToggleArchived: toggleArchivedSession, onDelete: (sessionId) => { const session = sessions.find((candidate) => candidate.id === sessionId); - if (session) void deleteSession(session); + if (session) setPendingSessionDeletion(session); }, }} onAccountMenuOpenChange={setAccountMenuOpen} @@ -2318,6 +2319,19 @@ export default function Home() { onOpenRedeem={() => openAccountDialog("redeem")} onOpenLogout={() => openAccountDialog("logout")} /> + {pendingSessionDeletion ? ( +
+

删除“{pendingSessionDeletion.title}”?此操作不可恢复。

+
+ + +
+
+ ) : null}
diff --git a/tests/test_session_management_entrypoints.py b/tests/test_session_management_entrypoints.py index ce0346fd..9cd2b2d2 100644 --- a/tests/test_session_management_entrypoints.py +++ b/tests/test_session_management_entrypoints.py @@ -13,6 +13,8 @@ def test_chat_history_management_actions_are_exposed() -> None: for expected in ( "renameSession", "deleteSession", + "pendingSessionDeletion", + "确认删除", "togglePinnedSession", "toggleArchivedSession", "showArchivedSessions",