launcher: 将本地代理注入改为显式开启#82
Open
wanpan11 wants to merge 1 commit into
Open
Conversation
Add a --proxy flag so Codex launch only auto-injects a detected local proxy when explicitly requested. Update launcher tests for the new opt-in behavior and fix the Windows installer test to assert the current interpreter path across platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Makes local proxy auto-detection/injection opt-in for launcher-driven Codex starts, to avoid unexpectedly mutating the launched process environment unless explicitly requested.
Changes:
- Add a
--proxyCLI flag and threadauto_proxythroughlaunch_and_inject→launch_codex_app→codex_process_environment. - Update launcher tests to validate opt-in proxy behavior, and broaden monkeypatched call signatures to accept new kwargs.
- Fix Windows installer test expectations to assert the actual default interpreter path used in generated scripts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
codex_session_delete/launcher.py |
Adds auto_proxy plumbing and gates local proxy injection behind an opt-in flag. |
codex_session_delete/cli.py |
Introduces --proxy flag and passes it through to the launcher entrypoint. |
tests/test_launcher_cli.py |
Updates/extends tests for opt-in proxy behavior and adjusts mocks for new kwargs. |
tests/test_windows_installer.py |
Adjusts assertion to match the installer’s computed default Python executable path. |
Comments suppressed due to low confidence (1)
codex_session_delete/launcher.py:166
has_proxy_environment()treats empty-string proxy variables as “not set”, butenv.setdefault(...)will not overwrite an existing key whose value is''. If a user hasHTTP_PROXY/HTTPS_PROXYexported as empty and runs with--proxy, local proxy auto-detection will still not inject anything. Consider explicitly setting the keys when the current value is falsy (or deleting empty keys) so--proxyconsistently enables injection.
def codex_process_environment(auto_proxy: bool = False) -> dict[str, str]:
env = os.environ.copy()
if not auto_proxy:
return env
if has_proxy_environment(env):
return env
proxy = local_proxy_url()
if proxy:
env.setdefault("HTTP_PROXY", proxy)
env.setdefault("HTTPS_PROXY", proxy)
env.setdefault("ALL_PROXY", proxy)
return env
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
17
to
24
| def add_launch_arguments(parser: argparse.ArgumentParser) -> None: | ||
| parser.add_argument("--app-dir", type=Path, default=None) | ||
| parser.add_argument("--db", type=Path, default=Path.home() / ".codex" / "state_5.sqlite", help="SQLite database path for local deletion fallback") | ||
| parser.add_argument("--backup-dir", type=Path, default=Path.home() / ".codex-session-delete" / "backups") | ||
| parser.add_argument("--debug-port", type=int, default=9229) | ||
| parser.add_argument("--helper-port", type=int, default=57321) | ||
| parser.add_argument("--proxy", action="store_true", default=False, help="Auto-detect and inject local proxy into Codex process environment") | ||
|
|
Owner
|
原来的自动探测有什么问题 |
Contributor
Author
会话无法正常链接 一直重试直到失败 使用的 V2rayU |
Contributor
Author
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.

变更摘要
--proxy启动参数,使本地代理自动探测改为显式开启auto_proxy配置贯穿到 launcher 的启动与注入流程变更原因
默认自动注入探测到的本地代理,会在用户未明确要求时修改 Codex 启动进程的环境变量。此次调整后,只有在用户显式传入
--proxy时,才会启用代理自动注入。评审说明
--proxy后,若环境中已显式设置代理,仍会优先沿用已有配置;只有未设置时才会回退到本地代理自动探测