pi-mega-compact 0.15.3 → 0.15.4

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 (51) hide show
  1. package/dist/extensions/dashboard-server/resolve-snapshot.js +38 -28
  2. package/extensions/dashboard-client/dist/assets/{AreaChart-CMri0vM1.js → AreaChart-CrmTcE7w.js} +2 -2
  3. package/extensions/dashboard-client/dist/assets/{AreaChart-CMri0vM1.js.map → AreaChart-CrmTcE7w.js.map} +1 -1
  4. package/extensions/dashboard-client/dist/assets/{BarChart-BbkxxSkM.js → BarChart-Cf8DTaXS.js} +2 -2
  5. package/extensions/dashboard-client/dist/assets/{BarChart-BbkxxSkM.js.map → BarChart-Cf8DTaXS.js.map} +1 -1
  6. package/extensions/dashboard-client/dist/assets/{CacheTab-CiHS6tod.js → CacheTab-Ce0MES6p.js} +2 -2
  7. package/extensions/dashboard-client/dist/assets/{CacheTab-CiHS6tod.js.map → CacheTab-Ce0MES6p.js.map} +1 -1
  8. package/extensions/dashboard-client/dist/assets/{EventsTab-NnD7EpRm.js → EventsTab-DbaUuA58.js} +2 -2
  9. package/extensions/dashboard-client/dist/assets/{EventsTab-NnD7EpRm.js.map → EventsTab-DbaUuA58.js.map} +1 -1
  10. package/extensions/dashboard-client/dist/assets/{HealthTab-Dlt7WTh7.js → HealthTab-BmEXkcfL.js} +2 -2
  11. package/extensions/dashboard-client/dist/assets/{HealthTab-Dlt7WTh7.js.map → HealthTab-BmEXkcfL.js.map} +1 -1
  12. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DgKBZmdD.js → MaintenanceTab-n2JQrMy7.js} +2 -2
  13. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DgKBZmdD.js.map → MaintenanceTab-n2JQrMy7.js.map} +1 -1
  14. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-SwTOzuZW.js → MemoryMapTab-Dvu7vkOm.js} +2 -2
  15. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-SwTOzuZW.js.map → MemoryMapTab-Dvu7vkOm.js.map} +1 -1
  16. package/extensions/dashboard-client/dist/assets/{MetricsTab-CWEgBTx0.js → MetricsTab-Q0g32AmP.js} +2 -2
  17. package/extensions/dashboard-client/dist/assets/{MetricsTab-CWEgBTx0.js.map → MetricsTab-Q0g32AmP.js.map} +1 -1
  18. package/extensions/dashboard-client/dist/assets/{OverviewTab-B0YDSSMH.js → OverviewTab-iKiEcOLL.js} +4 -4
  19. package/extensions/dashboard-client/dist/assets/OverviewTab-iKiEcOLL.js.map +1 -0
  20. package/extensions/dashboard-client/dist/assets/{ReposTab-CMKZ_a4B.js → ReposTab-DWpnv77y.js} +2 -2
  21. package/extensions/dashboard-client/dist/assets/{ReposTab-CMKZ_a4B.js.map → ReposTab-DWpnv77y.js.map} +1 -1
  22. package/extensions/dashboard-client/dist/assets/{SessionsTab-D2cCDKB3.js → SessionsTab-G0YxR1vG.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{SessionsTab-D2cCDKB3.js.map → SessionsTab-G0YxR1vG.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{SetupTab-HUAG7xDf.js → SetupTab-C-y6H-F-.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{SetupTab-HUAG7xDf.js.map → SetupTab-C-y6H-F-.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-NFCsyJhB.js → TimeSavedCard-1_LCFiJp.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-NFCsyJhB.js.map → TimeSavedCard-1_LCFiJp.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{TurnsTab-BY7_AZaG.js → TurnsTab-pqOkjE4L.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{TurnsTab-BY7_AZaG.js.map → TurnsTab-pqOkjE4L.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{WikiTab-MbmjqKVQ.js → WikiTab-99sKE4nB.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{WikiTab-MbmjqKVQ.js.map → WikiTab-99sKE4nB.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{button-CoVmU9Vr.js → button-YcV2VQEP.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{button-CoVmU9Vr.js.map → button-YcV2VQEP.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{card-Cp9Hpdoo.js → card-Bwxzo50p.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{card-Cp9Hpdoo.js.map → card-Bwxzo50p.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CMM8OUO5.js → generateCategoricalChart-C6hlfMYG.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CMM8OUO5.js.map → generateCategoricalChart-C6hlfMYG.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{index-CRHmWnRi.js → index-DRa2d4TF.js} +3 -3
  39. package/extensions/dashboard-client/dist/assets/{index-CRHmWnRi.js.map → index-DRa2d4TF.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{switch-jrYrJJYy.js → switch-rU-lor0v.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{switch-jrYrJJYy.js.map → switch-rU-lor0v.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{toggle-DT1AN5wS.js → toggle-h-9B4w9X.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{toggle-DT1AN5wS.js.map → toggle-h-9B4w9X.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{useSSE-rJH_Rx6K.js → useSSE-BxJORWx8.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{useSSE-rJH_Rx6K.js.map → useSSE-BxJORWx8.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/index.html +1 -1
  47. package/extensions/dashboard-client/src/components/SessionContextGauges.tsx +16 -9
  48. package/extensions/dashboard-client/src/tabs/OverviewTab.tsx +10 -13
  49. package/extensions/dashboard-server/resolve-snapshot.ts +39 -29
  50. package/package.json +1 -1
  51. package/extensions/dashboard-client/dist/assets/OverviewTab-B0YDSSMH.js.map +0 -1
@@ -2,21 +2,23 @@
2
2
  * dashboard-server/resolve-snapshot.ts — dynamic per-repo snapshot resolver.
3
3
  *
4
4
  * The dashboard server is launched with a single static stateDir, but the
5
- * active pi session may be running in a different repo. This module queries
6
- * the repo registry to find the most recently active repo's dashboard.json,
7
- * so the Overview always shows live data from the repo pi is actually running
8
- * in.
5
+ * active pi session may be running in a different repo. This module resolves
6
+ * which repo's dashboard.json to serve as the "this session" snapshot.
9
7
  *
10
- * The launch stateDir is a candidate like any other (NOT excluded): when
11
- * `/dashboard` was run in the repo you are still coding in, the launch dir
12
- * IS the most-recently-active repo and must win. Excluding it would serve a
13
- * stale other-repo snapshot, surfacing a phantom 0% "this session" gauge
14
- * plus a duplicate live-session gauge.
15
- *
16
- * Resolution order:
17
- * 1. Most recently seen repo (by last_seen in repo_registry, launch dir
18
- * included) whose dashboard.json exists and has a non-null updatedAt
19
- * 2. The static launch stateDir's dashboard.json (original behavior)
8
+ * Resolution order (the launch dir is the OWNer of this dashboard):
9
+ * 1. The launch stateDir's OWN dashboard.json the pi process that launched
10
+ * this dashboard server is the session you are coding in, so its snapshot
11
+ * is "this session" by definition. This must win over any other repo
12
+ * regardless of last_seen freshness; otherwise a more-recently-active
13
+ * OTHER repo steals the "this session" slot and your actual session gets
14
+ * demoted to an "other" gauge, producing the exact duplicate-gauge bug
15
+ * (this session + pi-<launchrepo> both showing the same active session
16
+ * split across two boxes).
17
+ * 2. Most recently seen OTHER repo (by last_seen in repo_registry) whose
18
+ * dashboard.json exists and has a non-null updatedAt — fallback for when
19
+ * the launch dir has no live snapshot yet (e.g. dashboard launched before
20
+ * any compaction wrote dashboard.json).
21
+ * 3. The static launch stateDir's dashboard.json (original behavior).
20
22
  */
21
23
 
22
24
  import { existsSync } from "node:fs";
@@ -40,17 +42,12 @@ interface RepoRegistryRow {
40
42
  }
41
43
 
42
44
  /**
43
- * Find the most recently active repo's stateDir by scanning the repo registry
44
- * for the repo with the highest last_seen whose dashboard.json exists and has
45
- * a non-null updatedAt. Returns null if no suitable repo is found.
46
- *
47
- * The launch stateDir is NOT excluded: if it is itself the most-recently-active
48
- * repo (the common case — `/dashboard` was run in the repo you are still
49
- * coding in), its live dashboard.json must be served. Excluding it would cause
50
- * a stale *other*-repo snapshot to win, producing a phantom 0% "this session"
51
- * gauge + a duplicate live-session gauge.
45
+ * Find the most recently active OTHER repo's stateDir (excluding the launch
46
+ * dir, which is handled by the caller) by scanning the repo registry for the
47
+ * repo with the highest last_seen whose dashboard.json exists and has a
48
+ * non-null updatedAt. Returns null if no suitable repo is found.
52
49
  */
53
- function mostRecentRepoStateDir(_staticStateDir: string): string | null {
50
+ function mostRecentOtherRepoStateDir(launchStateDir: string): string | null {
54
51
  const indexPath = join(getIndexDir(), "index.sqlite");
55
52
  if (!existsSync(indexPath)) return null;
56
53
  let db;
@@ -58,13 +55,14 @@ function mostRecentRepoStateDir(_staticStateDir: string): string | null {
58
55
  const { DatabaseSync } =
59
56
  require("node:sqlite") as typeof import("node:sqlite");
60
57
  db = new DatabaseSync(indexPath, { readOnly: true });
61
- const rows = db
58
+ const rows = db
62
59
  .prepare(
63
60
  `SELECT state_dir, last_seen FROM repo_registry
64
61
  WHERE state_dir IS NOT NULL AND last_seen IS NOT NULL
62
+ AND state_dir != @launch
65
63
  ORDER BY last_seen DESC`,
66
64
  )
67
- .all() as unknown as RepoRegistryRow[];
65
+ .all({ launch: launchStateDir }) as unknown as RepoRegistryRow[];
68
66
  for (const r of rows) {
69
67
  const dashPath = join(r.state_dir, "dashboard.json");
70
68
  if (!existsSync(dashPath)) continue;
@@ -93,8 +91,20 @@ export function resolveSnapshot(
93
91
  staticSnapshotPath: string,
94
92
  staticStateDir: string,
95
93
  ): ResolvedSnapshot {
96
- // Try the most recently active repo first.
97
- const activeDir = mostRecentRepoStateDir(staticStateDir);
94
+ // 1. The launch dir's OWN snapshot is "this session" — the pi process that
95
+ // launched this dashboard is the session you are coding in. It wins over
96
+ // any other repo regardless of last_seen, so a more-recently-active OTHER
97
+ // repo can't steal the "this session" slot and demote your actual session
98
+ // to a duplicate "other" gauge.
99
+ if (existsSync(staticSnapshotPath)) {
100
+ const launchSnap = readSnapshot(staticSnapshotPath);
101
+ if (launchSnap.updatedAt) {
102
+ return { snapshot: launchSnap, stateDir: staticStateDir };
103
+ }
104
+ }
105
+ // 2. Fall back to the most recently active OTHER repo (launch dir had no
106
+ // live snapshot yet).
107
+ const activeDir = mostRecentOtherRepoStateDir(staticStateDir);
98
108
  if (activeDir) {
99
109
  const activePath = join(activeDir, "dashboard.json");
100
110
  const snap = readSnapshot(activePath);
@@ -102,7 +112,7 @@ export function resolveSnapshot(
102
112
  return { snapshot: snap, stateDir: activeDir };
103
113
  }
104
114
  }
105
- // Fall back to the static launch path.
115
+ // 3. Last resort: the static launch path (even if stale).
106
116
  return {
107
117
  snapshot: readSnapshot(staticSnapshotPath),
108
118
  stateDir: staticStateDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",