-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(app-server): expose CODEX_COMPANION_APP_SERVER_DISABLE_BROKER env var #691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tyoon10
wants to merge
2
commits into
openai:main
Choose a base branch
from
tyoon10:devin/disable-broker-env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| import { buildEnv, installFakeCodex } from "./fake-codex-fixture.mjs"; | ||
| import { makeTempDir } from "./helpers.mjs"; | ||
| import { BROKER_DISABLE_ENV, CodexAppServerClient } from "../plugins/codex/scripts/lib/app-server.mjs"; | ||
|
|
||
| test("CodexAppServerClient.connect spawns directly when CODEX_COMPANION_APP_SERVER_DISABLE_BROKER is true", async () => { | ||
| const binDir = makeTempDir(); | ||
| installFakeCodex(binDir); | ||
| const cwd = makeTempDir(); | ||
| const env = { ...buildEnv(binDir), [BROKER_DISABLE_ENV]: "true" }; | ||
|
|
||
| const client = await CodexAppServerClient.connect(cwd, { env }); | ||
|
|
||
| assert.equal(client.transport, "direct"); | ||
| await client.close(); | ||
| }); | ||
|
|
||
| test("CodexAppServerClient.connect accepts 1 as a truthy disableBroker env value", async () => { | ||
| const binDir = makeTempDir(); | ||
| installFakeCodex(binDir); | ||
| const cwd = makeTempDir(); | ||
| const env = { ...buildEnv(binDir), [BROKER_DISABLE_ENV]: "1" }; | ||
|
|
||
| const client = await CodexAppServerClient.connect(cwd, { env }); | ||
|
|
||
| assert.equal(client.transport, "direct"); | ||
| await client.close(); | ||
| }); | ||
|
|
||
| test("CodexAppServerClient.connect treats an explicit disableBroker option as an override", async () => { | ||
| const binDir = makeTempDir(); | ||
| installFakeCodex(binDir); | ||
| const cwd = makeTempDir(); | ||
| // Even though the env var is set, an explicit option wins. | ||
| const client = await CodexAppServerClient.connect(cwd, { | ||
| env: buildEnv(binDir), | ||
| disableBroker: true | ||
| }); | ||
|
|
||
| assert.equal(client.transport, "direct"); | ||
| await client.close(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| import { getSessionRuntimeStatus } from "../plugins/codex/scripts/lib/codex.mjs"; | ||
| import { BROKER_DISABLE_ENV } from "../plugins/codex/scripts/lib/app-server.mjs"; | ||
| import { makeTempDir } from "./helpers.mjs"; | ||
|
|
||
| test("getSessionRuntimeStatus reports direct mode when disable-broker env is set", () => { | ||
| const cwd = makeTempDir(); | ||
| const env = { [BROKER_DISABLE_ENV]: "true" }; | ||
|
|
||
| const status = getSessionRuntimeStatus(env, cwd); | ||
|
|
||
| assert.equal(status.mode, "direct"); | ||
| assert.equal(status.endpoint, null); | ||
| assert.ok(status.detail.includes("disabled by CODEX_COMPANION_APP_SERVER_DISABLE_BROKER")); | ||
| }); | ||
|
|
||
| test("getSessionRuntimeStatus honors disable-broker env even when endpoint is set", () => { | ||
| const cwd = makeTempDir(); | ||
| const env = { | ||
| [BROKER_DISABLE_ENV]: "1", | ||
| CODEX_COMPANION_APP_SERVER_ENDPOINT: "tcp://127.0.0.1:12345" | ||
| }; | ||
|
|
||
| const status = getSessionRuntimeStatus(env, cwd); | ||
|
|
||
| assert.equal(status.mode, "direct"); | ||
| assert.equal(status.endpoint, null); | ||
| }); | ||
|
|
||
| test("getSessionRuntimeStatus reports shared mode when endpoint is set and disable is unset", () => { | ||
| const cwd = makeTempDir(); | ||
| const env = { | ||
| CODEX_COMPANION_APP_SERVER_ENDPOINT: "tcp://127.0.0.1:12345" | ||
| }; | ||
|
|
||
| const status = getSessionRuntimeStatus(env, cwd); | ||
|
|
||
| assert.equal(status.mode, "shared"); | ||
| assert.equal(status.endpoint, "tcp://127.0.0.1:12345"); | ||
| }); | ||
|
|
||
| test("getSessionRuntimeStatus reports direct mode when no endpoint or disable flag is set", () => { | ||
| const cwd = makeTempDir(); | ||
| const status = getSessionRuntimeStatus({}, cwd); | ||
|
|
||
| assert.equal(status.mode, "direct"); | ||
| assert.equal(status.endpoint, null); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this environment variable is enabled while either
CODEX_COMPANION_APP_SERVER_ENDPOINTor a saved broker session exists,connect()correctly chooses the direct transport, butgetSessionRuntimeStatus()inplugins/codex/scripts/lib/codex.mjs:906-914still reports a “shared session” because it only checks for an endpoint. Consequently,/codex:statusand setup output claim jobs are reusing the broker even though every connection bypasses it; apply the same disable-value resolution when determining the displayed runtime mode.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied:
getSessionRuntimeStatus()now callsresolveDisableBroker()so/codex:statusreports direct mode wheneverCODEX_COMPANION_APP_SERVER_DISABLE_BROKERis set, even if a broker endpoint or saved session exists. Addedtests/codex.test.mjscovering disable-wins-over-endpoint and the default cases.