Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix: open the ChatGPT verification tab synchronously on sign-in

Miguelon Peluchond2915e8a909f
diff --git a/control-ui/components/CodexSubscriptionHub/index.tsx b/control-ui/components/CodexSubscriptionHub/index.tsx
index 47a5699f5..c54b5e320 100644
--- a/control-ui/components/CodexSubscriptionHub/index.tsx
+++ b/control-ui/components/CodexSubscriptionHub/index.tsx
@@ -234,6 +234,14 @@ export function CodexSubscriptionHub() {
async function handleConnect(row: CodexSubscriptionConnectionView) {
const epoch = ++connectEpoch.current
setBusyKey(row.connectionKey)
+ // Open the verification page synchronously, inside the click handler and
+ // before any await — popup blockers honour user activation here, so the
+ // tab reliably appears. The device code lands in the card right after.
+ try {
+ window.open(CODEX_DEVICE_VERIFICATION_URI, '_blank', 'noopener,noreferrer')
+ } catch {
+ // Blocked or unavailable — the card's link is the manual fallback.
+ }
try {
const started = await startCodexDeviceConnect(
row.status === 'connected' ? 'reconnect' : 'connect',
@@ -592,7 +600,7 @@ export function CodexSubscriptionHub() {
{userCode ? (
<div className="cu-device-setup" data-testid="codex-device-code">
<p className="cu-device-setup__step">
- 1. Open the ChatGPT verification page:
+ 1. ChatGPT opened in a new tab — if it did not, use this link:
</p>
{(() => {
// Locked fallback (from dev): even if the backend
diff --git a/control-ui/components/__tests__/CodexSubscriptionHub.test.tsx b/control-ui/components/__tests__/CodexSubscriptionHub.test.tsx
index 0708c632b..e19b2f917 100644
--- a/control-ui/components/__tests__/CodexSubscriptionHub.test.tsx
+++ b/control-ui/components/__tests__/CodexSubscriptionHub.test.tsx
@@ -84,6 +84,10 @@ describe('CodexSubscriptionHub', () => {
})
it('creates the subscription when the name is confirmed and auto-starts sign-in', async () => {
+ vi.stubGlobal(
+ 'open',
+ vi.fn(() => ({}))
+ )
vi.mocked(createCodexSubscriptionConnection).mockResolvedValue(
connection({
connectionKey: 'codex-bbb',
@@ -211,6 +215,8 @@ describe('CodexSubscriptionHub', () => {
})
it('shows the device code card with the verification link and copy actions', async () => {
+ const openMock = vi.fn(() => ({}))
+ vi.stubGlobal('open', openMock)
vi.mocked(startCodexDeviceConnect).mockResolvedValue({
userCode: 'ABCD-1234',
verificationUri: 'https://chatgpt.com/device',
@@ -236,6 +242,12 @@ describe('CodexSubscriptionHub', () => {
fireEvent.click(await screen.findByRole('button', { name: 'Sign in with ChatGPT' }))
const card = await screen.findByTestId('codex-device-code')
expect(card).toHaveTextContent('ABCD-1234')
+ // The verification tab opens synchronously in the click handler.
+ expect(openMock).toHaveBeenCalledWith(
+ 'https://auth.openai.com/codex/device',
+ '_blank',
+ 'noopener,noreferrer'
+ )
const link = screen.getByTestId('codex-device-verification-link')
expect(link).toHaveAttribute('href', 'https://chatgpt.com/device')
expect(link).toHaveAttribute('target', '_blank')
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 4fd4e58c3..79d634013 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.482",
+ "version": "0.1.483",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.482",
+ "version": "0.1.483",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index 08689fd75..aeb174a9b 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.482",
+ "version": "0.1.483",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",