Skip to content

fix(rate-limits): authenticate OpenCode Go through a session cookie jar - #8047

Merged
OrcaWin merged 4 commits into
stablyai:mainfrom
bbingz:fix/opencode-go-windows-session-cookie
Jul 23, 2026
Merged

OrcaWin merged 4 commits into
stablyai:mainfrom
bbingz:fix/opencode-go-windows-session-cookie

Conversation

@bbingz

@bbingz bbingz commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #7104.

OpenCode Go usage refresh now authenticates through an isolated Electron session cookie jar instead of manually setting the Cookie request header. This avoids Chromium's net::ERR_FAILED behavior observed on Windows while preserving the existing workspace discovery and usage parsing flow.

The session accepts only the auth and __Host-auth cookies, clears its cookie storage before use, and clears it again after success or failure. Users can continue pasting either a full auth cookie pair or a bare token.

Screenshots

No visual change. The existing OpenCode Go usage UI now displays quota data instead of a refresh error on affected Windows systems.

Testing

  • pnpm lint — repository baseline fails locale parity for ja.json: interpolation mismatch at components.native-chat.composer.uploadingAttachments; all earlier lint stages passed
  • pnpm typecheck
  • pnpm test — OpenCode tests pass, but the full Windows suite has 93 existing failures across 31 files (including /bin/sh and openssl ENOENT, symlink behavior, and unrelated Claude usage expectations)
  • pnpm build
  • Added high-quality regression tests covering isolated-session selection, omission of the manual Cookie header, auth-cookie filtering, cleanup after success, and cleanup after partial cookie setup failure

Additional verification:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/rate-limits/opencode-go-usage-fetcher.test.ts — 29/29 passed
  • pnpm exec oxlint src/main/rate-limits/opencode-go-usage-fetcher.ts src/main/rate-limits/opencode-go-usage-fetcher.test.ts — passed
  • pnpm check:max-lines-ratchet — passed
  • Windows 11 real-account smoke test — OpenCode Go quota displayed successfully in the development build with no net::ERR_FAILED or cookie-jar errors

AI Review Report

Reviewed the final diff for correctness, failure cleanup, compatibility, and scope.

  • Flagged that a rejected cookies.set() could leave an earlier cookie installed; added cleanup for partial initialization and a regression test.
  • Confirmed the session is isolated from browser profiles and other usage providers, and that only OpenCode auth-cookie names are installed.
  • Cross-platform: the Electron Session API and HTTPS cookie attributes are supported on Windows, macOS, and Linux; no platform-specific shortcuts, labels, paths, or shell behavior changed.
  • Local/remote/SSH: usage fetching remains a main-process web integration and does not assume a local repository, shell, SSH host, or remote runtime path.
  • Agents/integrations/git providers: behavior is explicitly scoped to OpenCode Go; other agents, usage providers, and GitHub/GitLab review flows are unchanged.
  • Performance: one isolated session is reused for the two sequential requests, with bounded 15-second request timeouts. Cookie setup/cleanup adds only small constant work during usage refresh.
  • UI: no UI code or design-system behavior changed.

No unresolved review findings remain.

Security Audit

  • Authentication input is filtered to auth and __Host-auth; unrelated pasted cookies are not installed or transmitted.
  • The manual Cookie header was removed, allowing Chromium to attach cookies from its scoped jar normally.
  • The non-persistent rate-limit session is cleared before and after each fetch, including request failure and partial cookie installation failure.
  • Cookie values are not logged, included in errors, committed, or exposed through IPC by this change.
  • No command execution, filesystem path handling, dependency, or new IPC surface was introduced.

Notes

  • Primary bug and real-account verification platform: Windows 11.
  • No release/version changes.
  • X handle: not provided on the contributor's GitHub profile.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bc788a08-7a67-46fd-b5f7-e20960a31211

📥 Commits

Reviewing files that changed from the base of the PR and between dbe482fae11a258e7b0b23421f62369dae55915b and 69827fa.

📒 Files selected for processing (2)
  • src/main/rate-limits/opencode-go-usage-fetcher.test.ts
  • src/main/rate-limits/opencode-go-usage-fetcher.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/rate-limits/opencode-go-usage-fetcher.test.ts
  • src/main/rate-limits/opencode-go-usage-fetcher.ts

📝 Walkthrough

Walkthrough

OpenCode Go rate-limit fetching now parses supported authentication cookies and installs them in an isolated Electron session partition. Workspace and usage requests use the session’s cookie jar instead of manually setting Cookie headers. Session storage is cleared before setup, after fetching, and when cookie installation fails. Tests now mock the partitioned session and verify cookie installation, request headers, filtering, and cleanup behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: OpenCode Go now authenticates via an Electron session cookie jar.
Description check ✅ Passed The description follows the template and includes all required sections with substantial testing, review, security, and notes details.
Linked Issues check ✅ Passed The changes address #7104 by removing the manual Cookie header path and fixing OpenCode Go refresh through an isolated session jar.
Out of Scope Changes check ✅ Passed The diff stays focused on the OpenCode Go fetcher and its tests, with no unrelated feature, UI, or dependency changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bbingz
bbingz force-pushed the fix/opencode-go-windows-session-cookie branch from dbe482f to 69827fa Compare July 10, 2026 10:04
@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the fix! I pushed a maintainer follow-up that keeps the isolated cookie-jar approach while making the partition honor Orca, environment, and system proxy settings, serializing cookie installation so cleanup cannot race a rejected write, and adding focused regression coverage. The branch remains conflict-free with current main; changed-area tests, lint, max-lines, and the full typecheck pass.

@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@brennanb2025 Thanks for the maintainer follow-up (cookie-jar partition + install serialization + regressions).

Still MERGEABLE against current main. Ready to merge from my side.

@brennanb2025

Copy link
Copy Markdown
Contributor

Sorry for the delay, just doing one more manual test then will merge it in!

@OrcaWin
OrcaWin merged commit 9080205 into stablyai:main Jul 23, 2026
1 check passed
@bbingz
bbingz deleted the fix/opencode-go-windows-session-cookie branch August 1, 2026 00:47
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ar (stablyai#8047)

* fix(rate-limits): use session cookies for OpenCode Go

* fix(rate-limits): harden OpenCode session setup

---------

Co-authored-by: Brennan Benson <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
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.

OpenCode Go usage refresh fails with net::ERR_FAILED on Windows despite valid cookie

4 participants