Show OpenCode Go usage from browser sessions - #14
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds ChangesOpenCode Go usage
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Fetch
participant BrowserSessions
participant OpenCode
CLI->>Fetch: Request OpenCode Go usage
Fetch->>BrowserSessions: Scan authenticated browser sessions
BrowserSessions-->>Fetch: Return cookies and scan results
Fetch->>OpenCode: Request authenticated workspace pages
OpenCode-->>Fetch: Return workspace and usage data
Fetch-->>CLI: Display ProviderUsage
Possibly related PRs
✨ 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 |
| if command == "usage" && providerName == "opencode-go" { | ||
| usage, err := fetchOpenCodeGoUsage(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| printUsage(stdout, usage) | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Suggestion: The local-browser path ignores options.profile, even though usage validation accepts --profile and provider usage help advertises it. Consequently, prism opencode-go usage --profile <name> silently scans and reports every supported local browser session instead of honoring the selected profile. Either pass the profile through to the browser-session fetcher and scope the scan, or reject --profile for this provider. [api mismatch]
Severity Level: Major ⚠️
- ❌ `opencode-go usage --profile` can display usage from unintended browser sessions.
- ⚠️ Provider usage help advertises `--profile` through `internal/cli/run.go:618-620`.
- ⚠️ Multiple local browser accounts can produce ambiguous or incorrect output.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/cli/run.go
**Line:** 87:94
**Comment:**
*Api Mismatch: The local-browser path ignores `options.profile`, even though usage validation accepts `--profile` and provider usage help advertises it. Consequently, `prism opencode-go usage --profile <name>` silently scans and reports every supported local browser session instead of honoring the selected profile. Either pass the profile through to the browser-session fetcher and scope the scan, or reject `--profile` for this provider.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| for _, suffix := range []string{"", "-wal", "-shm"} { | ||
| if err := copyFile(source+suffix, destination+suffix); err != nil { | ||
| if suffix != "" && os.IsNotExist(err) { | ||
| continue | ||
| } | ||
| cleanup() | ||
| return "", func() {}, err | ||
| } |
There was a problem hiding this comment.
Suggestion: The database, WAL, and shared-memory files are copied in separate operations while the browser can write them concurrently. This can produce a main database paired with an unrelated WAL or shared-memory generation, causing SQLite to reject the snapshot or read an inconsistent state and report the browser store as unreadable. Create the snapshot through a SQLite-consistent backup mechanism or otherwise coordinate the files as one snapshot. [race condition]
Severity Level: Major ⚠️
- ⚠️ Active browser writes can make cookie snapshots unreadable.
- ❌ OpenCode usage fails during browser-backed session discovery.
- ⚠️ Failure affects macOS Chromium-family users.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/opencodego/session_darwin.go
**Line:** 354:361
**Comment:**
*Race Condition: The database, WAL, and shared-memory files are copied in separate operations while the browser can write them concurrently. This can produce a main database paired with an unrelated WAL or shared-memory generation, causing SQLite to reject the snapshot or read an inconsistent state and report the browser store as unreadable. Create the snapshot through a SQLite-consistent backup mechanism or otherwise coordinate the files as one snapshot.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
User description
Summary
Verification
CodeAnt-AI Description
Show OpenCode Go usage from existing browser sessions
What Changed
prism opencode-go usageto display rolling, weekly, and monthly OpenCode Go limits, remaining percentages, reset times, and usage-limit status.Impact
✅ View OpenCode Go usage without adding credentials✅ See all rolling, weekly, and monthly reset times✅ Clearer errors when browser sessions cannot be used💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
New Features
opencode-go usagecommand to display OpenCode Go usage and reset information by workspace.Documentation