Skip to content

Commit 0734274

Browse files
committed
fix(desktop): use server-side picker for all HTTP connections
Native OS file picker was shown when Desktop connected to a remote server via localhost port forwarding (e.g. ssh -L 4096:localhost:4096 linux-host). The localhost URL caused ServerConnection.local() to return true, triggering the native Electron dialog. A Windows path (e.g. D:\\renpy-workspace) was then sent to the remote Linux server, which rejected it as non-absolute. Fix: replace ServerConnection.local with ServerConnection.builtin in the picker policy. Only the embedded sidecar process is guaranteed to share the OS with the Desktop app. All HTTP connections — including localhost — use the server-side DialogSelectDirectory.
1 parent bace18c commit 0734274

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

packages/app/src/components/directory-picker-policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { ServerConnection } from "@/context/server"
22
import type { Platform } from "@/context/platform"
33

44
export function directoryPickerKind(platform: Platform["platform"], server: ServerConnection.Any) {
5-
if (platform === "desktop" && ServerConnection.local(server)) return "native" as const
5+
if (platform === "desktop" && ServerConnection.builtin(server)) return "native" as const
66
return "server" as const
77
}
Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,50 @@
11
import { describe, expect, test } from "bun:test"
22
import { directoryPickerKind } from "./directory-picker-policy"
33

4-
const local = {
4+
const sidecar = {
55
type: "sidecar",
66
variant: "base",
77
http: { url: "http://localhost:4096" },
88
} as const
9-
const remote = {
9+
10+
const wsl = {
11+
type: "sidecar",
12+
variant: "wsl",
13+
distro: "Ubuntu",
14+
http: { url: "http://localhost:4097" },
15+
} as const
16+
17+
const httpLocalhost = {
18+
type: "http",
19+
http: { url: "http://localhost:4096" },
20+
} as const
21+
22+
const httpRemote = {
23+
type: "http",
24+
http: { url: "http://192.168.1.100:4096" },
25+
} as const
26+
27+
const ssh = {
1028
type: "ssh",
1129
host: "example.test",
1230
http: { url: "http://localhost:4096" },
1331
} as const
1432

1533
describe("directoryPickerKind", () => {
16-
test("uses the native picker only for local desktop projects", () => {
17-
expect(directoryPickerKind("desktop", local)).toBe("native")
18-
expect(directoryPickerKind("desktop", remote)).toBe("server")
19-
expect(directoryPickerKind("web", local)).toBe("server")
34+
test("uses the native picker only for the built-in sidecar", () => {
35+
// Only the embedded sidecar process is guaranteed to share the OS with the Desktop app
36+
expect(directoryPickerKind("desktop", sidecar)).toBe("native")
37+
38+
// All HTTP connections use the server-side picker — a localhost URL could be a
39+
// port-forwarded remote server (e.g. Linux behind SSH tunnel from Windows)
40+
expect(directoryPickerKind("desktop", httpLocalhost)).toBe("server")
41+
expect(directoryPickerKind("desktop", httpRemote)).toBe("server")
42+
43+
// WSL and SSH are always remote filesystems
44+
expect(directoryPickerKind("desktop", wsl)).toBe("server")
45+
expect(directoryPickerKind("desktop", ssh)).toBe("server")
46+
47+
// Web platform never has access to the native picker
48+
expect(directoryPickerKind("web", sidecar)).toBe("server")
2049
})
2150
})

0 commit comments

Comments
 (0)