Skip to content

feat(mac): add proxy config and harden quota window routing - #57

Open
XLevon wants to merge 2 commits into
Cmochance:mainfrom
XLevon:feat/mac-proxy-config
Open

feat(mac): add proxy config and harden quota window routing#57
XLevon wants to merge 2 commits into
Cmochance:mainfrom
XLevon:feat/mac-proxy-config

Conversation

@XLevon

@XLevon XLevon commented Jul 24, 2026

Copy link
Copy Markdown

Changes

Proxy configuration (macOS)

  • Add Settings UI for HTTP/HTTPS/SOCKS5/SOCKS5h proxy configuration
  • Store proxy_state.json under per-platform runtime dir (macos/)
  • Inject proxy into reqwest HTTP client (ChatGPT plan/quota API)
  • Inject proxy env vars into codex app-server and login subprocesses
  • Inject proxy env vars into update-check curl subprocess
  • Invalidate cached HTTP client on proxy change for immediate effect (no restart needed)
  • Validate proxy URL via reqwest::Proxy::all before saving
  • Enable reqwest socks feature for SOCKS5 support

Quota window routing fix

  • Fall back to reset_at distance when window_minutes is missing in /wham/usage payload (observed in production). 5h window resets within hours, weekly resets in days; classify by 6h threshold.
  • Apply reset_at fallback across all three data paths: chatgpt_api, codex_app_server, session_usage
  • Show Xd Yh Zm reset countdown when reset is more than a day out (previously 115h 20m for weekly resets)

Test plan

  • cargo test quota_routing — 5 tests pass
  • cargo check --lib — compiles clean
  • Manual test: configure socks5h://127.0.0.1:7898, refresh profile, 403 region error gone
  • Manual test: weekly quota now displays in weekly slot (was incorrectly in 5h slot)
  • Manual test: reset countdown shows 4d 19h 20m instead of 115h 20m

Proxy configuration (macOS):
- Add Settings UI for HTTP/HTTPS/SOCKS5/SOCKS5h proxy configuration
- Store proxy_state.json under per-platform runtime dir (macos/)
- Inject proxy into reqwest HTTP client (ChatGPT plan/quota API)
- Inject proxy env vars into codex app-server and login subprocesses
- Inject proxy env vars into update-check curl subprocess
- Invalidate cached HTTP client on proxy change for immediate effect
- Validate proxy URL via reqwest::Proxy::all before saving
- reqwest: enable socks feature for SOCKS5 support

Quota window routing:
- Fall back to reset_at distance when window_minutes is missing in
  /wham/usage payload (observed in production). 5h window resets within
  hours, weekly resets in days; classify by 6h threshold.
- Apply reset_at fallback across all three data paths: chatgpt_api,
  codex_app_server, session_usage
- Show "Xd Yh Zm" reset countdown when reset is more than a day out
  (previously "115h 20m" for weekly resets)
@Cmochance
Cmochance force-pushed the feat/mac-proxy-config branch from 4808388 to f1b4c43 Compare July 26, 2026 01:08
@Cmochance

Copy link
Copy Markdown
Owner

@XLevon Thanks for the contribution! Maintainer note: #56 landed on main first and touched the same quota code, so I rebased this branch onto the new main (via the "allow edits from maintainers" permission) — 4808388f1b4c43, your authorship is preserved.

What changed during the rebase:

  • Resolved the one conflict in chatgpt_api.rs (quota_summary_from_payload): feat(quota): show reset credit expiry details #56 wrapped the window loop in if let Some(rate_limit) (reset credits can now exist without rate_limit), and your reset_at fallback now lives inside that wrapper. Both behaviors are preserved.
  • Applied cargo fmt on top (4 formatting spots — there is no fmt gate in CI, so it hadn't surfaced).

Local verification after the rebase: cargo test --lib 150 passed (including your 6 routing tests), tsc --noEmit, vitest run, and npm run build all green.

Surfaced by Cmochance#57: formatting drift passed CI because no fmt check ran.
rustfmt is not in dtolnay/rust-toolchain's minimal profile, so declare
the component explicitly.
@XLevon

XLevon commented Jul 28, 2026 via email

Copy link
Copy Markdown
Author

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.

2 participants