The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): middle-click paste ignores the GNOME key outside GNOME (#38943)
Co-authored-by: user <user@qubes-os.org> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Christian R. Kounatze committed
Nov 19, 2026 at 07:10 UTC
5db8cca50a03e23dcc1cabb869962db7228652e3
2 files changed
+63
-21
apps/desktop/src/app/DesktopPrimaryPaste.test.ts
+45
-14
@@ -6,13 +6,16 @@ import * as Sink from "effect/Sink";
6
import * as Stream from "effect/Stream";
7
import * as TestClock from "effect/testing/TestClock";
8
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
9
+import * as HostProcess from "@t3tools/shared/HostProcess";
10
11
import { readGtkPrimaryPasteEnabled } from "./DesktopPrimaryPaste.ts";
12
13
const encoder = new TextEncoder();
14
14
-const spawnerWithStdout = (stdout: Stream.Stream<Uint8Array>) =>
15
- ChildProcessSpawner.make(() =>
15
+const spawnerWithStdout = (
16
+ stdout: Stream.Stream<Uint8Array> | ((command: string) => Stream.Stream<Uint8Array>),
17
+) =>
18
+ ChildProcessSpawner.make((command) =>
19
Effect.succeed(
20
ChildProcessSpawner.makeHandle({
21
pid: ChildProcessSpawner.ProcessId(1),
@@ -21,7 +24,10 @@ const spawnerWithStdout = (stdout: Stream.Stream<Uint8Array>) =>
24
kill: () => Effect.void,
25
unref: Effect.succeed(Effect.void),
26
stdin: Sink.drain,
24
- stdout,
27
+ stdout:
28
+ typeof stdout === "function"
29
+ ? stdout(command._tag === "StandardCommand" ? command.command : "")
30
+ : stdout,
31
stderr: Stream.empty,
32
all: Stream.empty,
33
getInputFd: () => Sink.drain,
@@ -30,9 +36,20 @@ const spawnerWithStdout = (stdout: Stream.Stream<Uint8Array>) =>
36
),
37
);
38
33
-const read = (spawner: ChildProcessSpawner.ChildProcessSpawner["Service"]) =>
39
+const notFound = PlatformError.systemError({
40
+ _tag: "NotFound",
41
+ module: "ChildProcess",
42
+ method: "spawn",
43
+ description: "not found",
44
+});
45
+
46
+const read = (
47
+ spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],
48
+ desktop = "ubuntu:GNOME",
49
+) =>
50
readGtkPrimaryPasteEnabled.pipe(
51
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
52
+ Effect.provideService(HostProcess.Environment, { XDG_CURRENT_DESKTOP: desktop }),
53
);
54
55
describe("readGtkPrimaryPasteEnabled", () => {
@@ -45,18 +62,32 @@ describe("readGtkPrimaryPasteEnabled", () => {
62
}),
63
);
64
48
- it.effect("stays enabled when gsettings cannot run", () =>
65
+ it.effect("outside GNOME, honours only a value the user set", () =>
66
Effect.gen(function* () {
50
- const missing = ChildProcessSpawner.make(() =>
51
- Effect.fail(
52
- PlatformError.systemError({
53
- _tag: "NotFound",
54
- module: "ChildProcess",
55
- method: "spawn",
56
- description: "gsettings not found",
57
- }),
58
- ),
67
+ // gsettings reports the schema default, which only GNOME applies; dconf prints nothing when unset.
68
+ const unset = spawnerWithStdout((command) =>
69
+ command === "gsettings" ? Stream.make(encoder.encode("false\n")) : Stream.empty,
70
+ );
71
+ assert.isFalse(yield* read(unset, "ubuntu:GNOME"));
72
+ assert.isTrue(yield* read(unset, "XFCE"));
73
+ assert.isTrue(yield* read(unset, ""));
74
+ const userSet = spawnerWithStdout((command) =>
75
+ command === "dconf" ? Stream.make(encoder.encode("false\n")) : Stream.empty,
76
+ );
77
+ assert.isFalse(yield* read(userSet, "Hyprland"));
78
+ // Without dconf-cli, the effective value is the best evidence of an opt-out.
79
+ const noDconf = ChildProcessSpawner.make((command) =>
80
+ command._tag === "StandardCommand" && command.command === "dconf"
81
+ ? Effect.fail(notFound)
82
+ : spawnerWithStdout(Stream.make(encoder.encode("false\n"))).spawn(command),
83
);
84
+ assert.isFalse(yield* read(noDconf, "XFCE"));
85
+ }),
86
+ );
87
+
88
+ it.effect("stays enabled when gsettings cannot run", () =>
89
+ Effect.gen(function* () {
90
+ const missing = ChildProcessSpawner.make(() => Effect.fail(notFound));
91
assert.isTrue(yield* read(missing));
92
}),
93
);
apps/desktop/src/app/DesktopPrimaryPaste.ts
+18
-7
@@ -13,15 +13,26 @@ export class DesktopPrimaryPaste extends Context.Service<
13
>()("@t3tools/desktop/app/DesktopPrimaryPaste") {}
14
15
// Chrome applies gtk-enable-primary-paste from chrome/, which Electron does not include.
16
+// GNOME applies the key's schema default (false since gsettings-desktop-schemas 50); elsewhere
17
+// only a value the user set is a choice. `dconf read` prints nothing for an unset key, but it is
18
+// an optional package (dconf-cli), so without it fall back to the effective value.
19
+const gsettingsQuery = ChildProcess.make(
20
+ "gsettings",
21
+ ["get", "org.gnome.desktop.interface", "gtk-enable-primary-paste"],
22
+ { stdin: "ignore", stderr: "ignore" },
23
+);
24
+const dconfQuery = ChildProcess.make(
25
+ "dconf",
26
+ ["read", "/org/gnome/desktop/interface/gtk-enable-primary-paste"],
27
+ { stdin: "ignore", stderr: "ignore" },
28
+);
29
+
30
export const readGtkPrimaryPasteEnabled = Effect.gen(function* () {
31
+ const env = yield* HostProcess.Environment;
32
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
18
- const output = yield* spawner.string(
19
- ChildProcess.make(
20
- "gsettings",
21
- ["get", "org.gnome.desktop.interface", "gtk-enable-primary-paste"],
22
- { stdin: "ignore", stderr: "ignore" },
23
- ),
24
- );
33
+ const output = yield* env.XDG_CURRENT_DESKTOP?.split(":").includes("GNOME")
34
+ ? spawner.string(gsettingsQuery)
35
+ : spawner.string(dconfQuery).pipe(Effect.catch(() => spawner.string(gsettingsQuery)));
36
return output.trim() !== "false";
37
}).pipe(
38
Effect.timeout("2 seconds"),