feat: open a file by typing its path in the machine file browser (#35233)

Typing a file's path into the path bar of a machine's file browser tried it as a folder and showed "Failed to load directory". Now the file opens, and folder paths work as before.

Discussion: https://github.com/open-webui/open-webui/discussions/35231
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-30 18:33:55 +04:00
1 parent 71de09dba5
commit 7e2b509869
2 files changed
+37 -1

No files matched your search

+35
View File
@@ -1572,6 +1572,40 @@
} as BrowserRow);
};
// The path bar cannot tell a file from a folder
const goToPath = async (path: string) => {
const machine = selectedMachine;
const generation = loadGeneration;
const selector = effectiveMachineId,
session = chatId;
const filePath = path.replace(/\/$/, '');
const fileName = filePath.split('/').pop();
const parentPath = parentDirectoryPath(filePath);
const listing =
machine && !onSelectDirectory && isInsideFileRoot(parentPath)
? await listFiles(machine, parentPath)
: null;
if (generation !== loadGeneration || selector !== effectiveMachineId || session !== chatId)
return;
const entry = listing?.entries.find(
(item) => item.type === 'file' && cleanEntryName(item.name) === fileName
);
if (entry) {
await openEntry({
...entry,
name: fileName,
fullPath: filePath,
parentPath,
depth: 0,
rowIndex: -1
} as BrowserRow);
} else if (initialFile && onBrowseDirectory) {
onBrowseDirectory(path);
} else {
await loadDir(path);
}
};
const openContentMatch = async (match: MachineFileMatch, contentMatch: MachineContentMatch) => {
await openFileMatch(match);
fileSearchTarget = {
@@ -2540,6 +2574,7 @@
onGoBack={goBack}
onGoForward={goForward}
onNavigate={initialFile && onBrowseDirectory ? onBrowseDirectory : loadDir}
onGoToPath={goToPath}
listFolders={async (path) => {
const machine = selectedMachine;
const entries =
@@ -25,6 +25,7 @@
export let onViewModeChange: (mode: 'grid' | 'list') => void = () => {};
export let onNavigate: (path: string) => void = () => {};
export let onGoToPath: ((path: string) => void) | null = null;
export let listFolders: ((path: string) => Promise<string[]>) | null = null;
export let onRefresh: () => void = () => {};
export let showSearch = false;
@@ -83,7 +84,7 @@
const goToPath = () => {
typingPath = false;
if (pathInput.value.trim()) onNavigate(resolve(pathInput.value));
if (pathInput.value.trim()) (onGoToPath ?? onNavigate)(resolve(pathInput.value));
};
// Tab / Shift+Tab cycle through the folders matching the last name typed