opencode-statboard 2.10.24 → 2.10.25

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +19 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "2.10.24",
3
+ "version": "2.10.25",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -871,18 +871,7 @@ function settleBundle(now, msg) {
871
871
  // Today/7 days/Month/All is an in-memory swap (1–2ms) instead of a build.
872
872
  // Each build is ~25ms of pure in-memory work (no DB hit), and they run one
873
873
  // per tick so startup never blocks.
874
- setImmediate(() => {
875
- const scopes = [1, 7, 30, -1];
876
- const warm = (i) => {
877
- if (i >= scopes.length) return;
878
- try {
879
- const r = buildReportFromDb(scopes[i]);
880
- if (r && r.stats && r.stats.ok) reportCache[String(scopes[i])] = r;
881
- } catch (_) {}
882
- setImmediate(() => warm(i + 1));
883
- };
884
- warm(0);
885
- });
874
+ prewarmReports();
886
875
  }
887
876
 
888
877
  // Pure tool-count scan (no cache side effects) so the worker can run it.
@@ -1368,6 +1357,21 @@ function buildReportFromDb(days) {
1368
1357
  };
1369
1358
  }
1370
1359
 
1360
+ function prewarmReports() {
1361
+ setImmediate(() => {
1362
+ const scopes = [1, 7, 30, -1];
1363
+ const warm = (i) => {
1364
+ if (i >= scopes.length) return;
1365
+ try {
1366
+ const r = buildReportFromDb(scopes[i]);
1367
+ if (r && r.stats && r.stats.ok) reportCache[String(scopes[i])] = r;
1368
+ } catch (_) {}
1369
+ setImmediate(() => warm(i + 1));
1370
+ };
1371
+ warm(0);
1372
+ });
1373
+ }
1374
+
1371
1375
  function refreshReport(days) {
1372
1376
  const key = String(days);
1373
1377
  const hit = reportCache[key];
@@ -1587,6 +1591,9 @@ async function startServer() {
1587
1591
  const cached = loadBundleCache();
1588
1592
  attrAllCache = cached || null;
1589
1593
  getDb(); // detect schema now, so the worker result lands on a warm handle
1594
+ // Reports for every scope are pure in-memory builds off the bundle: do them
1595
+ // now so the first scope click is a swap, not a build.
1596
+ prewarmReports();
1590
1597
  // Spawn the fresh scan BEFORE the first refresh: while it is in flight the
1591
1598
  // request thread never runs the inline tool scan (toolCountsFor skips it).
1592
1599
  refreshAttrBundle();