From c04ce11a749c3d17520a43cfadd5b63cd4380024 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Jul 2026 09:04:57 +0530 Subject: [PATCH] Desktop file chooser integration: when the specified directory does not exist, open file chooser at home directory Fixes #10292 --- docs/changelog.rst | 2 ++ kittens/desktop_ui/portal.go | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 1fa83f7a3..b31e876dd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -191,6 +191,8 @@ Detailed list of changes - Linux: Fix an approx 1MB memory leak when reloading the config introduced in version 0.40.0 (:iss:`10290`) +- Desktop file chooser integration: when the specified directory does not exist, open file chooser at home directory (:iss:`10292`) + 0.48.1 [2026-07-24] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kittens/desktop_ui/portal.go b/kittens/desktop_ui/portal.go index 604bd30db..bfb79ef88 100644 --- a/kittens/desktop_ui/portal.go +++ b/kittens/desktop_ui/portal.go @@ -844,7 +844,18 @@ func (self *Portal) run_file_chooser(cfd ChooseFilesData) (response uint32, resu } } args = append(args, "--write-pid-to", pid_path) - args = append(args, utils.IfElse(cfd.Cwd == "", "~", cfd.Cwd)) + target := cfd.Cwd + if target == "" { + target = "~" + } else { + if st, err := os.Stat(cfd.Cwd); err == nil && st.IsDir() && unix.Access(cfd.Cwd, unix.R_OK|unix.X_OK) == nil { + target = cfd.Cwd + } else { + target = "~" + } + + } + args = append(args, target) cmd := exec.Command(utils.KittyExe(), args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr