From fb3ff060407687fceca21a2306c006c247d7e6b8 Mon Sep 17 00:00:00 2001 From: jakub961241 <144362244+jakub961241@users.noreply.github.com> Date: Sun, 22 Mar 2026 00:34:43 +0100 Subject: [PATCH] fix: open container directory at WorkingDir instead of root (#12255) When clicking "Directory" on a container, the file browser always opened at `/` (root). Now it inspects the container first and opens at the container's configured WorkingDir (e.g., `/app`, `/var/www`). Falls back to `/` if WorkingDir is not set or inspect fails. Fixes #12255 --- .../container/container/file-browser/index.vue | 3 ++- frontend/src/views/container/container/index.vue | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/container/container/file-browser/index.vue b/frontend/src/views/container/container/file-browser/index.vue index 1f59aae71fbc..d43074075a55 100644 --- a/frontend/src/views/container/container/file-browser/index.vue +++ b/frontend/src/views/container/container/file-browser/index.vue @@ -141,13 +141,14 @@ const pathSegments = computed(() => { interface DrawerProps { containerID: string; title: string; + workingDir?: string; } const acceptParams = async (params: DrawerProps): Promise => { visible.value = true; containerID.value = params.containerID; title.value = params.title; - filePath.value = '/'; + filePath.value = params.workingDir || '/'; await loadContainerFiles(); }; diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue index f7b6cde22ae2..7607530b93a0 100644 --- a/frontend/src/views/container/container/index.vue +++ b/frontend/src/views/container/container/index.vue @@ -677,9 +677,19 @@ const onTerminal = (row: any) => { dialogTerminalRef.value!.acceptParams({ containerID: row.containerID, title: title }); }; const dialogFileBrowserRef = ref(); -const onOpenFileBrowser = (row: any) => { +const onOpenFileBrowser = async (row: any) => { const title = i18n.global.t('menu.container') + ' ' + row.name; - dialogFileBrowserRef.value!.acceptParams({ containerID: row.containerID, title: title }); + let workingDir = '/'; + try { + const res = await inspect({ id: row.containerID, type: 'container', detail: '' }); + const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data; + if (data?.Config?.WorkingDir) { + workingDir = data.Config.WorkingDir; + } + } catch (e) { + /* fallback to root */ + } + dialogFileBrowserRef.value!.acceptParams({ containerID: row.containerID, title: title, workingDir: workingDir }); }; const onInspect = async (row: any) => {