fix(webui): restore chat selection after settings

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Xubin Ren
2026-05-08 23:48:01 +08:00
committed by Xubin Ren
co-authored by Cursor
parent 2cc32ca07c
commit 151c3d5ad0
2 changed files with 74 additions and 1 deletions
+12 -1
View File
@@ -331,6 +331,17 @@ function Shell({ onModelNameChange, onLogout }: { onModelNameChange: (modelName:
setMobileSidebarOpen(false);
}, []);
const onBackToChat = useCallback(() => {
setView("chat");
setMobileSidebarOpen(false);
setActiveKey((current) => {
if (current && sessions.some((session) => session.key === current)) {
return current;
}
return sessions[0]?.key ?? null;
});
}, [sessions]);
const onRestart = useCallback(() => {
const chatId = activeSession?.chatId ?? client.defaultChatId;
if (!chatId) return;
@@ -467,7 +478,7 @@ function Shell({ onModelNameChange, onLogout }: { onModelNameChange: (modelName:
<SettingsView
theme={theme}
onToggleTheme={toggle}
onBackToChat={() => setView("chat")}
onBackToChat={onBackToChat}
onModelNameChange={onModelNameChange}
onLogout={onLogout}
onRestart={onRestart}