Skip to content

feat: session cache footer in Pi's status bar - #2

Open
Saolence wants to merge 2 commits into
thetrebor:mainfrom
Saolence:feat/cache-footer
Open

feat: session cache footer in Pi's status bar#2
Saolence wants to merge 2 commits into
thetrebor:mainfrom
Saolence:feat/cache-footer

Conversation

@Saolence

@Saolence Saolence commented Aug 3, 2026

Copy link
Copy Markdown

What

Adds a cache-stats footer in Pi's status bar: a one-line summary of the current session's cache usage, rendered via setStatus — the same surface pi-cache-optimizer uses.

⚡️ 560/572 · 86.80M/90.01M (96%)

Why

Reasonix already collects the exact usage numbers (cacheRead/cacheWrite/input from message_end) and exposes them in /reasonix-status, but only on demand. The footer makes the cache hit rate continuously visible so you can tell at a glance whether the prefix-stabilization pillar is doing its job.

What changed

  • Session-scoped counters: new totalRequests/hitRequests on ReasonixStats, incremented from message_end usage (and the header fallback at turn_end). Counters reset on /reload or Pi restart — no on-disk persistence, mirroring pi-cache-optimizer's session footer mode.
  • src/footer.ts: pure rendering — formatTokenCount/formatCacheFooter producing ⚡️ 560/572 · 86.80M/90.01M (96%).
  • extensions/index.ts: render the footer through the handler context's ctx.ui.setStatus at message_end/turn_end, with an idempotent render guard.
  • REASONIX_FOOTER=0 disables the footer (default on — it only renders read-mostly stats, unlike the opt-in REASONIX_SCAVENGE).
  • Status key is !reasonix so Pi's alphabetical status sort keeps the banner leftmost (pi-lens's pi-lens-lsp would otherwise sort first).
  • Non-zero w<X> (cache writes) and 🔧/🌀/⚙ (repaired / storms / compacted) counters append only when present, keeping a quiet session short.
    • Tools head canonicalized (sorted by name, stabilized schemas) before hashing AND sending — recovered +42.7pp hit ratio under tool-set churn.
    • PrefixGuard.lastChangeReason attributes head changes to system/tools (/reasonix-statusCache head:).
    • Append-only log is content-fingerprinted, so compaction that rewrites history while keeping the message count is detected.
  • /reasonix-status shows the same footer text.
  • test/footer.test.mjs: 3 unit tests for token formatting and footer rendering.
  • README: env-var row, a "Footer" section, and the architecture tree.

@Saolence
Saolence force-pushed the feat/cache-footer branch from 6102e07 to a309ddf Compare August 3, 2026 13:37
@Saolence Saolence changed the title feat: persistent cache footer in Pi's status bar feat: session cache footer in Pi's status bar Aug 3, 2026
- Status key changed to `!reasonix` so Pi's alphabetical extension-status
  sort places the banner leftmost (pi-lens uses `pi-lens-lsp`, which
  otherwise sorts before `reasonix`)
- Footer now appends non-zero `w<X>` (cache writes) and 🔧/🌀/⚙
  (repaired / storms / compacted) counters; a quiet session stays short
@Saolence
Saolence force-pushed the feat/cache-footer branch from a309ddf to 3990a4d Compare August 3, 2026 13:43
@Saolence Saolence changed the title feat: session cache footer in Pi's status bar feat: session cache footer + cache-head stability Aug 3, 2026
@Saolence
Saolence force-pushed the feat/cache-footer branch from 57238bd to f999d31 Compare August 4, 2026 00:29
@Saolence Saolence changed the title feat: session cache footer + cache-head stability feat: session cache footer in Pi's status bar Aug 4, 2026
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.

1 participant