Skip to content

feat(cua-driver): honor GITHUB_TOKEN/GH_TOKEN in GitHub API update checks (#2106) - #2116

Open
injaneity wants to merge 1 commit into
trycua:mainfrom
injaneity:feat/2106-github-token-update-checks
Open

feat(cua-driver): honor GITHUB_TOKEN/GH_TOKEN in GitHub API update checks (#2106)#2116
injaneity wants to merge 1 commit into
trycua:mainfrom
injaneity:feat/2106-github-token-update-checks

Conversation

@injaneity

@injaneity injaneity commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • honor GITHUB_TOKEN, then GH_TOKEN, for cua-driver GitHub Releases API update checks
  • pass GitHub API auth headers from install.ps1 release resolution without logging tokens
  • document the env vars and correct stale Windows install path/one-liner

Docs

  • Regenerated cua-driver reference docs with npx tsx scripts/docs-generators/cua-driver.ts; no generated file drift.
  • Verified with npx tsx scripts/docs-generators/cua-driver.ts --check.

Verification

  • cd libs/cua-driver/rust && cargo check -p cua-driver
  • npx tsx scripts/docs-generators/cua-driver.ts --check
  • cargo test -p cua-driver github_token_prefers_github_token_and_trims_empty_values was attempted, but macOS linking failed due missing Swift compatibility libraries/frameworks (swiftCompatibility56, swiftCompatibilityConcurrency, CoreAudioTypes).
  • PowerShell parse check skipped: pwsh/powershell is not installed in this environment.

Summary by CodeRabbit

  • New Features

    • Added support for using GITHUB_TOKEN or GH_TOKEN during install and update checks to help avoid GitHub API rate limits.
    • Updated Windows install guidance with the latest default driver location and fallback install path.
  • Bug Fixes

    • Improved release lookup on rate-limited networks by sending authenticated GitHub API requests when a token is available.
    • Added a note that empty or whitespace-only tokens are ignored.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

This PR adds optional GitHub API token authentication (via GITHUB_TOKEN/GH_TOKEN) to both the Rust version_check.rs module and the PowerShell install.ps1 script, attaching Authorization: Bearer headers to GitHub Releases API calls, plus documentation updates describing the new default install path and rate-limit guidance.

Changes

GitHub Token Authentication

Layer / File(s) Summary
Rust version_check token support
libs/cua-driver/rust/crates/cua-driver/src/version_check.rs
Adds github_token() helper reading GITHUB_TOKEN/GH_TOKEN (trimmed, non-empty), applies it as a Bearer header in fetch_latest_version(), and adds a unit test for precedence/trimming behavior.
PowerShell installer token support
libs/cua-driver/scripts/install.ps1
Adds Get-GitHubApiHeaders function to build an Authorization header from token env vars, applies it to the Releases API pagination call, and updates header documentation.
Documentation updates
docs/content/docs/how-to-guides/driver/install.mdx, libs/cua-driver/rust/Skills/cua-driver/WINDOWS.md
Adds guidance on setting GITHUB_TOKEN/GH_TOKEN for rate-limited networks and updates the documented default cua-driver.exe install path and fallback install script URL.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant InstallScript as install.ps1 / version_check.rs
  participant TokenReader as GitHubApiHeaders / github_token
  participant GitHubAPI as GitHub Releases API

  User->>InstallScript: run install/update check
  InstallScript->>TokenReader: read GITHUB_TOKEN / GH_TOKEN
  TokenReader-->>InstallScript: Authorization header or none
  InstallScript->>GitHubAPI: request releases (with/without header)
  GitHubAPI-->>InstallScript: releases data
  InstallScript-->>User: install/update result
Loading

Possibly related PRs

  • trycua/cua#1556: Both PRs touch libs/cua-driver/scripts/install.ps1; this PR extends the installer with Authorization: Bearer header support.
  • trycua/cua#1664: Both PRs modify install.ps1's GitHub API interaction logic and related messaging.

Poem

A token in my paw, so bright and true,
No more rate limits chasing my burrow-crew!
GITHUB_TOKEN whispered, GH_TOKEN too,
Bearer headers hop right through. 🐇
Install, update, no delay in sight—
This bunny installs with all its might!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

@f-trycua f-trycua left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The selector unit test covers environment precedence, but the security-sensitive request boundary is not exercised. After resolving the conflict, please add a deterministic request-level test that observes the actual Authorization header for GITHUB_TOKEN and GH_TOKEN precedence, empty-value behavior, absence of the header when unset, and confirmation that token values cannot appear in returned errors. Cover the PowerShell request path as well.

@injaneity
injaneity force-pushed the feat/2106-github-token-update-checks branch from 52d75a5 to e4b3efd Compare August 20, 2026 18:55
@injaneity
injaneity force-pushed the feat/2106-github-token-update-checks branch from e4b3efd to fe01e5e Compare August 20, 2026 18:55
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