From 849288802a52d3b0c80ddb5eb5250c26901b05b2 Mon Sep 17 00:00:00 2001 From: lyx-tec Date: Thu, 4 Jun 2026 22:46:22 +0800 Subject: [PATCH 1/2] fix: support Windows drive switching in file browser - computeDirPart returns empty string for Windows drive roots - Add listDrives() to enumerate available drives - Handle empty path for drive listing in list/fileInfo commands - Fix getParentDirectory for backslash paths - Fix back button, bookmark, and parent entry for drives --- .../app/view/preview/preview-directory.tsx | 8 ++++ frontend/app/view/preview/preview-model.tsx | 6 ++- frontend/util/historyutil.ts | 20 +++++---- frontend/util/waveutil.ts | 3 ++ pkg/wshrpc/wshremote/wshremote_file.go | 45 +++++++++++++++++++ 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/frontend/app/view/preview/preview-directory.tsx b/frontend/app/view/preview/preview-directory.tsx index 0940ba43b3..f47401fbd6 100644 --- a/frontend/app/view/preview/preview-directory.tsx +++ b/frontend/app/view/preview/preview-directory.tsx @@ -603,6 +603,14 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) { modtime: new Date().getTime(), mimetype: "directory", }); + } else if (finfo?.dir === "" && finfo?.path) { + entries.unshift({ + name: "..", + path: "", + isdir: true, + modtime: new Date().getTime(), + mimetype: "directory", + }); } } catch (e) { console.error("Directory Read Error", e); diff --git a/frontend/app/view/preview/preview-model.tsx b/frontend/app/view/preview/preview-model.tsx index 8315e48b2a..f6daad34b7 100644 --- a/frontend/app/view/preview/preview-model.tsx +++ b/frontend/app/view/preview/preview-model.tsx @@ -31,6 +31,10 @@ const BOOKMARKS: { label: string; path: string }[] = [ { label: "Root", path: "/" }, ]; +if (window.navigator?.platform?.startsWith("Win")) { + BOOKMARKS.push({ label: "Drives", path: "" }); +} + const MaxFileSize = 1024 * 1024 * 10; // 10MB const MaxCSVSize = 1024 * 1024 * 1; // 1MB @@ -315,7 +319,7 @@ export class PreviewModel implements ViewModel { } const mimeType = jotaiLoadableValue(get(this.fileMimeTypeLoadable), ""); const metaPath = get(this.metaFilePath); - if (mimeType == "directory" && metaPath == "/") { + if (mimeType == "directory" && (metaPath == "/" || metaPath == "")) { return null; } return { diff --git a/frontend/util/historyutil.ts b/frontend/util/historyutil.ts index 73e4da201e..a41b0f7bef 100644 --- a/frontend/util/historyutil.ts +++ b/frontend/util/historyutil.ts @@ -5,22 +5,24 @@ import * as util from "@/util/util"; const MaxHistory = 20; -// this needs to be fixed for windows function getParentDirectory(path: string): string { if (util.isBlank(path) == null) { - // this not great, ideally we'd never be passed a null path return "/"; } - if (path == "/") { - return "/"; + if (path == "/" || path == "") { + return path; } - const splitPath = path.split("/"); + const separator = path.includes("\\") ? "\\" : "/"; + const splitPath = path.split(separator); splitPath.pop(); - if (splitPath.length == 1 && splitPath[0] == "") { - return "/"; + if (splitPath.length == 0 || (splitPath.length == 1 && splitPath[0] == "")) { + return separator == "\\" ? path.substring(0, 3) : "/"; + } + const joined = splitPath.join(separator); + if (separator == "\\" && joined.length == 2 && joined[1] == ":") { + return joined + "\\"; } - const newPath = splitPath.join("/"); - return newPath; + return joined; } function goHistoryBack(curValKey: "url" | "file", curVal: string, meta: MetaType, backToParent: boolean): MetaType { diff --git a/frontend/util/waveutil.ts b/frontend/util/waveutil.ts index 4d0f5952fc..7944e54d09 100644 --- a/frontend/util/waveutil.ts +++ b/frontend/util/waveutil.ts @@ -91,5 +91,8 @@ export function computeBgStyleFromMeta(meta: Omit Date: Fri, 5 Jun 2026 00:18:30 +0800 Subject: [PATCH 2/2] fix: display drive names (C:, D:) in file browser and show bookmarks on single click --- frontend/app/view/preview/preview-directory.tsx | 2 +- frontend/app/view/preview/preview-model.tsx | 4 ++-- pkg/wconfig/defaultconfig/settings.json | 4 ++-- pkg/wshrpc/wshremote/wshremote_file.go | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/app/view/preview/preview-directory.tsx b/frontend/app/view/preview/preview-directory.tsx index f47401fbd6..d4a2eace4f 100644 --- a/frontend/app/view/preview/preview-directory.tsx +++ b/frontend/app/view/preview/preview-directory.tsx @@ -603,7 +603,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) { modtime: new Date().getTime(), mimetype: "directory", }); - } else if (finfo?.dir === "" && finfo?.path) { + } else if (!finfo?.dir && finfo?.path) { entries.unshift({ name: "..", path: "", diff --git a/frontend/app/view/preview/preview-model.tsx b/frontend/app/view/preview/preview-model.tsx index f6daad34b7..b9c69f2d07 100644 --- a/frontend/app/view/preview/preview-model.tsx +++ b/frontend/app/view/preview/preview-model.tsx @@ -211,7 +211,7 @@ export class PreviewModel implements ViewModel { return { elemtype: "iconbutton", icon: "folder-open", - longClick: (e: React.MouseEvent) => { + click: (e: React.MouseEvent) => { const menuItems: ContextMenuItem[] = BOOKMARKS.map((bookmark) => ({ label: `Go to ${bookmark.label} (${bookmark.path})`, click: () => this.goHistory(bookmark.path), @@ -383,7 +383,7 @@ export class PreviewModel implements ViewModel { }); this.metaFilePath = atom((get) => { const file = get(this.blockAtom)?.meta?.file; - if (isBlank(file)) { + if (file == null) { return "~"; } return file; diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index d8847cabf2..19a0556106 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -5,7 +5,7 @@ "ai:timeoutms": 60000, "app:defaultnewblock": "term", "app:tabbar": "top", - "app:confirmquit": true, + "app:confirmquit": false, "app:hideaibutton": false, "term:showsplitbuttons": false, "app:disablectrlshiftarrows": false, @@ -27,7 +27,7 @@ "window:magnifiedblockblurprimarypx": 10, "window:fullscreenonlaunch": false, "window:magnifiedblockblursecondarypx": 2, - "window:confirmclose": true, + "window:confirmclose": false, "window:savelastwindow": true, "telemetry:enabled": true, "term:bellsound": false, diff --git a/pkg/wshrpc/wshremote/wshremote_file.go b/pkg/wshrpc/wshremote/wshremote_file.go index 4c2e5b4ace..e6ea1fccc0 100644 --- a/pkg/wshrpc/wshremote/wshremote_file.go +++ b/pkg/wshrpc/wshremote/wshremote_file.go @@ -361,7 +361,9 @@ func listDrives() ([]*wshrpc.FileInfo, error) { if err != nil { continue } - drives = append(drives, statToFileInfo(drivePath, finfo, false)) + driveInfo := statToFileInfo(drivePath, finfo, false) + driveInfo.Name = string(letter) + ":" + drives = append(drives, driveInfo) } if len(drives) == 0 { return nil, fmt.Errorf("no drives found")