Skip to content

Add proxy config patch script#50

Open
DevSplash wants to merge 2 commits intoHaleclipse:masterfrom
DevSplash:master
Open

Add proxy config patch script#50
DevSplash wants to merge 2 commits intoHaleclipse:masterfrom
DevSplash:master

Conversation

@DevSplash
Copy link
Copy Markdown

@DevSplash DevSplash commented May 6, 2026

#43

Summary by Sourcery

Add a post-build script that injects proxy configuration logic into Electron bootstrap files so the desktop app can honor Codex proxy settings from config.toml across platforms.

New Features:

  • Support reading a [proxy] section from Codex config.toml (or an overridden path) and applying the proxy settings application-wide.
  • Propagate configured proxy settings to environment variables and Electron command-line switches to affect both the app and child processes.

Enhancements:

  • Extend the patch-all pipeline to run a new proxy configuration patch script against platform-specific bootstrap.js outputs, with idempotent and update-aware injection behavior.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 6, 2026

Reviewer's Guide

Adds a new post-build patch script that injects proxy configuration logic into Electron bootstrap files based on Codex config.toml, and wires it into the existing patch-all pipeline.

File-Level Changes

Change Details Files
Add proxy configuration bootstrap patch script and integrate it into the patch pipeline.
  • Register new proxy patch script in the PATCHES list so it runs with other post-build patches.
  • Implement TOML-like parsing of the [proxy] section from Codex config.toml with env override for config path.
  • Derive proxy server and bypass values from config, with support for multiple key aliases and a feature flag via an enabled setting.
  • Inject an IIFE into bootstrap.js that sets HTTP(S)/ALL/NO_PROXY environment variables and configures Electron proxy switches and defaultSession proxy.
  • Support idempotent and updatable patching by detecting existing injected blocks and replacing them only when content changes.
  • Locate bootstrap.js across per-platform build directories with fallbacks and a conservative recursive search for robustness.
  • Add a --check mode to report patchable bootstrap targets without modifying files and support optional platform-specific patching.
scripts/patch-all.js
scripts/patch-proxy-config.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/patch-proxy-config.js" line_range="180-194" />
<code_context>
+}
+
+function patchSource(source) {
+  if (source.includes(MARKER)) {
+    const start = source.indexOf("/* " + MARKER + " */");
+    const end = source.indexOf("})();", start);
+    if (start !== -1 && end !== -1) {
+      const blockEnd = end + "})();".length;
+      const current = source.slice(start, blockEnd);
+      if (current === INJECTED) return { code: source, status: "already" };
+      return {
+        code: `${source.slice(0, start)}${INJECTED}${source.slice(blockEnd)}`,
+        status: "updated",
+      };
+    }
+    return { code: source, status: "already" };
+  }
+
</code_context>
<issue_to_address>
**suggestion:** Treat partial/failed marker matches as a mismatch instead of assuming the patch is already applied.

Because any file containing `MARKER` but lacking the exact `/* Codex proxy config patch */ ... })();` block is currently treated as `status: "already"`, truncated or manually edited blocks will be silently skipped. Consider treating the `start === -1 || end === -1` case as a mismatch (e.g., `"no-match"`) or attempting reinsertion so you avoid false positives and can log unexpected layouts.

```suggestion
function patchSource(source) {
  if (source.includes(MARKER)) {
    const start = source.indexOf("/* " + MARKER + " */");
    const end = source.indexOf("})();", start);

    // If we see the marker but can't find a well-formed injected block,
    // treat this as a mismatch so callers can log/handle the anomaly.
    if (start === -1 || end === -1) {
      return { code: source, status: "no-match" };
    }

    const blockEnd = end + "})();".length;
    const current = source.slice(start, blockEnd);

    if (current === INJECTED) {
      return { code: source, status: "already" };
    }

    return {
      code: `${source.slice(0, start)}${INJECTED}${source.slice(blockEnd)}`,
      status: "updated",
    };
  }
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread scripts/patch-proxy-config.js
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant