From ee38c0213c670ee7f0ec266d6fb928ffce44552c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 26 Nov 2026 16:55:05 +0400 Subject: [PATCH] refac --- backend/open_webui/models/chat_views.py | 4 +- src/lib/components/chat/Tabs.svelte | 33 +++++++++++++++ src/lib/components/chat/Tabs/GitBar.svelte | 49 +++++++++++++++++----- src/lib/components/chat/Tabs/tabs.ts | 1 + 4 files changed, 75 insertions(+), 12 deletions(-) diff --git a/backend/open_webui/models/chat_views.py b/backend/open_webui/models/chat_views.py index dcb94cb7ef..64a725aa6f 100644 --- a/backend/open_webui/models/chat_views.py +++ b/backend/open_webui/models/chat_views.py @@ -17,7 +17,9 @@ class ViewModel(BaseModel): class PanelTab(ViewModel): id: str - kind: Literal['chat', 'comments', 'files', 'file', 'terminal', 'browser', 'desktop', 'side', 'page', 'overview'] + kind: Literal[ + 'chat', 'comments', 'files', 'file', 'git', 'terminal', 'browser', 'desktop', 'side', 'page', 'overview' + ] label: str href: str | None = None machineId: str | None = None diff --git a/src/lib/components/chat/Tabs.svelte b/src/lib/components/chat/Tabs.svelte index cb29409e21..f2392630da 100644 --- a/src/lib/components/chat/Tabs.svelte +++ b/src/lib/components/chat/Tabs.svelte @@ -697,6 +697,7 @@ chat: 'chat-lines', page: 'page', files: 'folder', + git: 'git-branch', file: 'page', terminal: 'terminal', browser: 'browser', @@ -964,6 +965,21 @@ }); if (page != null) fileViews[id]?.revealPage?.(page); }; + const openGit = (machineId: string, root: string, sourceModelId = modelId) => { + if (!isMachineReachable(machineId)) return; + const target = resolveMachineTarget(machineId, $machines ?? [], localStorage.token, { + chatId: panelChatId, + modelId: sourceModelId ?? null + }); + openPanel({ + id: JSON.stringify(['git', machineId, target?.context.modelId ?? null, root]), + kind: 'git', + label: root.split('/').filter(Boolean).pop() || $i18n.t('Git'), + machineId, + target: target ?? undefined, + directory: root + }); + }; const openNewFileTab = () => { if (!selectedConnection) return askForMachine(openNewFileTab); let number = 1; @@ -2459,6 +2475,22 @@ }); }} /> + {:else if tab.kind === 'git' && tab.machineId && target} + openFile(path, tab.machineId!, null, target.context.modelId)} + onOpenDirectory={(path) => + openFiles(tab.machineId, path, false, target.context.modelId)} + {onDraftPrompt} + /> {:else if (tab.kind === 'files' || tab.kind === 'file') && tab.machineId} {@const fileTarget = isMounted ? resolveTabConnection(tab) : null}
@@ -2541,6 +2573,7 @@ openFile(path, tab.machineId!, null, fileTarget?.context.modelId)} onOpenDirectory={(path) => openFiles(tab.machineId, path, false, fileTarget?.context.modelId)} + onOpenTab={(root) => openGit(tab.machineId!, root, fileTarget?.context.modelId)} {onDraftPrompt} /> {/if} diff --git a/src/lib/components/chat/Tabs/GitBar.svelte b/src/lib/components/chat/Tabs/GitBar.svelte index 9ba9ddcd48..80b520d1db 100644 --- a/src/lib/components/chat/Tabs/GitBar.svelte +++ b/src/lib/components/chat/Tabs/GitBar.svelte @@ -34,7 +34,10 @@ const i18n = getContext('i18n'); export let status: GitStatus | null = null; export let initialView: any = null; - let expanded = initialView?.expanded ?? false; + /** Fills a tab of its own: always expanded, no collapse or resize. */ + export let standalone = false; + export let onOpenTab: ((root: string) => void) | null = null; + let expanded = standalone || (initialView?.expanded ?? false); export const captureView = () => ({ expanded, summary, description, height, listWidth, view }); export let diffMode: 'unified' | 'split' = 'unified'; export let hideWhitespace = false; @@ -266,7 +269,7 @@ status = null; error = ''; detectionError = ''; - expanded = restoring?.expanded ?? false; + expanded = standalone || (restoring?.expanded ?? false); showBranches = showWorktrees = showRename = @@ -471,6 +474,7 @@ ) ]; const toggle = () => { + if (standalone) return; expanded = !expanded; if (expanded) { void refresh(true); @@ -497,10 +501,12 @@ {#if status?.is_repo}
- {#if expanded} + {#if expanded && !standalone}
- + {#if onOpenTab && !standalone} + + + + {/if} + {#if !standalone} + + {/if}
{#if error}
{/if} {#if expanded}
refresh(true)}>
+{:else if standalone && status} +
+ {$i18n.t('Not a Git repository')} +
{/if}