Skip to content

🎥 Make videos programmatically with React

@remotion/studio-server: Fix Open in ChatGPT on macOS

Jonny Burger57ca85ad9ca3
diff --git a/packages/example/e2e/error-overlay.test.mts b/packages/example/e2e/error-overlay.test.mts
index ccd9763212..a587890b60 100644
--- a/packages/example/e2e/error-overlay.test.mts
+++ b/packages/example/e2e/error-overlay.test.mts
@@ -66,7 +66,7 @@ test.describe('error overlay dismissal', () => {
data: {
defaultCodingAgent: 'codex',
installedCodingAgents: [
- {id: 'codex', name: 'Codex', nameWithType: 'Codex'},
+ {id: 'codex', name: 'ChatGPT', nameWithType: 'ChatGPT'},
{
id: 'claude-code',
name: 'Claude',
@@ -176,7 +176,7 @@ test.describe('error overlay dismissal', () => {
}),
).toBeVisible();
await expect(
- page.getByRole('button', {name: 'Fix with Codex', exact: true}),
+ page.getByRole('button', {name: 'Fix with ChatGPT', exact: true}),
).toBeVisible();
await expect(
page.getByRole('button', {
@@ -187,7 +187,7 @@ test.describe('error overlay dismissal', () => {
'Copy stack',
'Search Issues Ctrl+G',
'Ask on Discord Ctrl+D',
- 'Fix with Codex',
+ 'Fix with ChatGPT',
]) {
const button = page.getByRole('button', {name: buttonName});
await expect(button).toHaveCSS('border-style', 'none');
@@ -201,7 +201,7 @@ test.describe('error overlay dismissal', () => {
.first()
.boundingBox();
const fixWithAgentButton = page.getByRole('button', {
- name: 'Fix with Codex',
+ name: 'Fix with ChatGPT',
exact: true,
});
const fixWithAgentButtonBounds = await fixWithAgentButton.boundingBox();
@@ -239,7 +239,7 @@ test.describe('error overlay dismissal', () => {
(errorMessageBounds.y + errorMessageBounds.height),
).toBeLessThan(16);
await page
- .getByRole('button', {name: 'Fix with Codex', exact: true})
+ .getByRole('button', {name: 'Fix with ChatGPT', exact: true})
.click();
await expect
.poll(() => openInCodingAgentRequests)
@@ -347,7 +347,7 @@ test.describe('error overlay dismissal', () => {
.locator('#error-overlay-open-in-editor')
.boundingBox();
const symbolicatedFixButtonBounds = await page
- .getByRole('button', {name: 'Fix with Codex', exact: true})
+ .getByRole('button', {name: 'Fix with ChatGPT', exact: true})
.boundingBox();
const symbolicatedCopyButtonBounds = await page
.getByRole('button', {name: 'Copy stack'})
diff --git a/packages/studio-server/src/helpers/coding-agent-registry.ts b/packages/studio-server/src/helpers/coding-agent-registry.ts
index f976659728..e5a4639a88 100644
--- a/packages/studio-server/src/helpers/coding-agent-registry.ts
+++ b/packages/studio-server/src/helpers/coding-agent-registry.ts
@@ -384,8 +384,8 @@ export const discoverAvailableCodingAgents = async (
applicationPath,
id,
launchMode: 'direct',
- name: definition.name,
- nameWithType: definition.nameWithType,
+ name: id === 'codex' ? 'ChatGPT' : definition.name,
+ nameWithType: id === 'codex' ? 'ChatGPT' : definition.nameWithType,
platform,
terminal: null,
});
@@ -443,15 +443,17 @@ export const getCodingAgentLaunchCommand = ({
}): {command: string; args: string[]; cwd: string | null} => {
if (codingAgent.platform === 'darwin') {
switch (codingAgent.id) {
- case 'codex':
+ case 'codex': {
+ const deepLink = new URL('codex://new');
+ deepLink.searchParams.set('path', projectPath);
+
return {
- command: path.posix.join(
- codingAgent.applicationPath,
- 'Contents/Resources/codex',
- ),
- args: ['app', projectPath],
+ command: 'open',
+ args: [deepLink.toString()],
cwd: null,
};
+ }
+
case 'cursor':
return {
command: path.posix.join(
@@ -570,23 +572,6 @@ export const getCodingAgentLaunchCommands = ({
projectPath: string;
prompt: string | null;
}): readonly CodingAgentLaunchCommand[] => {
- if (codingAgent.platform === 'darwin' && codingAgent.id === 'codex') {
- const deepLink = new URL('codex://new');
- deepLink.searchParams.set('path', projectPath);
- if (prompt !== null) {
- deepLink.searchParams.set('prompt', prompt);
- }
-
- return [
- {
- command: 'open',
- args: [deepLink.toString()],
- cwd: null,
- waitForExit: false,
- },
- ];
- }
-
const defaultCommand = {
...getCodingAgentLaunchCommand({codingAgent, projectPath}),
waitForExit: false,
@@ -595,13 +580,26 @@ export const getCodingAgentLaunchCommands = ({
if (
prompt === null ||
codingAgent.platform !== 'darwin' ||
- codingAgent.id === 'copilot' ||
- codingAgent.id === 'codex'
+ codingAgent.id === 'copilot'
) {
return [defaultCommand];
}
switch (codingAgent.id) {
+ case 'codex': {
+ const deepLink = new URL('codex://new');
+ deepLink.searchParams.set('path', projectPath);
+ deepLink.searchParams.set('prompt', prompt);
+ return [
+ {
+ command: 'open',
+ args: [deepLink.toString()],
+ cwd: null,
+ waitForExit: false,
+ },
+ ];
+ }
+
case 'cursor': {
const deepLink = new URL('cursor://anysphere.cursor-deeplink/prompt');
deepLink.searchParams.set('text', prompt);
diff --git a/packages/studio-server/src/test/coding-agent-registry.test.ts b/packages/studio-server/src/test/coding-agent-registry.test.ts
index 4423c8bceb..f13d643086 100644
--- a/packages/studio-server/src/test/coding-agent-registry.test.ts
+++ b/packages/studio-server/src/test/coding-agent-registry.test.ts
@@ -43,8 +43,8 @@ test('discovers supported macOS coding agents without launching them', async ()
applicationPath: '/Custom/Applications/ChatGPT.app',
id: 'codex',
launchMode: 'direct',
- name: 'Codex',
- nameWithType: 'Codex',
+ name: 'ChatGPT',
+ nameWithType: 'ChatGPT',
platform: 'darwin',
terminal: null,
},
diff --git a/packages/studio-server/src/test/open-in-coding-agent.test.ts b/packages/studio-server/src/test/open-in-coding-agent.test.ts
index 76d6992726..faf1fae219 100644
--- a/packages/studio-server/src/test/open-in-coding-agent.test.ts
+++ b/packages/studio-server/src/test/open-in-coding-agent.test.ts
@@ -18,24 +18,40 @@ import {
} from '../helpers/coding-agent-registry';
test('constructs macOS coding agent launch commands', () => {
+ const chatGPT = {
+ applicationPath: '/Applications/ChatGPT.app',
+ id: 'codex',
+ launchMode: 'direct',
+ name: 'ChatGPT',
+ nameWithType: 'ChatGPT',
+ platform: 'darwin',
+ terminal: null,
+ } as const;
+
expect(
getCodingAgentLaunchCommand({
- codingAgent: {
- applicationPath: '/Applications/ChatGPT.app',
- id: 'codex',
- launchMode: 'direct',
- name: 'Codex',
- nameWithType: 'Codex',
- platform: 'darwin',
- terminal: null,
- },
+ codingAgent: chatGPT,
projectPath: '/Users/test/My Project',
}),
).toEqual({
- command: '/Applications/ChatGPT.app/Contents/Resources/codex',
- args: ['app', '/Users/test/My Project'],
+ command: 'open',
+ args: ['codex://new?path=%2FUsers%2Ftest%2FMy+Project'],
cwd: null,
});
+ expect(
+ getCodingAgentLaunchCommands({
+ codingAgent: chatGPT,
+ projectPath: '/Users/test/My Project',
+ prompt: null,
+ }),
+ ).toEqual([
+ {
+ command: 'open',
+ args: ['codex://new?path=%2FUsers%2Ftest%2FMy+Project'],
+ cwd: null,
+ waitForExit: false,
+ },
+ ]);
expect(
getCodingAgentLaunchCommand({
@@ -181,8 +197,8 @@ test('prefills editable macOS coding agents without submitting to Copilot', () =
applicationPath: '/Applications/ChatGPT.app',
id: 'codex',
launchMode: 'direct',
- name: 'Codex',
- nameWithType: 'Codex',
+ name: 'ChatGPT',
+ nameWithType: 'ChatGPT',
platform: 'darwin',
terminal: null,
},