Skip to content

update(opencode-go): fix dashboard scraping + display all three usage windows#62

Closed
capyBearista wants to merge 2 commits intoslkiser:mainfrom
capyBearista:fix/opencode-go
Closed

update(opencode-go): fix dashboard scraping + display all three usage windows#62
capyBearista wants to merge 2 commits intoslkiser:mainfrom
capyBearista:fix/opencode-go

Conversation

@capyBearista
Copy link
Copy Markdown
Contributor

@capyBearista capyBearista commented Apr 27, 2026

Summary

This PR adds support for all three OpenCode Go usage windows—Rolling, Weekly, and Monthly—alongside a rewritten dashboard scraper (for robustness).

The previous implementation only parsed monthlyUsage and relied on brittle regex patterns that broke on dashboard markup changes (e.g., extra fields like status appearing between usage data). The scraper has been replaced with a strategy-based approach; [according to an LLM explaining the regex] it now uses "string-aware brace-depth matching and strict anchor isolation against $R[...] hydration markers". This correctly handles decoy keys (like billing metadata), braces inside string literals, and field order variations.

Behavioral details:

  • Rolling: Timer is blank when idle (0% usage), showing a live countdown only once usage begins
  • Weekly / Monthly: Timers always display live countdowns since they don't depend on the user to initiate a session
  • The three windows are ordered Rolling -> Weekly -> Monthly in the TUI sidebar
  • A forceAllWindows presentation flag ensures all three display regardless of the user's chosen formatStyle in the config
  • Diagnostics in /quota_status now report all three windows separately

Example:

opencode_go:
- config_state: configured
- config_source: env
- config_checked_paths: /home/arjun/.config/opencode/opencode-quota/opencode-go.json
- rolling_usage: used=8% rem=92% reset=15359s at=2026-04-27T05:48:20.888Z
- weekly_usage: used=3% rem=97% reset=599258s at=2026-05-03T23:59:59.888Z
- monthly_usage: used=51% rem=49% reset=2050404s at=2026-05-20T19:05:45.888Z
- live_probe: success
- live_entry_1: Rolling: percent_remaining=92 reset_at=2026-04-27T05:48:21.388Z
- live_entry_2: Weekly: percent_remaining=97 reset_at=2026-05-04T00:00:00.388Z
- live_more: +1 additional rows suppressed
...

What it looks like now:

image

Linked Issue

No existing issue. Rationale: The OpenCode Go quota was failing to be scraped, "throwing a vague live_fetch_error and was previously also limited to a single monthly usage window. This expands the provider to parity with the actual dashboard, which has always exposed all three windows.

OpenCode Validation

  • Current production released OpenCode version tested: 1.14.25, 1.14.26, 1.14.27
  • Why this version is relevant to the fix: This is the latest stable version of OpenCode (as of April 26, 2026)

Quality Checklist

  • I ran npm run typecheck
  • I ran npm test
  • I ran npm run build
  • This is the smallest safe root-cause fix (no unnecessary hook/output mutation logic)
  • I preserved behavioral invariants and updated/added boundary tests as needed
  • I updated docs for user-facing workflow/command/config changes (README.md and CONTRIBUTING.md when applicable)

Implemented a multi-strategy parsing approach for the OpenCode Go dashboard to handle varied SolidJS hydration patterns and pure JSON objects. Added smart URL normalization for workspace IDs and enhanced error reporting with masked HTML snippets to aid future debugging without leaking sensitive data.
Parses rolling, weekly, and monthly usage from the OpenCode Go
dashboard using string-aware brace matching with strict anchor
isolation against SolidJS $R[...] hydration markers. The old
regex-only approach was fragile against dashboard markup changes.

- Rolling timer is blank when idle (0% usage), active otherwise
- Weekly/Monthly always show live countdowns (fixed cycles)
- Ordered Rolling -> Weekly -> Monthly in the TUI sidebar
- forceAllWindows ensures all three display regardless of formatStyle
- Plural forms added to duration ranking (weeks, days, months, years)
@capyBearista capyBearista changed the title feat(opencode-go): display all three usage windows with robust scraper fix(opencode-go): display all three usage windows with robust scraper Apr 27, 2026
@capyBearista capyBearista changed the title fix(opencode-go): display all three usage windows with robust scraper update(opencode-go): fix dashboard scraping + display all three usage windows Apr 27, 2026
@capyBearista capyBearista marked this pull request as ready for review April 28, 2026 03:57
@slkiser
Copy link
Copy Markdown
Owner

slkiser commented Apr 28, 2026

@capyBearista I took somethings and added them to #65 (scraping was better here in #62)

@slkiser slkiser closed this Apr 28, 2026
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