mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-06 11:37:57 -05:00
refac
This commit is contained in:
1 parent
8296c5d08a
commit
b01fe7fae2
5 files changed
+17
-4
No files matched your search
@@ -22,6 +22,7 @@ class PanelTab(ViewModel):
|
||||
terminalNumber: int | None = None
|
||||
chatId: str | None = None
|
||||
sideChatNumber: int | None = None
|
||||
sideChat: bool | None = None
|
||||
path: str | None = None
|
||||
page: int | None = None
|
||||
sessionId: str | None = None
|
||||
|
||||
@@ -640,6 +640,7 @@
|
||||
kind,
|
||||
label: `${view.label} ${sideChatNumber}`,
|
||||
sideChatNumber,
|
||||
sideChat: true,
|
||||
initialPrompt
|
||||
},
|
||||
inSidePanel
|
||||
@@ -1798,7 +1799,7 @@
|
||||
chatId: chat.id,
|
||||
...(chat.title ? { label: chat.title } : {})
|
||||
})}
|
||||
parentChatId={tab.href ? '' : owner.chatId ?? ''}
|
||||
parentChatId={tab.sideChat ? owner.chatId ?? '' : ''}
|
||||
parentFolderId={tab.href ? null : folderId}
|
||||
{history}
|
||||
modelId={tab.href ? new URL(tab.href, location.origin).searchParams.get('models') ?? new URL(tab.href, location.origin).searchParams.get('model') ?? modelId : modelId}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
$user?.role === 'admin' ||
|
||||
($user?.role === 'user' && (standalone || ($user.permissions?.chat?.side_chat ?? false)));
|
||||
// Snapshot the active branch once; later parent edits and streaming stay in the parent.
|
||||
const context = (() => {
|
||||
let context = (() => {
|
||||
if (initialView?.context) return initialView.context;
|
||||
if (chatId || standalone) return [];
|
||||
const branch: any[] = [];
|
||||
@@ -98,7 +98,6 @@
|
||||
)
|
||||
);
|
||||
})();
|
||||
const contextIds = new Set(context.map((message) => message.id));
|
||||
let loaded = !chatId;
|
||||
let isShared = false;
|
||||
let readOnly = false;
|
||||
@@ -342,6 +341,9 @@
|
||||
system = params.system ?? saved.chat.system ?? $settings.system ?? '';
|
||||
}
|
||||
const savedHistory = saved.chat.history ?? convertMessagesToHistory(saved.chat.messages);
|
||||
if (parentChatId && !context.length)
|
||||
context = createMessagesList(savedHistory, saved.chat.branchPointMessageId);
|
||||
const contextIds = new Set(context.map((message) => message.id));
|
||||
messages = createMessagesList(
|
||||
savedHistory,
|
||||
saved.current_message_id ?? savedHistory.currentId
|
||||
|
||||
@@ -23,6 +23,7 @@ export type PanelTab = {
|
||||
initialPrompt?: string;
|
||||
chatId?: string;
|
||||
sideChatNumber?: number;
|
||||
sideChat?: boolean;
|
||||
terminalId?: string;
|
||||
terminalNumber?: number;
|
||||
path?: string;
|
||||
|
||||
@@ -71,6 +71,7 @@ export function serializeChatView(state: ChatViewState): ChatViewState {
|
||||
terminalNumber: tab.terminalNumber,
|
||||
chatId: tab.chatId,
|
||||
sideChatNumber: tab.sideChatNumber,
|
||||
sideChat: tab.sideChat,
|
||||
path: tab.path,
|
||||
page: tab.page,
|
||||
sessionId: tab.sessionId,
|
||||
@@ -113,7 +114,14 @@ export async function loadChatView(entry: Entry) {
|
||||
const result = await getChatView(entry.chatId!);
|
||||
if (result.state && result.state.schemaVersion !== 1)
|
||||
throw new Error('Unsupported chat view version');
|
||||
if (!entry.loaded && result.state) entry.state = result.state;
|
||||
if (!entry.loaded && result.state) {
|
||||
entry.state = result.state;
|
||||
// Older views used the display number to identify chats branched from the parent.
|
||||
for (const tab of entry.state.panels.tabs) {
|
||||
if (tab.kind === 'side')
|
||||
tab.sideChat ??= !tab.href && !!tab.sideChatNumber;
|
||||
}
|
||||
}
|
||||
entry.loaded = true;
|
||||
entry.error = '';
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user