BackendApiClient: Include GitHub token in search and explore requests#436
BackendApiClient: Include GitHub token in search and explore requests#436rainxchzed merged 2 commits intomainfrom
Conversation
- Inject `TokenStore` into `BackendApiClient`. - Implement `currentUserGithubToken()` to retrieve and trim the access token from `TokenStore`. - Add `X-GitHub-Token` header to `search` and `search/explore` requests if a token is available. - Update `SharedModule` to provide the `TokenStore` dependency to `BackendApiClient`. - Cleanup: Remove several detailed internal comments regarding language selection logic and DataStore timeouts in `TweaksViewModel`, `TweaksRepositoryImpl`, `DesktopApp`, and `MainActivity`.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRemoved several explanatory comment blocks about DataStore/language-read behavior; added a TokenStore dependency to BackendApiClient and logic to fetch a GitHub token and conditionally attach an Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BackendApiClient
participant TokenStore
participant GitHubAPI
Client->>BackendApiClient: search(params)
BackendApiClient->>TokenStore: get current token
TokenStore-->>BackendApiClient: token (or null)
alt token present
BackendApiClient->>GitHubAPI: HTTP GET /search (with X-GitHub-Token header)
else no token
BackendApiClient->>GitHubAPI: HTTP GET /search (no token header)
end
GitHubAPI-->>BackendApiClient: response
BackendApiClient-->>Client: parsed result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@core/data/src/commonMain/kotlin/zed/rainxch/core/data/network/BackendApiClient.kt`:
- Around line 153-157: The helper currentUserGithubToken uses runCatching which
swallows CancellationException; change it to an explicit try/catch that rethrows
CancellationException and only swallows other Throwables: call
tokenStore.currentToken()?.accessToken?.trim() in a try block, if the result is
null/empty return null, catch CancellationException and rethrow it, and catch
Throwable (or Exception) to return null—this preserves structured concurrency
while keeping the original null-on-error behavior; reference
currentUserGithubToken and tokenStore.currentToken().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 27688e39-c781-4fec-9b1f-15e84b7f9c2b
📒 Files selected for processing (6)
composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.ktcomposeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/DesktopApp.ktcore/data/src/commonMain/kotlin/zed/rainxch/core/data/di/SharedModule.ktcore/data/src/commonMain/kotlin/zed/rainxch/core/data/network/BackendApiClient.ktcore/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.ktfeature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt
💤 Files with no reviewable changes (4)
- composeApp/src/jvmMain/kotlin/zed/rainxch/githubstore/DesktopApp.kt
- composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/MainActivity.kt
- core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt
- feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt
…BackendApiClient.kt Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
TokenStoreintoBackendApiClient.currentUserGithubToken()to retrieve and trim the access token fromTokenStore.X-GitHub-Tokenheader tosearchandsearch/explorerequests if a token is available.SharedModuleto provide theTokenStoredependency toBackendApiClient.TweaksViewModel,TweaksRepositoryImpl,DesktopApp, andMainActivity.Summary by CodeRabbit
New Features
Documentation