From 54b432742cb85b70fc26028122586ab349098dfb Mon Sep 17 00:00:00 2001 From: Glean Code Writer Date: Tue, 21 Jul 2026 19:12:46 +0000 Subject: [PATCH 1/3] [Plugin] Use distinct OAuth client_name for Codex target The OAuth DCR client_name was hardcoded to "Glean Claude Code Plugin" for all plugin targets, causing the Glean consent page to show the Claude logo and name even when authenticating from Codex. Detect the Codex host via CODEX_THREAD_ID and register as "Glean Codex Plugin" so the server-side alias map resolves the correct icon. Generated by Glean Code Writer --- src/auth-provider.ts | 4 +++- tests/auth-provider.test.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/auth-provider.ts b/src/auth-provider.ts index 4c47d0b..55fd2ec 100644 --- a/src/auth-provider.ts +++ b/src/auth-provider.ts @@ -73,7 +73,9 @@ export class GleanOAuthClientProvider implements OAuthClientProvider { get clientMetadata(): OAuthClientMetadata { return { redirect_uris: [getCallbackUrl()], - client_name: "Glean Claude Code Plugin", + client_name: process.env.CODEX_THREAD_ID + ? "Glean Codex Plugin" + : "Glean Claude Code Plugin", }; } diff --git a/tests/auth-provider.test.ts b/tests/auth-provider.test.ts index ba181f0..f8bce77 100644 --- a/tests/auth-provider.test.ts +++ b/tests/auth-provider.test.ts @@ -121,6 +121,16 @@ describe("GleanOAuthClientProvider", () => { expect(meta.redirect_uris![0]).toMatch(/127\.0\.0\.1/); }); + it("clientMetadata uses Codex client name when CODEX_THREAD_ID is set", () => { + process.env.CODEX_THREAD_ID = "thread_abc123"; + try { + const provider = new GleanOAuthClientProvider(); + expect(provider.clientMetadata.client_name).toBe("Glean Codex Plugin"); + } finally { + delete process.env.CODEX_THREAD_ID; + } + }); + it("redirectToAuthorization records the URL and hands state to the loopback", async () => { const provider = new GleanOAuthClientProvider(); await provider.redirectToAuthorization( From 56fbdf72636563cfd5bcb8ea30cc487c74014e1c Mon Sep 17 00:00:00 2001 From: Glean Code Writer Date: Tue, 21 Jul 2026 19:41:05 +0000 Subject: [PATCH 2/3] Fix OAuth consent screen showing Claude logo for Codex host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The client_name in OAuth registration was hardcoded to "Glean Claude Code Plugin" for all hosts, causing the server to always display the Claude logo on the consent screen — even when the plugin is running inside Codex. Detect the host in start.mjs (via CODEX_THREAD_ID / CLAUDE_CODE_SESSION_ID env vars) and export GLEAN_PLUGIN_HOST so auth-provider.ts can send the appropriate client_name per host. The server-side icon mapping already handles "Codex" → ChatGPT logo correctly. --- plugins/glean/.claude-plugin/plugin.json | 2 +- plugins/glean/.codex-plugin/plugin.json | 2 +- plugins/glean/.cursor-plugin/plugin.json | 2 +- plugins/glean/dist/index.js | 7 ++++++- plugins/glean/start.mjs | 15 +++++++++++++-- src/auth-provider.ts | 9 ++++++--- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/plugins/glean/.claude-plugin/plugin.json b/plugins/glean/.claude-plugin/plugin.json index 1fee628..1ff6a83 100644 --- a/plugins/glean/.claude-plugin/plugin.json +++ b/plugins/glean/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "glean-vnext", - "version": "0.2.40", + "version": "0.2.41", "description": "Glean plugin for discovering skills and running tools.", "author": { "name": "Glean" diff --git a/plugins/glean/.codex-plugin/plugin.json b/plugins/glean/.codex-plugin/plugin.json index 16fb2f1..582cf9b 100644 --- a/plugins/glean/.codex-plugin/plugin.json +++ b/plugins/glean/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "glean-vnext", - "version": "0.2.40", + "version": "0.2.41", "description": "Glean Codex plugin for discovering skills and running tools.", "author": { "name": "Glean" diff --git a/plugins/glean/.cursor-plugin/plugin.json b/plugins/glean/.cursor-plugin/plugin.json index 87422ec..c67bd88 100644 --- a/plugins/glean/.cursor-plugin/plugin.json +++ b/plugins/glean/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "glean-vnext", "displayName": "Glean vNext", - "version": "0.2.40", + "version": "0.2.41", "description": "Search and act across your company's apps — Jira, Slack, Salesforce, Google Workspace, and more — without leaving Cursor.", "author": { "name": "Glean" diff --git a/plugins/glean/dist/index.js b/plugins/glean/dist/index.js index c46e8fc..48c17e0 100644 --- a/plugins/glean/dist/index.js +++ b/plugins/glean/dist/index.js @@ -25438,9 +25438,14 @@ var GleanOAuthClientProvider = class { return getCallbackUrl(); } get clientMetadata() { + const CLIENT_NAMES = { + "codex": "Glean Codex Plugin", + "cursor": "Glean Cursor Plugin" + }; + const host = process.env.GLEAN_PLUGIN_HOST ?? ""; return { redirect_uris: [getCallbackUrl()], - client_name: "Glean Claude Code Plugin" + client_name: CLIENT_NAMES[host] ?? "Glean Claude Code Plugin" }; } clientInformation() { diff --git a/plugins/glean/start.mjs b/plugins/glean/start.mjs index 84e549b..951c2dd 100644 --- a/plugins/glean/start.mjs +++ b/plugins/glean/start.mjs @@ -59,12 +59,23 @@ process.env.SKILLS_BASE_DIR = skillsBaseDir; // CLAUDE_CODE_SESSION_ID; Codex exposes the conversation id as CODEX_THREAD_ID. // Hosts that expose no session id (Cursor) leave it unset, and the plugin falls // back to a generated per-process id. -const sessionId = - val(process.env.CLAUDE_CODE_SESSION_ID) ?? val(process.env.CODEX_THREAD_ID); +const claudeSessionId = val(process.env.CLAUDE_CODE_SESSION_ID); +const codexThreadId = val(process.env.CODEX_THREAD_ID); +const sessionId = claudeSessionId ?? codexThreadId; if (sessionId !== undefined) { process.env.GLEAN_SESSION_ID = sessionId; } +// Export the detected host so the plugin can use host-appropriate identifiers +// (e.g. the OAuth client_name that drives the logo shown on the consent screen). +if (codexThreadId !== undefined) { + process.env.GLEAN_PLUGIN_HOST = "codex"; +} else if (claudeSessionId !== undefined) { + process.env.GLEAN_PLUGIN_HOST = "claude-code"; +} else { + process.env.GLEAN_PLUGIN_HOST = "cursor"; +} + // Boot the server in-process. Import via a file URL resolved against this // module so the dynamic specifier works regardless of cwd and on Windows paths. await import(new URL("./dist/index.js", import.meta.url).href); diff --git a/src/auth-provider.ts b/src/auth-provider.ts index 55fd2ec..c12059e 100644 --- a/src/auth-provider.ts +++ b/src/auth-provider.ts @@ -71,11 +71,14 @@ export class GleanOAuthClientProvider implements OAuthClientProvider { } get clientMetadata(): OAuthClientMetadata { + const CLIENT_NAMES: Record = { + "codex": "Glean Codex Plugin", + "cursor": "Glean Cursor Plugin", + }; + const host = process.env.GLEAN_PLUGIN_HOST ?? ""; return { redirect_uris: [getCallbackUrl()], - client_name: process.env.CODEX_THREAD_ID - ? "Glean Codex Plugin" - : "Glean Claude Code Plugin", + client_name: CLIENT_NAMES[host] ?? "Glean Claude Code Plugin", }; } From 90b911ddb0a7486c50a6d1f01555a020a26551a6 Mon Sep 17 00:00:00 2001 From: Glean Code Writer Date: Tue, 21 Jul 2026 19:42:02 +0000 Subject: [PATCH 3/3] Update test to use GLEAN_PLUGIN_HOST and add Cursor test case The auth provider now reads GLEAN_PLUGIN_HOST (set by start.mjs) instead of checking CODEX_THREAD_ID directly. Update the existing test and add a case for the Cursor host name. --- tests/auth-provider.test.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/auth-provider.test.ts b/tests/auth-provider.test.ts index f8bce77..c2837b3 100644 --- a/tests/auth-provider.test.ts +++ b/tests/auth-provider.test.ts @@ -121,13 +121,23 @@ describe("GleanOAuthClientProvider", () => { expect(meta.redirect_uris![0]).toMatch(/127\.0\.0\.1/); }); - it("clientMetadata uses Codex client name when CODEX_THREAD_ID is set", () => { - process.env.CODEX_THREAD_ID = "thread_abc123"; + it("clientMetadata uses Codex client name when GLEAN_PLUGIN_HOST is codex", () => { + process.env.GLEAN_PLUGIN_HOST = "codex"; try { const provider = new GleanOAuthClientProvider(); expect(provider.clientMetadata.client_name).toBe("Glean Codex Plugin"); } finally { - delete process.env.CODEX_THREAD_ID; + delete process.env.GLEAN_PLUGIN_HOST; + } + }); + + it("clientMetadata uses Cursor client name when GLEAN_PLUGIN_HOST is cursor", () => { + process.env.GLEAN_PLUGIN_HOST = "cursor"; + try { + const provider = new GleanOAuthClientProvider(); + expect(provider.clientMetadata.client_name).toBe("Glean Cursor Plugin"); + } finally { + delete process.env.GLEAN_PLUGIN_HOST; } });