Fix model-picker patch no-op on Codex Desktop 0.141.0+ (model-list-filter bundle; also 26.616.x)#50
Open
DevRico003 wants to merge 4 commits into
Open
Conversation
Codex Desktop >= 0.141.0 factors the model-list filter into its own webview/assets/model-list-filter-*.js bundle. `_find_js_bundle` returned the first candidate matching the needle OR the (loose) "already applied" regex. An unrelated minified bundle that happens to contain `=!1;...forEach` sorts earlier and matches the applied marker, so it shadowed the real filter bundle and `patch-app` reported a false "already applied" — leaving the Statsig allowlist branch (`useHiddenModels && authMethod !== 'amazonBedrock'`) intact and custom BYOK models hidden from the picker. Fixes: - Look up the dedicated `model-list-filter-*.js` bundle explicitly. - Make `_find_js_bundle` two-pass: prefer any candidate still containing the unpatched needle before falling back to an "already applied" match, so an unrelated bundle can no longer shadow the real target.
7d51d88 to
70b5f31
Compare
|
Thank you, hope this pesky fix gets merged soon (or OpenAI drops Statsig gating altogether)! |
The model-list-filter bundle lookup added for 0.141.0 also resolves the no-op on newer Codex Desktop builds (26.616.32156), where the allowlist guard ships as model-list-filter-*.js. Verified end-to-end: the guard is rewritten to s=!1 and custom catalog entries appear in the picker.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On Codex Desktop 0.141.0 (macOS),
codex-shim patch-appreportson a fresh, unpatched app and exits successfully — but the picker filter is never actually patched, so custom/BYOK catalog entries stay hidden from the model picker.
Root cause
Two things combine:
Codex Desktop ≥ 0.141.0 factors the model-list filter into its own bundle,
webview/assets/model-list-filter-*.js, which wasn't in the patch's glob list. The relevant code is:struthy ⇒ only server-allowlisted models (availableModels) render; custom slugs are dropped._find_js_bundlereturned the first candidate matching the needle or the deliberately-looseMODEL_PICKER_APPLIEDmarker ((?:let )?\w+=!1[,;]…\.forEach). An unrelated minified bundle that merely contains=!1;…forEachsorts earlier and matches that marker, so it shadowed the real filter bundle._replace_oncethen found the applied marker there and returned "already applied" — a false no-op.The needle itself (
…&&\w+!==\amazonBedrock``) already matches the new bundle, so once the right file is selected the existing replacement works unchanged.Fix
model-list-filter-*.jsto the picker glob list._find_js_bundletwo-pass: prefer any candidate still containing the unpatched needle before falling back to an "already applied" match. An unrelated bundle can no longer shadow the real target.Verified end-to-end against an actual Codex Desktop 0.141.0
app.asar: the filter is now correctly rewritten tos=!1(allowlist branch off,!n.hiddenbranch active), ASAR integrity re-hashed and re-signed, and custom models appear in the picker. Existing test suite passes; backward-compatible with the older inline (let u=c.useHiddenModels&&o!==\amazonBedrock`,d;`) and extracted-helper bundle shapes.Update — also verified on Codex Desktop 26.616.32156
The same root cause reproduces on the current Codex Desktop 26.616.32156 (macOS arm64): the allowlist guard ships in its own
model-list-filter-*.jsbundle (...,s=i&&e!==\amazonBedrock`;), and the loose *already-applied* regex matched an unrelated bundle first, sopatch-app` exited as a no-op on a fresh app.With the
model-list-filter-*.jsglob and the needle-first two-pass lookup in this PR,patch-appnow resolves the correct bundle and rewrites the guard tos=!1. Verified end-to-end: the picker shows custom catalog entries again. README test matrix updated accordingly.