From a8ccef0ad3c0bae8b91bff85445d99301cd005ac Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Sun, 22 Nov 2026 21:44:24 +0900 Subject: [PATCH 1/4] fix(nix): show the T3 desktop app as T3 instead of Electron macOS names the Dock and Cmd+Tab entry after the bundle that holds the running binary. llm-agents' launcher execs nixpkgs' Electron.app, so the app showed as Electron. Assemble a T3 bundle around a copy of the same Electron with the wrappers' arguments and PATH, and re-sign it ad-hoc. Refs #494 Co-Authored-By: Claude Opus 5.5 --- ...e_the_t3_desktop_app_bundle_in_dotfiles.md | 20 ++++++ nix/checks.nix | 43 +++++++++++++ nix/home/default.nix | 5 +- nix/packages/t3code_desktop.nix | 63 +++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md create mode 100644 nix/packages/t3code_desktop.nix diff --git a/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md b/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md new file mode 100644 index 0000000..bb164b4 --- /dev/null +++ b/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md @@ -0,0 +1,20 @@ +--- +status: proposed +date: 2026-11-22 +--- + +# ADR-0046: Assemble the T3 desktop app bundle in dotfiles + +In the context of the T3 Code desktop app from `llm-agents` +([#494](https://github.com/furedea/dotfiles/issues/494)), facing its `.app` being a launcher that +execs the binary inside nixpkgs' `Electron.app`, so that macOS names the running process after that +bundle and shows "Electron" with Electron's icon in the Dock, Cmd+Tab and the menu bar, we decided +for a dotfiles package (`nix/packages/t3code_desktop.nix`) that copies the `Electron.app` of the +Electron `llm-agents` builds T3 against, renames it to T3 with T3's identifier and icon, puts a +launcher with the `llm-agents` wrappers' arguments and PATH in it, and re-signs it ad-hoc, and +against keeping the `llm-agents` `t3code-desktop` package or waiting for an upstream change, so that +the running Electron lives in a bundle that is T3 while T3's code, version and provider PATH +(including the signed Codex of ADR-0041) still come from `llm-agents`, accepting that dotfiles now +duplicates the wrappers' arguments, takes Electron from the `llm-agents` nixpkgs input, and stores a +second copy of `Electron.app`; the `t3-desktop-app-bundle` check fails when the PATH, app directory +or Electron version drifts from `llm-agents`. diff --git a/nix/checks.nix b/nix/checks.nix index 9c31a8e..c55489c 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -36,6 +36,11 @@ let t3Package = builtins.head ( builtins.filter (package: (package.pname or "") == "t3code") mbpHome.home.packages ); + t3DesktopPackage = builtins.head ( + builtins.filter ( + package: (package.pname or package.name or "") == "t3code-desktop" + ) mbpHome.home.packages + ); t3ServicePath = lib.splitString ":" t3Service.EnvironmentVariables.PATH; t3ServiceState = "${mbpHome.home.homeDirectory}/.t3"; claudePackage = inputs.llm-agents.packages.${pkgs.stdenv.hostPlatform.system}.claude-code; @@ -533,6 +538,44 @@ in touch "$out" ''; + # macOS names the Dock and Cmd+Tab entry after the bundle of the running binary, so the + # launcher must exec the Electron inside the T3 bundle with the llm-agents wrapper's environment. + t3-desktop-app-bundle = + pkgs.runCommand "t3-desktop-app-bundle" + { + nativeBuildInputs = [ pkgs.cctools ]; + app = "${t3DesktopPackage}/Applications/T3 Code (Beta).app"; + upstreamApp = "${t3Package.desktop}/Applications/T3 Code (Beta).app"; + upstreamLauncher = "${t3Package.desktop}/bin/t3code-desktop"; + unwrappedLauncher = "${t3Package.unwrapped.desktop}/bin/t3code-desktop"; + appDirectory = "${t3Package.unwrapped.desktop}/libexec/t3code/apps/desktop"; + signedCodex = lib.makeBinPath [ codexPackage ]; + } + '' + info() { /usr/bin/plutil -extract "$2" raw -o - "$1/Contents/Info.plist"; } + wrapperPath() { strings "$1" | sed -n "s/^ *--prefix 'PATH' ':' '\(.*\)' .*$/\1/p"; } + test "$(info "$app" CFBundleName)" = 'T3 Code (Beta)' + test "$(info "$app" CFBundleDisplayName)" = 'T3 Code (Beta)' + test "$(info "$app" CFBundleIdentifier)" = "$(info "$upstreamApp" CFBundleIdentifier)" + cmp "$app/Contents/Resources/$(info "$app" CFBundleIconFile)" "$upstreamApp/Contents/Resources/t3code.icns" + + launcher="$app/Contents/MacOS/$(info "$app" CFBundleExecutable)" + test -f "$launcher" && test -x "$launcher" && test ! -L "$launcher" + strings "$launcher" | grep -qF "$app/Contents/MacOS/Electron" + strings "$launcher" | grep -qF "$appDirectory" + test -n "$(wrapperPath "$upstreamLauncher")" + test "$(wrapperPath "$launcher")" = "$(wrapperPath "$upstreamLauncher")" + wrapperPath "$launcher" | tr ':' '\n' | grep -qxF "$signedCodex" + + # Electron looks its helpers up as "Electron Helper*.app". + test -x "$app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper" + upstreamElectron=$(strings "$unwrappedLauncher" | grep -m1 -oE '/nix/store/[^ ]*-electron-[^/ ]*/bin/electron') + test "$(info "$app" CFBundleVersion)" = "$(info "''${upstreamElectron%/bin/electron}/Applications/Electron.app" CFBundleVersion)" + + /usr/bin/codesign --verify --deep --strict "$app" + touch "$out" + ''; + # Skills are generated by running the installed Darwin CLIs, so only a build proves the bundled text. automation-cli-skills = pkgs.runCommand "automation-cli-skills" diff --git a/nix/home/default.nix b/nix/home/default.nix index a664956..706c528 100644 --- a/nix/home/default.nix +++ b/nix/home/default.nix @@ -44,7 +44,10 @@ let ] ++ lib.filter (provider: (provider.pname or "") != "codex") t3codeUpstream.providerPackages; }; - t3codeDesktopPackage = llm-agents.packages.${system}.t3code-desktop.override { + # The Dock shows T3, not Electron, only when the bundle holds the Electron it runs (#494). + # llm-agents builds T3 against the Electron of its own nixpkgs, not the dotfiles one. + t3codeDesktopPackage = pkgs.callPackage ../packages/t3code_desktop.nix { + inherit (llm-agents.inputs.nixpkgs.legacyPackages.${system}) electron_44; t3code = t3codePackage; }; agentDesktopPackage = pkgs.callPackage ../packages/agent_desktop.nix { }; diff --git a/nix/packages/t3code_desktop.nix b/nix/packages/t3code_desktop.nix new file mode 100644 index 0000000..2d221e3 --- /dev/null +++ b/nix/packages/t3code_desktop.nix @@ -0,0 +1,63 @@ +{ + electron_44, + lib, + makeBinaryWrapper, + stdenvNoCC, + t3code, +}: + +# macOS names the Dock and Cmd+Tab entry after the bundle that holds the running binary, so +# llm-agents' launcher, which execs nixpkgs' Electron.app, shows up as "Electron". This copies +# that Electron.app, renames it to T3, and execs the copy's own Electron with T3's app directory. +let + inherit (t3code.unwrapped) appName; + upstreamApp = "${t3code.desktop}/Applications/${appName}.app"; + appDirectory = "${t3code.unwrapped.desktop}/libexec/t3code/apps/desktop"; +in +stdenvNoCC.mkDerivation { + pname = "t3code-desktop"; + inherit (t3code) version; + + dontUnpack = true; + # Fixup would strip or rewrite Mach-O files after the ad-hoc signature is applied. + dontFixup = true; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + installPhase = '' + runHook preInstall + + app="$out/Applications/${appName}.app" + mkdir -p "$out/Applications" "$out/bin" + cp -R ${electron_44}/Applications/Electron.app "$app" + chmod -R u+w "$app" + + install -m444 "${upstreamApp}/Contents/Resources/t3code.icns" "$app/Contents/Resources/t3code.icns" + plist="$app/Contents/Info.plist" + identifier=$(/usr/bin/plutil -extract CFBundleIdentifier raw -o - "${upstreamApp}/Contents/Info.plist") + /usr/bin/plutil -replace CFBundleName -string "${appName}" "$plist" + /usr/bin/plutil -replace CFBundleDisplayName -string "${appName}" "$plist" + /usr/bin/plutil -replace CFBundleIdentifier -string "$identifier" "$plist" + /usr/bin/plutil -replace CFBundleIconFile -string t3code.icns "$plist" + /usr/bin/plutil -replace CFBundleExecutable -string "${appName}" "$plist" + + # Same arguments and PATH as llm-agents' two wrappers, which keeps the signed Codex (ADR-0041). + makeWrapper "$app/Contents/MacOS/Electron" "$app/Contents/MacOS/${appName}" \ + --add-flags ${lib.escapeShellArg appDirectory} \ + --prefix PATH : ${lib.escapeShellArg (lib.makeBinPath t3code.providerPackages)} \ + --inherit-argv0 + ln -s "../Applications/${appName}.app/Contents/MacOS/${appName}" "$out/bin/t3code-desktop" + ln -s ${t3code.desktop}/share "$out/share" + + # Editing Info.plist and adding the launcher invalidate the copied signature. + /usr/bin/codesign --force --deep --sign - "$app" + + runHook postInstall + ''; + + meta = t3code.meta // { + description = "T3 Code desktop app bundled under its own name and icon"; + mainProgram = "t3code-desktop"; + platforms = [ "aarch64-darwin" ]; + }; +} From 7ceb3deba631e143f0cc288693c2a3a8d8a6e373 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Sun, 22 Nov 2026 23:15:12 +0900 Subject: [PATCH 2/4] docs(adr): write ADR-0046 in the MADR format Refs #494 Co-Authored-By: Claude Opus 5.5 --- ...e_the_t3_desktop_app_bundle_in_dotfiles.md | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md b/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md index bb164b4..7c3e6a5 100644 --- a/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md +++ b/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md @@ -1,20 +1,41 @@ --- status: proposed date: 2026-11-22 +related: [ADR-0041] --- -# ADR-0046: Assemble the T3 desktop app bundle in dotfiles - -In the context of the T3 Code desktop app from `llm-agents` -([#494](https://github.com/furedea/dotfiles/issues/494)), facing its `.app` being a launcher that -execs the binary inside nixpkgs' `Electron.app`, so that macOS names the running process after that -bundle and shows "Electron" with Electron's icon in the Dock, Cmd+Tab and the menu bar, we decided -for a dotfiles package (`nix/packages/t3code_desktop.nix`) that copies the `Electron.app` of the -Electron `llm-agents` builds T3 against, renames it to T3 with T3's identifier and icon, puts a -launcher with the `llm-agents` wrappers' arguments and PATH in it, and re-signs it ad-hoc, and -against keeping the `llm-agents` `t3code-desktop` package or waiting for an upstream change, so that -the running Electron lives in a bundle that is T3 while T3's code, version and provider PATH -(including the signed Codex of ADR-0041) still come from `llm-agents`, accepting that dotfiles now -duplicates the wrappers' arguments, takes Electron from the `llm-agents` nixpkgs input, and stores a -second copy of `Electron.app`; the `t3-desktop-app-bundle` check fails when the PATH, app directory -or Electron version drifts from `llm-agents`. +# Assemble the T3 desktop app bundle in dotfiles + +## Context and Problem Statement + +The T3 Code desktop app from `llm-agents` shows up as "Electron", with Electron's icon, in the Dock, +Cmd+Tab and the menu bar. Its `.app` is only a launcher that execs the binary inside nixpkgs' +`Electron.app`, and macOS names a process after the bundle that holds its executable. Issue #494 +tracks the work; T3's code, version and provider PATH (including the signed Codex of ADR-0041) +should keep coming from `llm-agents`. + +## Considered Options + +- A dotfiles package (`nix/packages/t3code_desktop.nix`) that copies the `Electron.app` of the + Electron `llm-agents` builds T3 against, renames it to T3, adds a launcher with the `llm-agents` + wrappers' arguments and PATH, and re-signs the bundle ad-hoc. +- Keep the `llm-agents` `t3code-desktop` package and wait for an upstream fix. + +## Decision Outcome + +Chosen option: "A dotfiles package that copies `Electron.app` and renames it to T3", because the +running Electron then lives in a bundle whose name, identifier and icon are T3's, while only the +bundle assembly leaves `llm-agents`. Electron comes from the `llm-agents` nixpkgs input, not the +dotfiles one, so T3 runs on the Electron it was built for. Waiting for upstream leaves the wrong +name and icon in place with no date. + +### Consequences + +- Good, because the Dock, Cmd+Tab and the menu bar show T3 Code (Beta) and T3's icon. +- Good, because T3's code and version still update with `llm-agents`, and the launchd server's + `t3codePackage` is unchanged. +- Bad, because dotfiles duplicates the `llm-agents` wrappers' arguments and PATH; the + `t3-desktop-app-bundle` check fails when they, the app directory, or the Electron version drift. +- Bad, because the store holds a second, ad-hoc signed copy of `Electron.app`, and macOS asks for + notification permission again after the identifier and signature change. +- Revert to the `llm-agents` package once upstream assembles a T3-named bundle itself. From 338fb8c2db505a5c79e4ea67ab21221e07227390 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:42:06 +0900 Subject: [PATCH 3/4] fix(nix): give the T3 bundle a valid bundle identifier llm-agents' "org.nixos.T3 Code (Beta)" contains spaces and parentheses, which Apple does not allow; the bundle now runs under that identity. Refs #494 Co-Authored-By: Claude Opus 5.5 --- nix/checks.nix | 4 +++- nix/packages/t3code_desktop.nix | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nix/checks.nix b/nix/checks.nix index c55489c..c56c599 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -556,7 +556,9 @@ in wrapperPath() { strings "$1" | sed -n "s/^ *--prefix 'PATH' ':' '\(.*\)' .*$/\1/p"; } test "$(info "$app" CFBundleName)" = 'T3 Code (Beta)' test "$(info "$app" CFBundleDisplayName)" = 'T3 Code (Beta)' - test "$(info "$app" CFBundleIdentifier)" = "$(info "$upstreamApp" CFBundleIdentifier)" + # Apple allows only letters, digits, "-" and "." in a bundle identifier. + info "$app" CFBundleIdentifier | grep -qxE '[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+' + info "$app" CFBundleIdentifier | grep -qF t3code cmp "$app/Contents/Resources/$(info "$app" CFBundleIconFile)" "$upstreamApp/Contents/Resources/t3code.icns" launcher="$app/Contents/MacOS/$(info "$app" CFBundleExecutable)" diff --git a/nix/packages/t3code_desktop.nix b/nix/packages/t3code_desktop.nix index 2d221e3..2265f1d 100644 --- a/nix/packages/t3code_desktop.nix +++ b/nix/packages/t3code_desktop.nix @@ -13,6 +13,8 @@ let inherit (t3code.unwrapped) appName; upstreamApp = "${t3code.desktop}/Applications/${appName}.app"; appDirectory = "${t3code.unwrapped.desktop}/libexec/t3code/apps/desktop"; + # llm-agents' "org.nixos.T3 Code (Beta)" has characters Apple does not allow in an identifier. + bundleIdentifier = "org.nixos.t3code-desktop"; in stdenvNoCC.mkDerivation { pname = "t3code-desktop"; @@ -34,10 +36,9 @@ stdenvNoCC.mkDerivation { install -m444 "${upstreamApp}/Contents/Resources/t3code.icns" "$app/Contents/Resources/t3code.icns" plist="$app/Contents/Info.plist" - identifier=$(/usr/bin/plutil -extract CFBundleIdentifier raw -o - "${upstreamApp}/Contents/Info.plist") /usr/bin/plutil -replace CFBundleName -string "${appName}" "$plist" /usr/bin/plutil -replace CFBundleDisplayName -string "${appName}" "$plist" - /usr/bin/plutil -replace CFBundleIdentifier -string "$identifier" "$plist" + /usr/bin/plutil -replace CFBundleIdentifier -string ${bundleIdentifier} "$plist" /usr/bin/plutil -replace CFBundleIconFile -string t3code.icns "$plist" /usr/bin/plutil -replace CFBundleExecutable -string "${appName}" "$plist" From e9a1c0ffc2eb65b0a87d864bde1fb9ae5e3043eb Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:52:10 +0900 Subject: [PATCH 4/4] docs(adr): renumber the T3 app bundle ADR to 0047 ADR-0046 was taken by #496. Refs #494 Co-Authored-By: Claude Opus 5.5 --- ....md => 0047_assemble_the_t3_desktop_app_bundle_in_dotfiles.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/adr/{0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md => 0047_assemble_the_t3_desktop_app_bundle_in_dotfiles.md} (100%) diff --git a/docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md b/docs/adr/0047_assemble_the_t3_desktop_app_bundle_in_dotfiles.md similarity index 100% rename from docs/adr/0046_assemble_the_t3_desktop_app_bundle_in_dotfiles.md rename to docs/adr/0047_assemble_the_t3_desktop_app_bundle_in_dotfiles.md