Skip to content

feat(hoosage): cache session indexes across windows - #52

Merged
wakemeup0 merged 2 commits into
mainfrom
feat/index-cache
Sep 29, 2026
Merged

wakemeup0 merged 2 commits into
mainfrom
feat/index-cache

Conversation

@wakemeup0

Copy link
Copy Markdown
Contributor

Every new VS Code window re-read all saved Copilot usage, which kept the dashboard on "Indexing saved usage…" for seconds on each start:

  • Copilot CLI session files (Windows plus WSL over 9P, in 4 MB batches per poll)
  • Chat transcripts (a full re-parse)

This PR adds a local index cache under globalStorageUri/cache/.

CLI / JetBrains / WSL session-state

  • Stores the byte offset, inode, reader state and usage read so far for each file.
  • A later window reads only the bytes appended since then.
  • Line splitting is now byte-based, so the resume offset is exact, including for partial UTF-8 lines.
  • Sessions whose directory disappeared are dropped.

Chat transcripts

  • Stores size, mtime, projectId and allowlisted usage for each file.
  • Unchanged transcripts are not parsed again.

Startup

  • Previously imported chat-history.json usage is shown immediately, before the rescan.

Safety

  • The cache is keyed by the extension version, so it is rebuilt once per update.
  • Each file entry is validated. A missing, corrupt, truncated or replaced source falls back to a full read.
  • Writes are atomic (tmp + rename) and best-effort.
  • Stopped WSL distros are still never touched.

Measured on a real profile (cold → warm)

Totals were identical with and without the cache.

Source Cold Warm
Windows CLI (53 files, 77 MB) 529 ms 17 ms
WSL CLI (28 files, 148 MB) 1927 ms (10 polls) 305 ms
Chat transcripts 1690 ms 95 ms

Tests

  • npm run check: 80/80 tests, typecheck, build and calendar UI all pass.
  • New test/scan-cache.test.ts covers:
    • resuming from the cache;
    • cached vs full reads matching, including a split UTF-8 line;
    • a key mismatch;
    • truncation;
    • removed sessions and a corrupt cache;
    • transcript cache hits and misses.
  • npm run test:extension fails on Windows on main as well: pathToFileURL gives file:///C:/…, while VS Code uses file:///c%3A/….
    • With that locally patched, all activation, saved-usage, CLI-discovery and Chat-import assertions pass.
    • The remaining failure is the Copilot enable/status check on the current Insiders build and is unrelated to this change.

Every new window re-read all Copilot CLI session files (including WSL
over 9P) and re-parsed every Chat transcript, so "Indexing saved usage"
showed for seconds on each start.

Keep a local index cache under globalStorageUri/cache/:
- CLI/JetBrains/WSL session-state: per-file byte offset, inode, reader
  state and the usage read so far; later starts only read appended bytes.
  Line splitting is now byte-based so the resume offset is exact.
- Chat transcripts: size, mtime and allowlisted usage per file; unchanged
  transcripts are not parsed again.
- Previously imported Chat history is shown before the rescan.

The cache is keyed by extension version, validated per file and falls
back to a full read when missing, corrupt, truncated or replaced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread test/scan-cache.test.ts Fixed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wakemeup0
wakemeup0 merged commit bf67251 into main Sep 29, 2026
7 checks passed
@wakemeup0
wakemeup0 deleted the feat/index-cache branch September 29, 2026 11:09
wakemeup0 added a commit that referenced this pull request Sep 29, 2026
## 0.14.0 (2026-09-29)

### Features

- **hoosage:** cache session indexes across windows (#52) (bf67251)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants