feat(webui): add assistant reply fork-from-here

This commit is contained in:
Bayern4ever-dot
2026-06-10 04:26:06 +08:00
committed by Xubin Ren
parent 4a58b83acc
commit 03bca4c0a9
30 changed files with 1358 additions and 36 deletions
+21 -1
View File
@@ -526,7 +526,7 @@ function Shell({
const { t, i18n } = useTranslation();
const { client, token } = useClient();
const { theme, toggle } = useTheme();
const { sessions, loading, refresh, createChat, deleteChat } = useSessions();
const { sessions, loading, refresh, createChat, forkChat, deleteChat } = useSessions();
const { state: sidebarState, update: updateSidebarState } =
useSidebarState(sessions, !loading);
const initialRouteRef = useRef<ShellRoute | null>(null);
@@ -885,6 +885,25 @@ function Shell({
}
}, [activeWorkspaceScope, createChat, navigate, t]);
const onForkChat = useCallback(async (
sourceChatId: string,
beforeUserIndex: number,
) => {
try {
const chatId = await forkChat(sourceChatId, beforeUserIndex);
navigate({
view: "chat",
activeKey: `websocket:${chatId}`,
settingsSection: "overview",
});
setMobileSidebarOpen(false);
return chatId;
} catch (e) {
console.error("Failed to fork chat", e);
return null;
}
}, [forkChat, navigate]);
const onNewChat = useCallback(() => {
navigate(defaultShellRoute());
setDraftWorkspaceScope(null);
@@ -1486,6 +1505,7 @@ function Shell({
onToggleSidebar={toggleSidebar}
onNewChat={onNewChat}
onCreateChat={onCreateChat}
onForkChat={onForkChat}
onTurnEnd={onTurnEnd}
theme={theme}
onToggleTheme={toggle}