Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Preserve T3 Code identity in macOS development launcher (#4102)

Julius Marminge8b3379952386
diff --git a/apps/desktop/scripts/electron-launcher.mjs b/apps/desktop/scripts/electron-launcher.mjs
index 081ef903a..929afeeab 100644
--- a/apps/desktop/scripts/electron-launcher.mjs
+++ b/apps/desktop/scripts/electron-launcher.mjs
@@ -20,7 +20,7 @@ export const APP_BUNDLE_ID = isDevelopment
? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
: "com.t3tools.t3code";
const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
-const LAUNCHER_VERSION = 12;
+const LAUNCHER_VERSION = 14;
const defaultIconPath = NodePath.join(desktopDir, "resources", "icon.icns");
const developmentMacIconPngPath = NodePath.join(
repoRoot,
@@ -220,11 +220,12 @@ function ensureDevelopmentIconIcns(runtimeDir) {
}
}
-function patchMainBundleInfoPlist(appBundlePath, iconPath) {
+function patchMainBundleInfoPlist(appBundlePath, iconPath, executableName) {
const infoPlistPath = NodePath.join(appBundlePath, "Contents", "Info.plist");
setPlistString(infoPlistPath, "CFBundleDisplayName", APP_DISPLAY_NAME);
setPlistString(infoPlistPath, "CFBundleName", APP_DISPLAY_NAME);
setPlistString(infoPlistPath, "CFBundleIdentifier", APP_BUNDLE_ID);
+ setPlistString(infoPlistPath, "CFBundleExecutable", executableName);
setPlistString(infoPlistPath, "CFBundleIconFile", "icon.icns");
setPlistJson(infoPlistPath, "CFBundleURLTypes", [
{
@@ -277,11 +278,25 @@ function readJson(path) {
}
}
+export function resolveMacLauncherPaths(appBundlePath, displayName = APP_DISPLAY_NAME) {
+ const executableDir = NodePath.join(appBundlePath, "Contents", "MacOS");
+ const launcherExecutableName = `${displayName} Launcher`;
+ return {
+ launcherExecutableName,
+ launcherBinaryPath: NodePath.join(executableDir, launcherExecutableName),
+ runtimeElectronBinaryPath: NodePath.join(executableDir, "Electron"),
+ };
+}
+
function buildMacLauncher(electronBinaryPath) {
const sourceAppBundlePath = NodePath.resolve(NodePath.dirname(electronBinaryPath), "../..");
const runtimeDir = NodePath.join(desktopDir, ".electron-runtime");
const targetAppBundlePath = NodePath.join(runtimeDir, `${APP_DISPLAY_NAME}.app`);
- const targetBinaryPath = NodePath.join(targetAppBundlePath, "Contents", "MacOS", "Electron");
+ const developmentPaths = resolveMacLauncherPaths(targetAppBundlePath);
+ const runtimeElectronBinaryPath = developmentPaths.runtimeElectronBinaryPath;
+ const launcherBinaryPath = isDevelopment
+ ? developmentPaths.launcherBinaryPath
+ : runtimeElectronBinaryPath;
const iconPath = isDevelopment ? ensureDevelopmentIconIcns(runtimeDir) : defaultIconPath;
const metadataPath = NodePath.join(runtimeDir, "metadata.json");
@@ -298,7 +313,8 @@ function buildMacLauncher(electronBinaryPath) {
const currentMetadata = readJson(metadataPath);
if (
- NodeFS.existsSync(targetBinaryPath) &&
+ NodeFS.existsSync(launcherBinaryPath) &&
+ (!isDevelopment || NodeFS.existsSync(runtimeElectronBinaryPath)) &&
currentMetadata &&
JSON.stringify(currentMetadata) === JSON.stringify(expectedMetadata)
) {
@@ -306,10 +322,10 @@ function buildMacLauncher(electronBinaryPath) {
// The launcher also handles protocol activations outside the dev runner,
// so refresh its fallback environment on every launch. Never let a value
// captured by an older parent app override the live dev-runner environment.
- writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath);
+ writeDevelopmentLauncherScript(launcherBinaryPath, runtimeElectronBinaryPath);
}
registerMacLauncherBundle(targetAppBundlePath);
- return targetBinaryPath;
+ return launcherBinaryPath;
}
NodeFS.rmSync(targetAppBundlePath, { recursive: true, force: true });
@@ -321,15 +337,24 @@ function buildMacLauncher(electronBinaryPath) {
recursive: true,
verbatimSymlinks: true,
});
- patchMainBundleInfoPlist(targetAppBundlePath, iconPath);
+ patchMainBundleInfoPlist(
+ targetAppBundlePath,
+ iconPath,
+ isDevelopment ? developmentPaths.launcherExecutableName : "Electron",
+ );
patchHelperBundleInfoPlists(targetAppBundlePath);
if (isDevelopment) {
- writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath);
+ // Keep Electron's native executable inside the branded bundle. Launching the
+ // node_modules copy makes macOS associate the process (and Dock label) with
+ // Electron.app even though this bundle's Info.plist has the T3 Code name.
+ // Its conventional executable name also keeps Electron's default-app runtime
+ // in development mode instead of making app.isPackaged report true.
+ writeDevelopmentLauncherScript(launcherBinaryPath, runtimeElectronBinaryPath);
}
NodeFS.writeFileSync(metadataPath, `${JSON.stringify(expectedMetadata, null, 2)}\n`);
registerMacLauncherBundle(targetAppBundlePath);
- return targetBinaryPath;
+ return launcherBinaryPath;
}
function isLinuxSetuidSandboxConfigured(electronBinaryPath) {
diff --git a/apps/desktop/scripts/electron-launcher.test.mjs b/apps/desktop/scripts/electron-launcher.test.mjs
index 36e9429e4..1c82167ea 100644
--- a/apps/desktop/scripts/electron-launcher.test.mjs
+++ b/apps/desktop/scripts/electron-launcher.test.mjs
@@ -1,6 +1,10 @@
import { assert, describe, it } from "vite-plus/test";
-import { makeDevelopmentLauncherScript, resolveElectronBinaryPath } from "./electron-launcher.mjs";
+import {
+ makeDevelopmentLauncherScript,
+ resolveElectronBinaryPath,
+ resolveMacLauncherPaths,
+} from "./electron-launcher.mjs";
describe("electron development launcher", () => {
it("uses captured values only as fallbacks for a live runner environment", () => {
@@ -45,4 +49,33 @@ describe("electron development launcher", () => {
);
assert.deepEqual(calls, ["ensure", "require:electron"]);
});
+
+ it("keeps the native Electron executable name inside the branded macOS bundle", () => {
+ const paths = resolveMacLauncherPaths(
+ "/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app",
+ "T3 Code (Dev)",
+ );
+
+ assert.equal(paths.launcherExecutableName, "T3 Code (Dev) Launcher");
+ assert.equal(
+ paths.launcherBinaryPath,
+ "/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/T3 Code (Dev) Launcher",
+ );
+ assert.equal(
+ paths.runtimeElectronBinaryPath,
+ "/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/Electron",
+ );
+
+ const script = makeDevelopmentLauncherScript({
+ electronBinaryPath: paths.runtimeElectronBinaryPath,
+ mainEntryPath: "/repo/apps/desktop/dist-electron/main.cjs",
+ desktopRoot: "/repo/apps/desktop",
+ environment: {},
+ });
+ assert.include(
+ script,
+ "exec '/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/Electron'",
+ );
+ assert.notInclude(script, "node_modules/electron");
+ });
});