How ranjithrajv/opencode-usage-quota-tracker works
This OpenCode plugin renders live usage and workspace quota in the TUI sidebar footer. Its workflow gathers credentials and session/provider state, fetches shared plan quota, then selects and renders a provider view; users can switch views through a picker or command, with the choice persisted. The main behavior is concentrated in tui.tsx; source excerpts show its polling, caching, session scans, and rendering, while README statements support the documented view-selection and integration capabilities.
Main entry points: tui.tsx TUI plugin setup · index.ts Server plugin entry
Components 18
Host integration
- Server plugin entry
src/index.ts - TUI plugin setup
tui.tsx
Usage collection
- OpenCode auth store
- Session messages
- Workspace usage API
- Quota fetcher
tui.tsx - Quota cache
tui.tsx - Session usage scan
tui.tsx - Provider usage totals
tui.tsx
Footer experience
- Provider views
tui.tsx - Connected providers
tui.tsx - View picker command
tui.tsx - Saved view choice
tui.tsx - Automatic view selection
tui.tsx - Usage row builder
tui.tsx - Footer renderer
tui.tsx
Other components
- OpenCode host
- Sidebar footer
Connections 23
- OpenCode host → Server plugin entry: loads plugin
README.md - OpenCode host → TUI plugin setup: loads TUI
README.md - TUI plugin setup → OpenCode auth store: reads credentials
tui.tsx - TUI plugin setup → Session messages: reads messages
tui.tsx - TUI plugin setup → Quota fetcher: starts polling
tui.tsx - Quota fetcher → Workspace usage API: fetches quota
README.md - Quota fetcher → Quota cache: updates cache
tui.tsx - TUI plugin setup → Quota cache: creates store
tui.tsx - TUI plugin setup → Connected providers: checks integrations
tui.tsx - TUI plugin setup → Session usage scan: scans sessions
tui.tsx - Session usage scan → Session messages: reads history
tui.tsx - Session usage scan → Provider usage totals: derives totals
tui.tsx - TUI plugin setup → View picker command: registers command
tui.tsx - View picker command → Saved view choice: persists choice
README.md - TUI plugin setup → Automatic view selection: selects view
README.md - Connected providers → Automatic view selection: limits choices
README.md - Saved view choice → Automatic view selection: provides fallback
README.md - Automatic view selection → Provider views: chooses provider
README.md - Provider views → Usage row builder: builds rows
README.md - Usage row builder → Footer renderer: supplies rows
tui.tsx - Quota cache → Usage row builder: supplies quota
tui.tsx - Provider usage totals → Usage row builder: supplies totals
tui.tsx - Footer renderer → Sidebar footer: renders footer
README.md