opencode-copilot-chat icon indicating copy to clipboard operation
opencode-copilot-chat copied to clipboard

feat: manual usage targets + live pricing for Go tracker

Open Wallacy opened this issue 5 months ago • 0 comments

Summary

Adds manual Go usage target configuration and fixes cost estimation to use live models.dev pricing instead of a stale hardcoded table.

Closes

Closes #23

Changes

Manual Usage Targets (showUsageTargetEditor)

  • New command "OpenCode Go: Set Usage Targets..." opens 5 sequential input boxes pre-filled with current values:
    • Session spent (rolling 5h, limit $12)
    • Weekly spent (Mon–Mon UTC, limit $30)
    • Monthly spent (limit $60)
    • Monthly reset day (1–31)
    • Monthly reset hour (0–23 UTC)
  • Press Enter on any input to keep the current value; Escape cancels the entire flow.
  • Targets are persisted in globalState as baseline amounts with a custom expiresAt for the monthly anchor.

Monthly Reset Display Fix

  • buildSummaryFromTracked and buildSummaryFromRows now use baseline.monthly.expiresAt as resetsAt when available, so the "resets in Xd Yh" text reflects the user-configured anchor date instead of the auto-calculated month end.

Webview / Status Bar Cleanup

  • Removed button and scripts from the usage webview (now display-only SVG).
  • Status bar click disabled (hover-only via tooltip).
  • Tooltip links to the setUsageTargets command.

Live Pricing Fallback

  • Injected a CostResolver callback into GoUsageTracker that reads from the live models.dev metadata snapshot.
  • Cost resolution priority: per-request externalCost → live snapshot → bundled static table.
  • The hardcoded GO_MODEL_PRICING is kept only as a last-resort fallback.

Commits

  • d031457 — feat: add manual usage targets editor for Go usage tracker
  • 094978e — fix: use live models.dev pricing instead of hardcoded fallback in Go tracker

Wallacy avatar Jun 16 '26 21:06 Wallacy