fix: enable fast mode patch for API auth#92
Open
siyuan-123 wants to merge 1 commit into
Open
Conversation
Reviewer's GuideUpdate the fast-mode patch script to handle both old and new auth gate shapes, expand chatgpt-only checks to include apikey, broaden bundle targeting heuristics, and improve check-mode reporting of detected gates. Sequence diagram for updated fast mode patch script in check modesequenceDiagram
participant CLI
participant main
participant bundles as locateBundles
participant fs
participant acorn
participant patcher as collectPatches
CLI->>main: node scripts/patch-fast-mode.js win --check
main->>bundles: locateBundles SRC_DIR
bundles-->>main: bundle list
loop per bundle
main->>fs: readFileSync(bundle.path)
main->>main: src.includes chatgpt and fast_mode
alt matches markers
main->>acorn: parse(src, ecmaVersion)
acorn-->>main: ast
main->>patcher: collectPatches(ast, src)
patcher-->>main: patches
main->>main: totalFound += patches.length
note over main: isCheck=true so no writeFileSync
else no markers
main->>main: skip bundle
end
end
alt totalPatched > 0
main-->>CLI: [ok] X auth gate(s) removed
else totalPatched == 0 and totalFound > 0
main-->>CLI: [check] totalFound auth gate(s) would be patched
else
main-->>CLI: [ok] fast_mode auth gates already patched or absent
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
siyuan-123
marked this pull request as ready for review
June 28, 2026 06:05
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- When expanding
=== 'chatgpt'comparisons, the replacement always uses a template literal forapikey; consider mirroring the original literal style (string vs template) to avoid unexpected formatting changes in minified/bundled code. - The
expressionSourceForApiKeySidehelper assumes the compared expression is a simple AST node and reuses its source slice; if more complex expressions or whitespace/comment variations appear, you may want to normalize or parenthesize the insertedapikeycomparison to avoid precedence or formatting issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When expanding `=== 'chatgpt'` comparisons, the replacement always uses a template literal for `apikey`; consider mirroring the original literal style (string vs template) to avoid unexpected formatting changes in minified/bundled code.
- The `expressionSourceForApiKeySide` helper assumes the compared expression is a simple AST node and reuses its source slice; if more complex expressions or whitespace/comment variations appear, you may want to normalize or parenthesize the inserted `apikey` comparison to avoid precedence or formatting issues.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary
This fixes the Fast mode patch for API-key auth on newer Codex Desktop bundles.
Root cause
The existing
scripts/patch-fast-mode.jsonly handled the older negative auth gate shape inside fast-mode functions:Newer upstream bundles now use positive
chatgptchecks instead, for both the UI selector and request-timeservice_tierplumbing, for example:As a result, API-key users (
apikey) still cannot use Fast mode even after the old patch runs:use-service-tier-settings-*read-service-tier-for-request-*Changes
chatgptcomparisons.!== "chatgpt"gate and continue replacing it with!1.=== "chatgpt"/=== `chatgpt`gate and expand it to also allow API-key auth:fast_mode+chatgptinstead of requiring the literal textauthMethod, because the request-time helper can use a local auth variable such asn.--checkoutput so it reports how many gates would be patched.Impact
API-key users can access Fast mode UI and the selected Fast service tier is preserved when building requests.
Validation
On the Windows upstream ASAR assets,
--checknow finds both target gates:Also validated:
After patching, the second
--checkreports the gates are already patched/absent, confirming the script is idempotent.Summary by Sourcery
Update the fast-mode patch script to support newer chatgpt-based auth gates and report patched gate counts for API-key users.
Bug Fixes:
Enhancements: