History

feat(desktop): app icon + share scope dir with CLI (#786)

Two polish fixes after the v1.4.20 launch: 1. App icon - Drop the 2048×2048 executor-icon.png at apps/desktop/build/icon.png so electron-builder picks it up automatically for all platforms (auto-generates .icns for mac, .ico for win, uses the PNG directly for linux). - Switch directories.buildResources from "resources" to "build" so electron-builder looks for build inputs (icon, entitlements plist) in build/ — separated from runtime resources (sidecar binary, web-ui) which stay in resources/ and are wired via extraResources. - Add a resolveLinuxIcon() helper that sets the BrowserWindow icon on Linux at runtime (macOS uses the .app bundle's icon, Windows uses the .exe-embedded icon, but Linux taskbars read it from the window directly). 2. Scope dir = ~/.executor - Sidecar now sets EXECUTOR_SCOPE_DIR + EXECUTOR_DATA_DIR to join(homedir(), ".executor") — same path the CLI uses. - Desktop and CLI share state on the same machine, so sources and secrets set up in one show up in the other. No migration concerns yet since nobody's used v1.4.20's old userData path. - User-facing commands like `executor mcp --scope ~/.executor` stay short and copy-paste-friendly instead of dragging `~/Library/Application Support/sh.executor.desktop` around. Electron's own userData (electron-store, electron-log, window-state) stays separate, pinned to ~/Library/Application Support/Executor (friendly name, no bundle ID in the path).

Rhys Sullivan committed 6 months ago

Commit 2d80d211 parent 760c6c64 files · +41 −17Browse files

Unified · Split

4 files
  1. apps/desktop/build/icon.png +0 −0
  2. apps/desktop/electron-builder.config.ts +4 −1
  3. apps/desktop/src/main/index.ts +26 −7
  4. apps/desktop/src/main/sidecar.ts +12 −10
apps/desktop/build/icon.png+0−0

Binary file not shown.

apps/desktop/electron-builder.config.ts+4−1
@@ -6,7 +6,10 @@ const config: Configuration = { · 5 unmodified lines
6 artifactName: "executor-desktop-${os}-${arch}.${ext}",6 artifactName: "executor-desktop-${os}-${arch}.${ext}",
7 directories: {7 directories: {
8 output: "dist",8 output: "dist",
9 buildResources: "resources",9 // Static build inputs live in build/ (icon.png, entitlements.mac.plist).
10 // Runtime resources staged at build time (sidecar binary, web-ui) live
11 // in resources/ and are wired in via `extraResources` below.
12 buildResources: "build",
10 },13 },
11 files: ["out/**/*", "package.json"],14 files: ["out/**/*", "package.json"],
12 extraResources: [15 extraResources: [
apps/desktop/src/main/index.ts+26−7
@@ -6,14 +6,17 @@ import updater from "electron-updater"; · 5 unmodified lines
6const { autoUpdater } = updater;6const { autoUpdater } = updater;
7import { startSidecar, stopSidecar, type SidecarConnection } from "./sidecar";7import { startSidecar, stopSidecar, type SidecarConnection } from "./sidecar";
8 8
9// Pin userData to an appId-scoped dir BEFORE app.ready so every downstream9// Pin userData to a friendly app-name-scoped dir BEFORE app.ready so every
10// consumer (electron-store, the sidecar's EXECUTOR_SCOPE_DIR, electron-log)10// Electron-side consumer (electron-store, electron-log, window-state) lands
11// agrees on the location. Without this, userData defaults to a path derived11// at a predictable spot. The bundle identifier `sh.executor.desktop` is
12// from package.json#name (`@executor-js/desktop`), which is ugly and changes12// used for the app ID (electron-builder, single-instance lock) but NOT for
13// if we ever rename the workspace package.13// the userData path — we keep that as the readable "Executor" so anyone
14const APP_ID = "sh.executor.desktop";14// who pokes around inside ~/Library/Application Support sees the friendly
15// name. User-mutable executor state (executor.jsonc, data.db) is pinned
16// separately to ~/.executor in main/sidecar.ts; it's intentionally NOT
17// under userData so the path matches the CLI's default.
15app.setName("Executor");18app.setName("Executor");
16app.setPath("userData", join(app.getPath("appData"), APP_ID));19app.setPath("userData", join(app.getPath("appData"), "Executor"));
17 20
18log.initialize({ preload: true });21log.initialize({ preload: true });
19log.transports.file.level = "info";22log.transports.file.level = "info";
@@ -50,6 +53,19 @@ const installBasicAuthHeader = (origin: string, password: string) => { · 30 unmodified lines
50 );53 );
51};54};
52 55
56const resolveLinuxIcon = (): string | undefined => {
57 if (process.platform !== "linux") return undefined;
58 // In packaged AppImage/deb/rpm the icon is referenced through the
59 // desktop-entry file electron-builder generates; this is only used at
60 // BrowserWindow construction time. Resolves to the icon staged by
61 // electron-builder under Resources/ in production, or back to the
62 // source PNG when running unpacked in dev.
63 if (app.isPackaged) {
64 return join(process.resourcesPath, "icon.png");
65 }
66 return join(import.meta.dirname, "..", "..", "build", "icon.png");
67};
68
53const createWindow = async (conn: SidecarConnection) => {69const createWindow = async (conn: SidecarConnection) => {
54 const windowState = windowStateKeeper({70 const windowState = windowStateKeeper({
55 defaultWidth: 1280,71 defaultWidth: 1280,
@@ -58,6 +74,8 @@ const createWindow = async (conn: SidecarConnection) => { · 2 unmodified lines
58 74
59 installBasicAuthHeader(conn.baseUrl, conn.authPassword);75 installBasicAuthHeader(conn.baseUrl, conn.authPassword);
60 76
77 const linuxIcon = resolveLinuxIcon();
78
61 mainWindow = new BrowserWindow({79 mainWindow = new BrowserWindow({
62 x: windowState.x,80 x: windowState.x,
63 y: windowState.y,81 y: windowState.y,
@@ -68,6 +86,7 @@ const createWindow = async (conn: SidecarConnection) => { · 4 unmodified lines
68 show: false,86 show: false,
69 backgroundColor: "#0a0a0a",87 backgroundColor: "#0a0a0a",
70 autoHideMenuBar: true,88 autoHideMenuBar: true,
89 ...(linuxIcon ? { icon: linuxIcon } : {}),
71 webPreferences: {90 webPreferences: {
72 contextIsolation: true,91 contextIsolation: true,
73 nodeIntegration: false,92 nodeIntegration: false,
apps/desktop/src/main/sidecar.ts+12−10
@@ -14,6 +14,7 @@ · 13 unmodified lines
14import { spawn, type ChildProcess } from "node:child_process";14import { spawn, type ChildProcess } from "node:child_process";
15import { randomBytes } from "node:crypto";15import { randomBytes } from "node:crypto";
16import { existsSync, mkdirSync } from "node:fs";16import { existsSync, mkdirSync } from "node:fs";
17import { homedir } from "node:os";
17import { resolve, join } from "node:path";18import { resolve, join } from "node:path";
18import { app } from "electron";19import { app } from "electron";
19 20
@@ -64,14 +65,15 @@ export async function startSidecar(options: StartOptions = {}): Promise<SidecarC · 44 unmodified lines
64 );65 );
65 }66 }
66 67
67 // Pin all user-mutable state (executor.jsonc, data.db, migrations) to the68 // executor.jsonc and data.db go to ~/.executor — the same path the CLI's
68 // per-user Electron userData dir (mac: ~/Library/Application Support/Executor,69 // `executor web` uses. Desktop and CLI share state on the same machine so
69 // win: %APPDATA%/Executor, linux: ~/.config/Executor). app.setPath in70 // sources/secrets/policies set up in one show up in the other, and
70 // main/index.ts pins this to a stable appId-scoped path that survives71 // user-facing commands like `executor mcp --scope ~/.executor` stay
71 // auto-updates; defaulting cwd into process.resourcesPath (the app bundle)72 // copy-paste-friendly. Electron's userData (set in main/index.ts) is
72 // would put writes inside a read-only signed bundle.73 // still used for electron-store, electron-log, and window-state — those
73 const userDataPath = app.getPath("userData");74 // stay app-scoped to avoid colliding with anything else under HOME.
74 mkdirSync(userDataPath, { recursive: true });75 const scopeDir = join(homedir(), ".executor");
76 mkdirSync(scopeDir, { recursive: true });
75 77
76 const child = spawn(command, args, {78 const child = spawn(command, args, {
77 cwd,79 cwd,
@@ -82,8 +84,8 @@ export async function startSidecar(options: StartOptions = {}): Promise<SidecarC · 4 unmodified lines
82 EXECUTOR_HOST: hostname,84 EXECUTOR_HOST: hostname,
83 EXECUTOR_AUTH_PASSWORD: authPassword,85 EXECUTOR_AUTH_PASSWORD: authPassword,
84 EXECUTOR_CLIENT_DIR: clientDir,86 EXECUTOR_CLIENT_DIR: clientDir,
85 EXECUTOR_SCOPE_DIR: userDataPath,87 EXECUTOR_SCOPE_DIR: scopeDir,
86 EXECUTOR_DATA_DIR: userDataPath,88 EXECUTOR_DATA_DIR: scopeDir,
87 },89 },
88 });90 });
89 91

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t