refactor(webui): open models directly for first-run setup

This commit is contained in:
Xubin Ren committed 2026-09-02 16:25:07 +08:00
1 parent 1c1f746903
commit 05100b70ad
22 files changed
+75 -627

No files matched your search

+4 -20
View File
@@ -57,7 +57,6 @@ import {
} from "@/lib/bootstrap";
import { displayTitle, sortSessions } from "@/lib/chat-groups";
import { deriveTitle } from "@/lib/format";
import type { ModelSetupIntent } from "@/lib/model-setup";
import { NanobotClient } from "@/lib/nanobot-client";
import { ClientProvider, useClient } from "@/providers/ClientProvider";
import type {
@@ -1054,8 +1053,6 @@ function Shell({
const [temporaryChatEnabled, setTemporaryChatEnabled] = useState(false);
const [settingsInitialSection, setSettingsInitialSection] =
useState<SettingsSectionKey>(initialRouteRef.current.settingsSection);
const [modelSetupIntent, setModelSetupIntent] = useState<ModelSetupIntent | null>(null);
const [chatFocusRequest, setChatFocusRequest] = useState(0);
const [hostSidebarOpen, setHostSidebarOpen] =
useState<boolean>(readSidebarOpen);
const [hostSidebarPreviewOpen, setHostSidebarPreviewOpen] = useState(false);
@@ -1984,12 +1981,8 @@ function Shell({
[onSelectChat],
);
const onOpenSettings = useCallback((
section: SettingsSectionKey = "overview",
setupIntent: ModelSetupIntent | null = null,
) => {
const onOpenSettings = useCallback((section: SettingsSectionKey = "overview") => {
setSessionSearchOpen(false);
setModelSetupIntent(setupIntent);
navigate({ view: "settings", activeKey, settingsSection: section });
setMobileSidebarOpen(false);
}, [activeKey, navigate]);
@@ -1998,8 +1991,8 @@ function Shell({
void loadSettingsView();
}, []);
const onOpenModelSettings = useCallback((intent?: ModelSetupIntent) => {
onOpenSettings("models", intent ?? null);
const onOpenModelSettings = useCallback(() => {
onOpenSettings("models");
}, [onOpenSettings]);
const onOpenApps = useCallback(() => {
@@ -2022,7 +2015,6 @@ function Shell({
const onSettingsSectionChange = useCallback(
(section: SettingsSectionKey) => {
setModelSetupIntent(null);
navigate({
view: shellViewForSettingsSection(section),
activeKey,
@@ -2033,9 +2025,7 @@ function Shell({
);
const onBackToChat = useCallback(() => {
const restoreComposerFocus = modelSetupIntent !== null;
setMobileSidebarOpen(false);
setModelSetupIntent(null);
const nextKey = (() => {
if (!activeKey) return null;
if (topicSessions.some((session) => session.key === activeKey)) return activeKey;
@@ -2046,10 +2036,7 @@ function Shell({
activeKey: nextKey,
settingsSection: "overview",
});
if (restoreComposerFocus) {
setChatFocusRequest((value) => value + 1);
}
}, [activeKey, modelSetupIntent, navigate, topicSessions]);
}, [activeKey, navigate, topicSessions]);
const onRestart = useCallback(() => {
const chatId = activeSession?.chatId ?? client.defaultChatId;
@@ -2805,7 +2792,6 @@ function Shell({
onWorkspaceScopeChange={applyWorkspaceScope}
settingsSnapshot={settingsSnapshot}
onOpenModelSettings={onOpenModelSettings}
focusComposerRequest={chatFocusRequest}
skills={skills}
/>
);
@@ -2864,7 +2850,6 @@ function Shell({
}}
settingsSnapshot={settingsSnapshot}
onOpenModelSettings={onOpenModelSettings}
focusComposerRequest={context.active ? chatFocusRequest : 0}
skills={skills}
/>
);
@@ -2878,7 +2863,6 @@ function Shell({
theme={theme}
initialSection={settingsInitialSection}
initialSettings={settingsSnapshot}
modelSetupIntent={modelSetupIntent}
showSidebar={view === "settings"}
onToggleTheme={toggle}
onBackToChat={onBackToChat}