opencode-statboard 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -353,6 +353,12 @@ async function poll() {
353
353
  try {
354
354
  const r = await fetch('/api/stats?days=' + currentDays + '&_=' + Date.now(), { cache: 'no-store' });
355
355
  const j = await r.json();
356
+ if (j.loading) {
357
+ $('pill').textContent = t('updating');
358
+ $('pill').className = 'pill lang';
359
+ $('updated').textContent = t('updating');
360
+ return;
361
+ }
356
362
  if (!j.ok) {
357
363
  $('errbanner').textContent = t('statsFail') + ': ' + (j.error || '');
358
364
  $('errbanner').classList.add('show');
package/server.js CHANGED
@@ -18,7 +18,7 @@ const EXE = (() => {
18
18
  return 'opencode';
19
19
  })();
20
20
 
21
- const state = { data: null, busy: false, error: null, updatedAt: 0, models: null, modelsBusy: false };
21
+ const state = { data: null, busy: false, error: null, updatedAt: 0, models: null, modelsBusy: false, loading: true };
22
22
 
23
23
  let indexHtmlCache = null;
24
24
 
@@ -223,6 +223,7 @@ async function refresh() {
223
223
  } else {
224
224
  state.error = state.error || 'opencode stats failed';
225
225
  }
226
+ state.loading = false;
226
227
  state.busy = false;
227
228
  }
228
229
 
@@ -329,6 +330,7 @@ const server = http.createServer(async (req, res) => {
329
330
  res.setHeader('Cache-Control', 'no-store');
330
331
  res.end(JSON.stringify({
331
332
  ok: !!state.data,
333
+ loading: state.loading,
332
334
  error: state.error,
333
335
  generatedAt: state.updatedAt,
334
336
  data: state.data,