Skip to content

Commit fe46e21

Browse files
fix(desktop): register t3code protocol across packages
1 parent 054e6c8 commit fe46e21

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

scripts/build-desktop-artifact.test.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
499499
assert.notInclude(error.message, secret);
500500
});
501501

502-
it.effect("adds passkey entitlements and both renderer protocols to signed macOS builds", () =>
502+
it.effect("adds passkey entitlements and the external protocol to signed macOS builds", () =>
503503
Effect.gen(function* () {
504504
const config = yield* createBuildConfig("mac", "dmg", "1.2.3", true, false, undefined, {
505505
entitlementsPath: "/tmp/entitlements.mac.plist",
@@ -510,9 +510,30 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
510510
assert.equal(config.appId, "com.t3tools.t3code");
511511
assert.equal(mac.entitlements, "/tmp/entitlements.mac.plist");
512512
assert.equal(mac.provisioningProfile, "/tmp/t3code.provisionprofile");
513-
assert.deepStrictEqual(mac.protocols, [
514-
{ name: "T3 Code", schemes: ["t3code", "t3code-dev"] },
515-
]);
513+
assert.deepStrictEqual(config.protocols, [{ name: "T3 Code", schemes: ["t3code"] }]);
514+
assert.notProperty(mac, "protocols");
515+
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
516+
);
517+
518+
it.effect("declares the external protocol for Linux desktop integration", () =>
519+
Effect.gen(function* () {
520+
const config = yield* createBuildConfig(
521+
"linux",
522+
"AppImage",
523+
"1.2.3",
524+
false,
525+
false,
526+
undefined,
527+
undefined,
528+
);
529+
530+
const linux = config.linux as Record<string, unknown>;
531+
assert.deepStrictEqual(config.protocols, [{ name: "T3 Code", schemes: ["t3code"] }]);
532+
assert.notProperty(linux, "protocols");
533+
assert.notProperty(
534+
(linux.desktop as { readonly entry: Record<string, unknown> }).entry,
535+
"MimeType",
536+
);
516537
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
517538
);
518539

@@ -529,6 +550,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
529550
);
530551

531552
const win = config.win as Record<string, unknown>;
553+
assert.deepStrictEqual(config.protocols, [{ name: "T3 Code", schemes: ["t3code"] }]);
532554
assert.equal(win.icon, "icon.ico");
533555
assert.equal(win.signAndEditExecutable, true);
534556
assert.notProperty(win, "azureSignOptions");

scripts/build-desktop-artifact.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,15 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
14221422
appId: DESKTOP_APP_ID,
14231423
productName: resolveDesktopProductName(version),
14241424
artifactName: "T3-Code-${version}-${arch}.${ext}",
1425+
// electron-builder writes this into macOS CFBundleURLTypes and Linux
1426+
// x-scheme-handler metadata. Windows NSIS builds register the same scheme
1427+
// at runtime through app.setAsDefaultProtocolClient.
1428+
protocols: [
1429+
{
1430+
name: "T3 Code",
1431+
schemes: ["t3code"],
1432+
},
1433+
],
14251434
directories: {
14261435
buildResources: "apps/desktop/resources",
14271436
},
@@ -1458,12 +1467,6 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
14581467
target: target === "dmg" ? [target, "zip"] : [target],
14591468
icon: "icon.icns",
14601469
category: "public.app-category.developer-tools",
1461-
protocols: [
1462-
{
1463-
name: "T3 Code",
1464-
schemes: ["t3code", "t3code-dev"],
1465-
},
1466-
],
14671470
...(macPasskeySigning
14681471
? {
14691472
entitlements: macPasskeySigning.entitlementsPath,
@@ -1482,17 +1485,8 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
14821485
desktop: {
14831486
entry: {
14841487
StartupWMClass: "t3code",
1485-
// Register the external deep-link scheme so xdg-open can launch T3.
1486-
// electron-builder keeps %U on Exec when MimeType is present.
1487-
MimeType: "x-scheme-handler/t3code;",
14881488
},
14891489
},
1490-
protocols: [
1491-
{
1492-
name: "T3 Code",
1493-
schemes: ["t3code"],
1494-
},
1495-
],
14961490
};
14971491
}
14981492

0 commit comments

Comments
 (0)