Files
2026-10-22 10:24:33 +02:00

10 lines
1.4 KiB
Markdown

# Codex usage widget
Add **Codex usage** from the dashboard widget catalogue. The card shows remaining capacity in circular gauges for each usage window returned by the service, plus each window's reset time. Times are converted to the browser's local timezone. The footer shows the next scheduled refresh time.
The authenticated Django endpoint `dashboard/codex-usage/` requests `http://192.168.1.122:3100/api/usage` by default. Set `DASHBOARD_CODEX_USAGE_URL` on the Django server to override it. The browser receives only normalized display fields; the upstream account ID and full response stay server-side. The service response is cached for 45 seconds in the shared file cache. The browser polls the HTML partial with HTMX every 60 seconds while the widget is mounted.
If the service fails, the last successful display remains available for up to 15 minutes and is visibly marked stale. After that, the card shows an unavailable state. A response explicitly marked stale is also labeled. The widget never guesses missing percentages or reset times. Removing the card stops its HTMX polling with the DOM element; adding it again starts a new poll.
The dashboard template adds a version query to the widget stylesheet and scripts, including `builder.js`. This forces browsers with an older cached widget catalogue script to load the current type registry and Add handler after deployment.