fix: return clipboard mode from _open_path on headless Linux

Addresses PR review: on a native Linux/SSH session with neither DISPLAY
nor WAYLAND_DISPLAY (and not Docker/WSL), _open_path unconditionally
launched xdg-open and reported success even though no file manager can
open. Mirror open_settings_location: hand the path to the browser for
copying instead. Fixes open_backup_location, open_wildcards_location
and open_sidecar_location together.
This commit is contained in:
Will Miao
2026-09-27 10:05:05 +08:00
parent 7aee964448
commit 485679223b
2 changed files with 44 additions and 0 deletions
+12
View File
@@ -3378,6 +3378,18 @@ class FileSystemHandler:
elif sys.platform == "darwin":
subprocess.Popen(["open", path])
else:
if not _has_gui_display():
# Headless/SSH session: xdg-open cannot open a file
# manager, so hand the path to the browser for copying
# instead of reporting a success that never happened.
return web.json_response(
{
"success": True,
"message": "Headless session: path available for copying",
"path": path,
"mode": "clipboard",
}
)
subprocess.Popen(["xdg-open", path])
return web.json_response(