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
66 artifactName: "executor-desktop-${os}-${arch}.${ext}",
77 directories: {
88 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",
1013 },
1114 files: ["out/**/*", "package.json"],
1215 extraResources: [
apps/desktop/src/main/index.ts+26−7
@@ -6,14 +6,17 @@ import updater from "electron-updater"; · 5 unmodified lines
66 const { autoUpdater } = updater;
77 import { startSidecar, stopSidecar, type SidecarConnection } from "./sidecar";
88
9−// Pin userData to an appId-scoped dir BEFORE app.ready so every downstream
10−// consumer (electron-store, the sidecar's EXECUTOR_SCOPE_DIR, electron-log)
11−// agrees on the location. Without this, userData defaults to a path derived
12−// from package.json#name (`@executor-js/desktop`), which is ugly and changes
13−// if we ever rename the workspace package.
14−const APP_ID = "sh.executor.desktop";
9+// Pin userData to a friendly app-name-scoped dir BEFORE app.ready so every
10+// Electron-side consumer (electron-store, electron-log, window-state) lands
11+// at a predictable spot. The bundle identifier `sh.executor.desktop` is
12+// used for the app ID (electron-builder, single-instance lock) but NOT for
13+// the userData path — we keep that as the readable "Executor" so anyone
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.
1518 app.setName("Executor");
16−app.setPath("userData", join(app.getPath("appData"), APP_ID));
19+app.setPath("userData", join(app.getPath("appData"), "Executor"));
1720
1821 log.initialize({ preload: true });
1922 log.transports.file.level = "info";
@@ -50,6 +53,19 @@ const installBasicAuthHeader = (origin: string, password: string) => { · 30 unmodified lines
5053 );
5154 };
5255
56+const 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+
5369 const createWindow = async (conn: SidecarConnection) => {
5470 const windowState = windowStateKeeper({
5571 defaultWidth: 1280,
@@ -58,6 +74,8 @@ const createWindow = async (conn: SidecarConnection) => { · 2 unmodified lines
5874
5975 installBasicAuthHeader(conn.baseUrl, conn.authPassword);
6076
77+ const linuxIcon = resolveLinuxIcon();
78+
6179 mainWindow = new BrowserWindow({
6280 x: windowState.x,
6381 y: windowState.y,
@@ -68,6 +86,7 @@ const createWindow = async (conn: SidecarConnection) => { · 4 unmodified lines
6886 show: false,
6987 backgroundColor: "#0a0a0a",
7088 autoHideMenuBar: true,
89+ ...(linuxIcon ? { icon: linuxIcon } : {}),
7190 webPreferences: {
7291 contextIsolation: true,
7392 nodeIntegration: false,
apps/desktop/src/main/sidecar.ts+12−10
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 import { spawn, type ChildProcess } from "node:child_process";
1515 import { randomBytes } from "node:crypto";
1616 import { existsSync, mkdirSync } from "node:fs";
17+import { homedir } from "node:os";
1718 import { resolve, join } from "node:path";
1819 import { app } from "electron";
1920
@@ -64,14 +65,15 @@ export async function startSidecar(options: StartOptions = {}): Promise<SidecarC · 44 unmodified lines
6465 );
6566 }
6667
67− // Pin all user-mutable state (executor.jsonc, data.db, migrations) to the
68− // per-user Electron userData dir (mac: ~/Library/Application Support/Executor,
69− // win: %APPDATA%/Executor, linux: ~/.config/Executor). app.setPath in
70− // main/index.ts pins this to a stable appId-scoped path that survives
71− // auto-updates; defaulting cwd into process.resourcesPath (the app bundle)
72− // would put writes inside a read-only signed bundle.
73− const userDataPath = app.getPath("userData");
74− mkdirSync(userDataPath, { recursive: true });
68+ // executor.jsonc and data.db go to ~/.executor — the same path the CLI's
69+ // `executor web` uses. Desktop and CLI share state on the same machine so
70+ // sources/secrets/policies set up in one show up in the other, and
71+ // user-facing commands like `executor mcp --scope ~/.executor` stay
72+ // copy-paste-friendly. Electron's userData (set in main/index.ts) is
73+ // still used for electron-store, electron-log, and window-state — those
74+ // stay app-scoped to avoid colliding with anything else under HOME.
75+ const scopeDir = join(homedir(), ".executor");
76+ mkdirSync(scopeDir, { recursive: true });
7577
7678 const child = spawn(command, args, {
7779 cwd,
@@ -82,8 +84,8 @@ export async function startSidecar(options: StartOptions = {}): Promise<SidecarC · 4 unmodified lines
8284 EXECUTOR_HOST: hostname,
8385 EXECUTOR_AUTH_PASSWORD: authPassword,
8486 EXECUTOR_CLIENT_DIR: clientDir,
85− EXECUTOR_SCOPE_DIR: userDataPath,
86− EXECUTOR_DATA_DIR: userDataPath,
87+ EXECUTOR_SCOPE_DIR: scopeDir,
88+ EXECUTOR_DATA_DIR: scopeDir,
8789 },
8890 });
8991

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