The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 01:45 UTC
fix(desktop): Linux URL handler quotes the Exec path only when it must (#16670)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Igor Makowski committed
Oct 19, 2026 at 22:25 UTC
29d46101f3e5fc488097fd6c0a5e32a4aad1a8c3
3 files changed
+34
-4
apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
+26
-2
@@ -179,6 +179,25 @@ describe("DesktopLinuxUrlHandler", () => {
179
assert.include(entry, "Icon=/home/al ice/icons/T3\\\\x.png");
180
});
181
182
+ it.each([
183
+ {
184
+ execTarget: "/opt/T3(beta)/t3code.AppImage",
185
+ execLine: 'Exec="/opt/T3(beta)/t3code.AppImage" %U',
186
+ },
187
+ {
188
+ execTarget: "/opt/t3%20code/t3code.AppImage",
189
+ execLine: "Exec=/opt/t3%%20code/t3code.AppImage %U",
190
+ },
191
+ ])("renders the handler Exec line for $execTarget", ({ execTarget, execLine }) => {
192
+ const entry = DesktopLinuxUrlHandler.renderUrlHandlerDesktopEntry({
193
+ displayName: "T3 Code",
194
+ execTarget,
195
+ scheme: "t3code",
196
+ });
197
+
198
+ assert.include(entry.split("\n"), execLine);
199
+ });
200
+
201
it("carries structured context on registration errors", () => {
202
const writeError = new DesktopLinuxUrlHandler.DesktopLinuxUrlHandlerRegistrationError({
203
step: "write-desktop-entry",
@@ -222,7 +241,7 @@ describe("DesktopLinuxUrlHandler", () => {
241
);
242
assert.include(
243
recorded.files[0]?.content,
225
- 'Exec="/home/alice/Applications/T3-Code.AppImage" %U',
244
+ "Exec=/home/alice/Applications/T3-Code.AppImage %U",
245
);
246
assert.include(recorded.files[0]?.content, "MimeType=x-scheme-handler/t3code;");
247
assert.deepEqual(recorded.commands, [
@@ -247,7 +266,12 @@ describe("DesktopLinuxUrlHandler", () => {
266
267
assert.include(
268
recorded.files[0]?.content,
250
- `Exec=${DesktopLinuxUrlHandler.escapeDesktopEntryExecArgument(process.execPath)} %U`,
269
+ DesktopLinuxUrlHandler.renderUrlHandlerDesktopEntry({
270
+ displayName: "T3 Code (Alpha)",
271
+ execTarget: process.execPath,
272
+ scheme: "t3code",
273
+ iconPath: "/home/alice/.local/share/icons/com.t3tools.T3Code.desktop.png",
274
+ }),
275
);
276
});
277
});
apps/desktop/src/app/DesktopLinuxUrlHandler.ts
+7
-1
@@ -75,6 +75,12 @@ export function escapeDesktopEntryExecArgument(value: string): string {
75
return escapeDesktopEntryString(`"${quoted}"`);
76
}
77
78
+// Legacy xdg-open looks up the first Exec word without unquoting it.
79
+const escapeUrlHandlerExecTarget = (value: string): string =>
80
+ /[ \t\n"'\\><~|&;$*?#()`]/.test(value)
81
+ ? escapeDesktopEntryExecArgument(value)
82
+ : escapeDesktopEntryString(value.replaceAll("%", "%%"));
83
+
84
// The AppImage integration entry owns the window identity. This
85
// hidden URL-only entry must not compete with it for StartupWMClass matching.
86
export function renderUrlHandlerDesktopEntry(input: {
@@ -87,7 +93,7 @@ export function renderUrlHandlerDesktopEntry(input: {
93
"[Desktop Entry]",
94
"Type=Application",
95
`Name=${escapeDesktopEntryString(input.displayName)}`,
90
- `Exec=${escapeDesktopEntryExecArgument(input.execTarget)} %U`,
96
+ `Exec=${escapeUrlHandlerExecTarget(input.execTarget)} %U`,
97
...(input.iconPath === undefined ? [] : [`Icon=${escapeDesktopEntryString(input.iconPath)}`]),
98
"Terminal=false",
99
"NoDisplay=true",
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
+1
-1
@@ -174,7 +174,7 @@ describe("DesktopPreReadyPlatform", () => {
174
);
175
const identity = yield* Effect.promise(() => portalIdentity);
176
assert.equal(identity.desktopName, "com.t3tools.T3Code.desktop");
177
- assert.include(identity.desktopEntry ?? "", 'Exec="/Applications/current.AppImage" %U');
177
+ assert.include(identity.desktopEntry ?? "", "Exec=/Applications/current.AppImage %U");
178
assert.include(identity.desktopEntry ?? "", "Name=T3 Code (Beta)");
179
assert.include(identity.desktopEntry ?? "", "MimeType=x-scheme-handler/t3code;");
180
assert.include(