From aca943e39a81ca0f4b558fa2cea0b09da0cdf728 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Thu, 26 Nov 2026 16:40:07 +0100 Subject: [PATCH] fix: Detect the Codex app as ChatGPT.app, so Open in Codex appears. OpenAI folded the Codex desktop app into ChatGPT: the bundle is `ChatGPT.app`, identifier `com.openai.codex`, and it claims `codex:`. App Studio looked for `Codex.app`, found nothing, and never drew the button. An editor can now list other names and a bundle id; the id is checked because an older `ChatGPT.app` is the chat-only `com.openai.chat`, which has no `codex:` scheme. `Codex.app` is still tried for a copy from before the rename. Also records that Antigravity.app 2.9.1 still cannot be handed a local folder (its one deep link is an AI Studio import), so Antigravity keeps opening through Antigravity IDE. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 9 +++ lib/session/external_editors.dart | 86 +++++++++++++++++++++---- test/session/external_editors_test.dart | 85 +++++++++++++++++------- 3 files changed, 146 insertions(+), 34 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 02dacda..4c0f66f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -481,6 +481,15 @@ restart buttons. `ui/open_in_editor_buttons.dart` draws them, fork, and `open -a` on it was confirmed against 2.5.5: the folder opened, and a second call reused the running copy. **macOS only** — where the Windows installer puts the IDE has not been seen, so there is no Windows button. + Rechecked against `Antigravity.app` 2.9.1: still no document types, `argv` + is only scanned for a URL, and the renderer's one deep-link route is + `antigravity://teleport/ai_studio?blob_id=…&signature=…` (an AI Studio + import). There is no way to hand it a local folder. +- **Codex is `ChatGPT.app`, bundle id `com.openai.codex`.** OpenAI folded the + Codex app into ChatGPT; looking for `Codex.app` found nothing, so the button + never showed. The bundle id is checked (`_EditorApp.bundleId`, read from the + XML `Info.plist`) because an older `ChatGPT.app` is the chat-only + `com.openai.chat`, with no `codex:` scheme. `Codex.app` is still tried. - **Order is preference order**, and `ProjectStartedDialog` features the first. OpenCode is last deliberately: it only appears when the box was ticked, but App Studio already runs it in the Agent tab, so an editor it does *not* have diff --git a/lib/session/external_editors.dart b/lib/session/external_editors.dart index 5f6e569..fd03131 100644 --- a/lib/session/external_editors.dart +++ b/lib/session/external_editors.dart @@ -25,13 +25,30 @@ import 'project_settings.dart'; /// Picking the wrong door is not loud: `open` exits 0 for an app that launched /// and dropped the path exactly as it does for one that opened it. class _EditorApp { - const _EditorApp(this.appName, {this.deepLink, this.cli}); + const _EditorApp( + this.appName, { + this.alsoNamed = const [], + this.bundleId, + this.deepLink, + this.cli, + }); /// Bundle name under one of [_applicationDirectories]. Doubles as the /// installed check, which [deepLink] needs even more than the rest do: /// `open ://…` fails *silently* when nothing claims the scheme. final String appName; + /// Other names the same app has shipped under, tried after [appName]. + final List alsoNamed; + + /// The `CFBundleIdentifier` a bundle found by name must carry, or null to + /// take the name alone. Needed where a name is shared with a different app: + /// `ChatGPT.app` is the Codex app today and was the plain chat app before. + final String? bundleId; + + /// Every name to look for, in order. + List get appNames => [appName, ...alsoNamed]; + /// Builds the URL for an app that takes the project as a deep link. Null /// means it accepts the folder as a document — `open -a `. final Uri Function(String projectPath)? deepLink; @@ -74,6 +91,14 @@ class _EditorCli { /// that takes a project directory. A CLI does not qualify — there is no window /// to open a folder in, and "open in …" has to mean something visible. /// +/// **Codex is `ChatGPT.app`.** OpenAI folded the Codex desktop app into +/// ChatGPT: the bundle is named `ChatGPT.app`, carries the identifier +/// `com.openai.codex` and claims `codex:`. Looking for `Codex.app` found +/// nothing, so the button never appeared. The identifier is checked because +/// an older `ChatGPT.app` is the chat-only app (`com.openai.chat`), which has +/// no `codex:` scheme; `Codex.app` is still tried for a copy from before the +/// rename. +/// /// **Antigravity is `Antigravity IDE.app`, not `Antigravity.app`.** The latter /// is a thin Electron shell around a Go language server, with no `open-file` /// handler and no `CFBundleDocumentTypes`, so a folder handed to it is dropped @@ -86,7 +111,12 @@ const _editorApps = { IdeIntegration.vscode: _EditorApp('Visual Studio Code'), IdeIntegration.antigravity: _EditorApp('Antigravity IDE'), IdeIntegration.claude: _EditorApp('Claude', deepLink: _claudeDeepLink), - IdeIntegration.codex: _EditorApp('Codex', deepLink: _codexDeepLink), + IdeIntegration.codex: _EditorApp( + 'ChatGPT', + alsoNamed: ['Codex'], + bundleId: 'com.openai.codex', + deepLink: _codexDeepLink, + ), IdeIntegration.opencode: _EditorApp('OpenCode', deepLink: _openCodeDeepLink), }; @@ -231,7 +261,7 @@ class ExternalEditorsController extends ChangeNotifier required this.session, required this.process, Future> Function(String projectPath)? readEditors, - String? Function(String appName)? findApp, + String? Function(String appName, String? bundleId)? findApp, bool Function(String path)? fileExists, Future Function(List command)? launch, HostPlatform? host, @@ -255,7 +285,7 @@ class ExternalEditorsController extends ChangeNotifier final ProjectReadyView process; final Future> Function(String projectPath) _readEditors; - final String? Function(String appName) _findApp; + final String? Function(String appName, String? bundleId) _findApp; final bool Function(String path) _fileExists; final Future Function(List command) _launch; @@ -263,7 +293,7 @@ class ExternalEditorsController extends ChangeNotifier final WindowsSystem? _windowsSystem; final Map? _environment; final Future Function(String exe, List arguments) - _runElectronCli; + _runElectronCli; WindowsSystem get _windows => _windowsSystem ?? Win32System(); @@ -301,10 +331,13 @@ class ExternalEditorsController extends ChangeNotifier final target = _windowsTargets[editor.id]; if (target == null) return; launched = switch (target) { - _FoundLink(:final link) => - _windows.shellOpen(link(projectPath).toString()), - _FoundCli(:final exe, :final script) => - await _runElectronCli(exe, [script, projectPath]), + _FoundLink(:final link) => _windows.shellOpen( + link(projectPath).toString(), + ), + _FoundCli(:final exe, :final script) => await _runElectronCli(exe, [ + script, + projectPath, + ]), }; } else { final resolved = _resolved[editor.id]; @@ -354,7 +387,12 @@ class ExternalEditorsController extends ChangeNotifier final configured = await _readEditors(projectPath); for (final entry in _editorApps.entries) { if (!configured.contains(entry.key)) continue; - final appPath = _findApp(entry.value.appName); + final app = entry.value; + String? appPath; + for (final name in app.appNames) { + appPath = _findApp(name, app.bundleId); + if (appPath != null) break; + } if (appPath == null) continue; editors.add( ExternalEditor(id: entry.key.option, label: entry.key.label), @@ -493,14 +531,38 @@ List _applicationDirectories() => [ bool _defaultFileExists(String path) => File(path).existsSync(); -String? _defaultFindApp(String appName) { +String? _defaultFindApp(String appName, String? bundleId) { for (final dir in _applicationDirectories()) { final path = p.join(dir, '$appName.app'); - if (Directory(path).existsSync()) return path; + if (!Directory(path).existsSync()) continue; + if (bundleId == null || _bundleIdentifier(path) == bundleId) return path; } return null; } +final _bundleIdPattern = RegExp( + r'CFBundleIdentifier\s*([^<]*)', +); + +/// The bundle's `CFBundleIdentifier`, read out of its `Info.plist`, or null +/// when it cannot be read. +/// +/// XML only. Every editor this is asked about ships an XML plist; a binary one +/// reads as null, which only costs that app its button. +String? _bundleIdentifier(String appPath) { + try { + final plist = File( + p.join(appPath, 'Contents', 'Info.plist'), + ).readAsStringSync(); + return _bundleIdPattern.firstMatch(plist)?.group(1)?.trim(); + } on FileSystemException { + return null; + } on FormatException { + // A binary plist is not UTF-8. + return null; + } +} + /// Runs `[executable, ...arguments]` — an editor's own CLI, or `open` with /// either `-a ` or a deep-link URL. /// diff --git a/test/session/external_editors_test.dart b/test/session/external_editors_test.dart index a85449c..634903c 100644 --- a/test/session/external_editors_test.dart +++ b/test/session/external_editors_test.dart @@ -43,7 +43,7 @@ void main() { 'Cursor', 'Visual Studio Code', 'Claude', - 'Codex', + 'ChatGPT', 'OpenCode', }, required _FakeSession session, @@ -56,7 +56,7 @@ void main() { session: session, process: process ?? _FakeProcess(projectIsReady: true), readEditors: (path) async => editorsByProject[path] ?? const {}, - findApp: (name) => + findApp: (name, bundleId) => installedApps.contains(name) ? '/Applications/$name.app' : null, fileExists: (_) => cliIsPresent, launch: (command) async { @@ -189,7 +189,7 @@ void main() { ? {IdeIntegration.cursor} : {IdeIntegration.vscode}; }, - findApp: (name) => '/Applications/$name.app', + findApp: (name, _) => '/Applications/$name.app', launch: (_) async => true, host: HostPlatform.macos, ); @@ -339,6 +339,44 @@ void main() { ]); }); + test('finds Codex as ChatGPT.app, the name it ships under now', () async { + final session = _FakeSession()..setPath('/p'); + final lookups = <(String, String?)>[]; + final editors = ExternalEditorsController( + session: session, + process: _FakeProcess(projectIsReady: true), + readEditors: (_) async => {IdeIntegration.codex}, + findApp: (name, bundleId) { + lookups.add((name, bundleId)); + return name == 'ChatGPT' ? '/Applications/ChatGPT.app' : null; + }, + fileExists: (_) => true, + launch: (_) async => true, + host: HostPlatform.macos, + ); + addTearDown(editors.dispose); + await pumpEventQueue(); + + expect(editors.editors.single.label, 'Codex'); + // The identifier is what tells the Codex app from the chat-only ChatGPT. + expect(lookups.first, ('ChatGPT', 'com.openai.codex')); + }); + + test('still finds Codex under its old name', () async { + final session = _FakeSession()..setPath('/p'); + final editors = controller( + session: session, + editorsByProject: { + '/p': {IdeIntegration.codex}, + }, + installedApps: {'Codex'}, + ); + addTearDown(editors.dispose); + await pumpEventQueue(); + + expect(editors.editors.single.label, 'Codex'); + }); + test('a deep-link editor still has to be installed', () async { // Unlike `open -a`, `open ://…` exits 0 when nothing claims the // scheme, so the bundle check is the only thing standing between the user @@ -400,7 +438,7 @@ void main() { process: _FakeProcess(projectIsReady: true), readEditors: (path) async => path == project ? configured : const {}, // macOS lookups must never be what decides a Windows editor. - findApp: (_) => fail('looked for a macOS bundle'), + findApp: (_, _) => fail('looked for a macOS bundle'), fileExists: files.contains, launch: (_) => fail('launched a macOS command'), host: HostPlatform.windows, @@ -416,24 +454,27 @@ void main() { ); } - test('hands the folder to Cursor through its CLI, as an argument', () async { - final runs = >[]; - final editors = windowsController( - configured: {IdeIntegration.cursor}, - files: {cursorExe, cursorCli}, - cliRuns: runs, - ); - addTearDown(editors.dispose); - await pumpEventQueue(); - - expect(editors.editors.map((e) => e.id), ['cursor']); - await editors.open(editors.editors.single); - // The folder is one argument to a real `.exe` — never a `.cmd` line - // that cmd.exe would re-parse, spaces and all. - expect(runs, [ - [cursorExe, cursorCli, project], - ]); - }); + test( + 'hands the folder to Cursor through its CLI, as an argument', + () async { + final runs = >[]; + final editors = windowsController( + configured: {IdeIntegration.cursor}, + files: {cursorExe, cursorCli}, + cliRuns: runs, + ); + addTearDown(editors.dispose); + await pumpEventQueue(); + + expect(editors.editors.map((e) => e.id), ['cursor']); + await editors.open(editors.editors.single); + // The folder is one argument to a real `.exe` — never a `.cmd` line + // that cmd.exe would re-parse, spaces and all. + expect(runs, [ + [cursorExe, cursorCli, project], + ]); + }, + ); test('finds a machine-wide VS Code under Program Files', () async { const code = r'C:\Program Files\Microsoft VS Code\Code.exe';