GeezerVison is showing github.com — feat(desktop): add signal macOS DMG installer background (#6201) · pingdotgg/t3code@ad11723
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +33Lines changed: 33 additions & 0 deletions - Display the source diff
- Display the rich diff
Collapse file Copy file name to clipboard +64Lines changed: 64 additions & 0 deletions - Display the source diff
- Display the rich diff
Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboardExpand all lines: apps/desktop/scripts/electron-launcher.mjs +17-16Lines changed: 17 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,14 +20,14 @@ export const APP_BUNDLE_ID = isDevelopment | 20 | 20 | ? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}` | 21 | 21 | : "com.t3tools.t3code"; | 22 | 22 | const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"]; | 23 | | -const LAUNCHER_VERSION = 14; | 24 | | -const defaultIconPath = NodePath.join(desktopDir, "resources", "icon.icns"); | | 23 | +const LAUNCHER_VERSION = 15; | 25 | 24 | const developmentMacIconPngPath = NodePath.join( | 26 | 25 | repoRoot, | 27 | 26 | "assets", | 28 | 27 | "dev", | 29 | 28 | "blueprint-macos-1024.png", | 30 | 29 | ); | | 30 | +const productionMacIconPngPath = NodePath.join(repoRoot, "assets", "prod", "black-macos-1024.png"); | 31 | 31 | // oxlint-disable-next-line t3code/no-global-process-runtime -- Standalone launcher script has no Effect runtime. | 32 | 32 | const hostPlatform = NodeOS.platform(); | 33 | 33 |
| @@ -165,15 +165,22 @@ function registerMacLauncherBundle(appBundlePath) { | 165 | 165 | } | 166 | 166 | } | 167 | 167 |
| 168 | | -function ensureDevelopmentIconIcns(runtimeDir) { | 169 | | - const generatedIconPath = NodePath.join(runtimeDir, "icon-dev.icns"); | | 168 | +export function resolveMacLauncherIconPaths(runtimeDir, development = isDevelopment) { | | 169 | + return { | | 170 | + sourceIconPath: development ? developmentMacIconPngPath : productionMacIconPngPath, | | 171 | + generatedIconPath: NodePath.join(runtimeDir, development ? "icon-dev.icns" : "icon-prod.icns"), | | 172 | + }; | | 173 | +} | | 174 | + | | 175 | +function ensureMacIconIcns(runtimeDir) { | | 176 | + const { sourceIconPath, generatedIconPath } = resolveMacLauncherIconPaths(runtimeDir); | 170 | 177 | NodeFS.mkdirSync(runtimeDir, { recursive: true }); | 171 | 178 |
| 172 | | - if (!NodeFS.existsSync(developmentMacIconPngPath)) { | 173 | | - return defaultIconPath; | | 179 | + if (!NodeFS.existsSync(sourceIconPath)) { | | 180 | + throw new Error(`Desktop macOS icon source is missing at ${sourceIconPath}`); | 174 | 181 | } | 175 | 182 |
| 176 | | - const sourceMtimeMs = NodeFS.statSync(developmentMacIconPngPath).mtimeMs; | | 183 | + const sourceMtimeMs = NodeFS.statSync(sourceIconPath).mtimeMs; | 177 | 184 | if ( | 178 | 185 | NodeFS.existsSync(generatedIconPath) && | 179 | 186 | NodeFS.statSync(generatedIconPath).mtimeMs >= sourceMtimeMs | @@ -191,7 +198,7 @@ function ensureDevelopmentIconIcns(runtimeDir) { | 191 | 198 | "-z", | 192 | 199 | String(size), | 193 | 200 | String(size), | 194 | | - developmentMacIconPngPath, | | 201 | + sourceIconPath, | 195 | 202 | "--out", | 196 | 203 | NodePath.join(iconsetDir, `icon_${size}x${size}.png`), | 197 | 204 | ]); | @@ -201,20 +208,14 @@ function ensureDevelopmentIconIcns(runtimeDir) { | 201 | 208 | "-z", | 202 | 209 | String(retinaSize), | 203 | 210 | String(retinaSize), | 204 | | - developmentMacIconPngPath, | | 211 | + sourceIconPath, | 205 | 212 | "--out", | 206 | 213 | NodePath.join(iconsetDir, `icon_${size}x${size}@2x.png`), | 207 | 214 | ]); | 208 | 215 | } | 209 | 216 |
| 210 | 217 | runChecked("iconutil", ["-c", "icns", iconsetDir, "-o", generatedIconPath]); | 211 | 218 | return generatedIconPath; | 212 | | - } catch (error) { | 213 | | - console.warn( | 214 | | - "[desktop-launcher] Failed to generate dev macOS icon, falling back to default icon.", | 215 | | - error, | 216 | | - ); | 217 | | - return defaultIconPath; | 218 | 219 | } finally { | 219 | 220 | NodeFS.rmSync(iconsetRoot, { recursive: true, force: true }); | 220 | 221 | } | @@ -297,7 +298,7 @@ function buildMacLauncher(electronBinaryPath) { | 297 | 298 | const launcherBinaryPath = isDevelopment | 298 | 299 | ? developmentPaths.launcherBinaryPath | 299 | 300 | : runtimeElectronBinaryPath; | 300 | | - const iconPath = isDevelopment ? ensureDevelopmentIconIcns(runtimeDir) : defaultIconPath; | | 301 | + const iconPath = ensureMacIconIcns(runtimeDir); | 301 | 302 | const metadataPath = NodePath.join(runtimeDir, "metadata.json"); | 302 | 303 |
| 303 | 304 | NodeFS.mkdirSync(runtimeDir, { recursive: true }); | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/scripts/electron-launcher.test.mjs +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import { assert, describe, it } from "vite-plus/test"; | 3 | 3 | import { | 4 | 4 | makeDevelopmentLauncherScript, | 5 | 5 | resolveElectronBinaryPath, | | 6 | + resolveMacLauncherIconPaths, | 6 | 7 | resolveMacLauncherPaths, | 7 | 8 | } from "./electron-launcher.mjs"; | 8 | 9 |
| @@ -78,4 +79,14 @@ describe("electron development launcher", () => { | 78 | 79 | ); | 79 | 80 | assert.notInclude(script, "node_modules/electron"); | 80 | 81 | }); | | 82 | + | | 83 | + it("derives launcher icons from canonical development and production assets", () => { | | 84 | + const development = resolveMacLauncherIconPaths("/runtime", true); | | 85 | + const production = resolveMacLauncherIconPaths("/runtime", false); | | 86 | + | | 87 | + assert.match(development.sourceIconPath, /assets\/dev\/blueprint-macos-1024\.png$/); | | 88 | + assert.equal(development.generatedIconPath, "/runtime/icon-dev.icns"); | | 89 | + assert.match(production.sourceIconPath, /assets\/prod\/black-macos-1024\.png$/); | | 90 | + assert.equal(production.generatedIconPath, "/runtime/icon-prod.icns"); | | 91 | + }); | 81 | 92 | }); |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopAssets.test.ts +40Lines changed: 40 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import { assert, describe, it } from "@effect/vitest"; | 3 | 3 | import * as Effect from "effect/Effect"; | 4 | 4 | import * as FileSystem from "effect/FileSystem"; | 5 | 5 | import * as Layer from "effect/Layer"; | | 6 | +import * as Option from "effect/Option"; | 6 | 7 | import * as PlatformError from "effect/PlatformError"; | 7 | 8 |
| 8 | 9 | import * as DesktopAssets from "./DesktopAssets.ts"; | @@ -22,6 +23,45 @@ const environmentLayer = DesktopEnvironment.layer({ | 22 | 23 | }).pipe(Layer.provide(Layer.mergeAll(NodeServices.layer, DesktopConfig.layerTest({})))); | 23 | 24 |
| 24 | 25 | describe("DesktopAssets", () => { | | 26 | + it.effect("uses canonical source-tree icons for unpackaged development", () => | | 27 | + Effect.gen(function* () { | | 28 | + const developmentEnvironmentLayer = DesktopEnvironment.layer({ | | 29 | + dirname: "/repo/apps/desktop/dist-electron", | | 30 | + homeDirectory: "/Users/alice", | | 31 | + platform: "linux", | | 32 | + processArch: "x64", | | 33 | + appVersion: "1.2.3", | | 34 | + appPath: "/repo", | | 35 | + isPackaged: false, | | 36 | + resourcesPath: "/repo/apps/desktop/resources", | | 37 | + runningUnderArm64Translation: false, | | 38 | + }).pipe( | | 39 | + Layer.provide( | | 40 | + Layer.mergeAll( | | 41 | + NodeServices.layer, | | 42 | + DesktopConfig.layerTest({ VITE_DEV_SERVER_URL: "http://localhost:5733" }), | | 43 | + ), | | 44 | + ), | | 45 | + ); | | 46 | + const fileSystemLayer = FileSystem.layerNoop({ | | 47 | + exists: (path) => Effect.succeed(String(path).includes("/assets/dev/")), | | 48 | + }); | | 49 | + const assets = yield* DesktopAssets.DesktopAssets.pipe( | | 50 | + Effect.provide( | | 51 | + DesktopAssets.layer.pipe( | | 52 | + Layer.provide(Layer.merge(fileSystemLayer, developmentEnvironmentLayer)), | | 53 | + ), | | 54 | + ), | | 55 | + ); | | 56 | + | | 57 | + const icons = yield* assets.iconPaths; | | 58 | + | | 59 | + assert.match(Option.getOrThrow(icons.ico), /assets\/dev\/blueprint-windows\.ico$/); | | 60 | + assert.match(Option.getOrThrow(icons.png), /assets\/dev\/blueprint-universal-1024\.png$/); | | 61 | + assert.isTrue(Option.isNone(icons.icns)); | | 62 | + }), | | 63 | + ); | | 64 | + | 25 | 65 | it.effect("preserves the failed asset candidate and filesystem cause", () => | 26 | 66 | Effect.gen(function* () { | 27 | 67 | const fileName = "custom.bin"; | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopAssets.ts +36-7Lines changed: 36 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,35 @@ const resolveResourcePath = Effect.fn("desktop.assets.resolveResourcePath")(func | 61 | 61 | return Option.none<string>(); | 62 | 62 | }); | 63 | 63 |
| | 64 | +const sourceTreeIconFileNames = { | | 65 | + dev: { | | 66 | + ico: "blueprint-windows.ico", | | 67 | + macPng: "blueprint-macos-1024.png", | | 68 | + universalPng: "blueprint-universal-1024.png", | | 69 | + }, | | 70 | + prod: { | | 71 | + ico: "t3-black-windows.ico", | | 72 | + macPng: "black-macos-1024.png", | | 73 | + universalPng: "black-universal-1024.png", | | 74 | + }, | | 75 | +} as const; | | 76 | + | | 77 | +function resolveSourceTreeIconPath( | | 78 | + environment: DesktopEnvironment.DesktopEnvironment["Service"], | | 79 | + ext: keyof DesktopIconPaths, | | 80 | +): string | undefined { | | 81 | + if (environment.isPackaged || ext === "icns") return undefined; | | 82 | + const brand = environment.isDevelopment ? "dev" : "prod"; | | 83 | + const fileNames = sourceTreeIconFileNames[brand]; | | 84 | + const fileName = | | 85 | + ext === "ico" | | 86 | + ? fileNames.ico | | 87 | + : environment.platform === "darwin" | | 88 | + ? fileNames.macPng | | 89 | + : fileNames.universalPng; | | 90 | + return environment.path.join(environment.rootDir, "assets", brand, fileName); | | 91 | +} | | 92 | + | 64 | 93 | const resolveIconPath = Effect.fn("desktop.assets.resolveIconPath")(function* ( | 65 | 94 | ext: keyof DesktopIconPaths, | 66 | 95 | ): Effect.fn.Return< | @@ -70,20 +99,20 @@ const resolveIconPath = Effect.fn("desktop.assets.resolveIconPath")(function* ( | 70 | 99 | > { | 71 | 100 | const fileSystem = yield* FileSystem.FileSystem; | 72 | 101 | const environment = yield* DesktopEnvironment.DesktopEnvironment; | 73 | | - if (environment.isDevelopment && environment.platform === "darwin" && ext === "png") { | 74 | | - const developmentDockIconPath = environment.developmentDockIconPath; | 75 | | - const developmentDockIconExists = yield* fileSystem.exists(developmentDockIconPath).pipe( | | 102 | + const sourceTreeIconPath = resolveSourceTreeIconPath(environment, ext); | | 103 | + if (sourceTreeIconPath !== undefined) { | | 104 | + const sourceTreeIconExists = yield* fileSystem.exists(sourceTreeIconPath).pipe( | 76 | 105 | Effect.mapError( | 77 | 106 | (cause) => | 78 | 107 | new DesktopAssetProbeError({ | 79 | | - fileName: "icon.png", | 80 | | - candidatePath: developmentDockIconPath, | | 108 | + fileName: `icon.${ext}`, | | 109 | + candidatePath: sourceTreeIconPath, | 81 | 110 | cause, | 82 | 111 | }), | 83 | 112 | ), | 84 | 113 | ); | 85 | | - if (developmentDockIconExists) { | 86 | | - return Option.some(developmentDockIconPath); | | 114 | + if (sourceTreeIconExists) { | | 115 | + return Option.some(sourceTreeIconPath); | 87 | 116 | } | 88 | 117 | } | 89 | 118 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopEnvironment.ts -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,7 +82,6 @@ export class DesktopEnvironment extends Context.Service< | 82 | 82 | readonly runtimeInfo: DesktopRuntimeInfo; | 83 | 83 | readonly resolvePickFolderDefaultPath: (rawOptions: unknown) => Option.Option<string>; | 84 | 84 | readonly resolveResourcePathCandidates: (fileName: string) => readonly string[]; | 85 | | - readonly developmentDockIconPath: string; | 86 | 85 | } | 87 | 86 | >()("@t3tools/desktop/app/DesktopEnvironment") {} | 88 | 87 |
| @@ -270,7 +269,6 @@ const make = Effect.fn("desktop.environment.make")(function* ( | 270 | 269 | path.join(resourcesPath, "resources", fileName), | 271 | 270 | path.join(resourcesPath, fileName), | 272 | 271 | ], | 273 | | - developmentDockIconPath: path.join(rootDir, "assets", "dev", "blueprint-macos-1024.png"), | 274 | 272 | }); | 275 | 273 | }); | 276 | 274 |
| |
|