osborn 0.9.259 → 0.9.260

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/dist/config.js +52 -1
  2. package/package.json +1 -1
package/dist/config.js CHANGED
@@ -674,6 +674,29 @@ const SESSION_LIST_TTL_MS = 300_000;
674
674
  export function invalidateSessionListCache() {
675
675
  _sessionListCache = null;
676
676
  }
677
+ const SESSION_MANIFEST_VERSION = 1;
678
+ function sessionManifestPath() {
679
+ return join(homedir(), '.claude', 'session-manifest.json');
680
+ }
681
+ function loadSessionManifest() {
682
+ try {
683
+ const raw = readFileSync(sessionManifestPath(), 'utf-8');
684
+ const m = JSON.parse(raw);
685
+ if (m && m.v === SESSION_MANIFEST_VERSION && m.entries && typeof m.entries === 'object')
686
+ return m;
687
+ }
688
+ catch { /* missing / corrupt → start fresh */ }
689
+ return { v: SESSION_MANIFEST_VERSION, entries: {} };
690
+ }
691
+ function saveSessionManifest(m) {
692
+ try {
693
+ const p = sessionManifestPath();
694
+ const tmp = `${p}.tmp`;
695
+ writeFileSync(tmp, JSON.stringify(m));
696
+ renameSync(tmp, p); // atomic swap — a reader never sees a half-written file
697
+ }
698
+ catch { /* best-effort — a failed manifest write just means the next cold boot re-reads */ }
699
+ }
677
700
  /**
678
701
  * Scan ALL Claude Code projects for sessions.
679
702
  * Returns lightweight metadata for every main session JSONL across all projects.
@@ -736,17 +759,45 @@ export async function listAllClaudeSessions(limit = 1000, includeSubagents = fal
736
759
  // 3. Sort by mtime descending, take top N for detailed reads
737
760
  candidates.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
738
761
  const topCandidates = candidates.slice(0, limit);
739
- // 4. Read metadata in parallel (sequential was ~10ms × N files = seconds at scale)
762
+ // 4. Read metadata in parallel (sequential was ~10ms × N files = seconds at scale).
763
+ // COLD-BOOT FIX: consult the persisted manifest first — a session whose
764
+ // file mtime+size is unchanged since last build is served from the manifest
765
+ // with NO file read. Only changed/new sessions pay the head/tail read. This
766
+ // is what makes the first dashboard build after a machine restart fast.
740
767
  const sessions = [];
768
+ const manifest = loadSessionManifest();
769
+ let manifestDirty = false;
741
770
  const results = await Promise.all(topCandidates.map(async (c) => {
771
+ const hit = manifest.entries[c.filePath];
772
+ if (hit && hit.mtimeMs === c.mtime.getTime() && hit.size === c.size) {
773
+ // Unchanged since last build — reuse cached preview + cwd, skip the read.
774
+ return { c, preview: { lastMessage: hit.lastMessage, messageCount: hit.messageCount }, cwd: hit.cwd };
775
+ }
742
776
  try {
743
777
  const [preview, cwd] = await Promise.all([getSessionPreview(c.filePath, c.size), extractCwd(c.filePath)]);
778
+ manifest.entries[c.filePath] = {
779
+ mtimeMs: c.mtime.getTime(), size: c.size,
780
+ lastMessage: preview.lastMessage, messageCount: preview.messageCount, cwd,
781
+ };
782
+ manifestDirty = true;
744
783
  return { c, preview, cwd };
745
784
  }
746
785
  catch {
747
786
  return null;
748
787
  }
749
788
  }));
789
+ // Prune manifest entries for files that no longer exist on disk (deleted
790
+ // sessions), keyed off the full candidate set so the manifest can't grow
791
+ // unbounded or resurrect stale rows.
792
+ const liveKeys = new Set(candidates.map(c => c.filePath));
793
+ for (const key of Object.keys(manifest.entries)) {
794
+ if (!liveKeys.has(key)) {
795
+ delete manifest.entries[key];
796
+ manifestDirty = true;
797
+ }
798
+ }
799
+ if (manifestDirty)
800
+ saveSessionManifest(manifest);
750
801
  for (const r of results) {
751
802
  if (!r)
752
803
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.259",
3
+ "version": "0.9.260",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {