v1.0.109 — Statusline counter regression fix + ctx_stats bars + #419
This release fixes a regression that landed in v1.0.108 (and was actually
present since v1.0.107 — only became visible to fresh /ctx-upgrade users
after the marketplace sync fix in #418 actually started delivering updates):
the session-level counter shown in the statusline was resetting to zero
after every MCP server restart.
If you upgraded to v1.0.108 and then noticed your statusline reading
context-mode 2min · 0 calls · $0.00 this session mid-session — that's
the bug fixed here.
Upgrade
npm update -g context-modeThen run /ctx-upgrade inside Claude Code to refresh the marketplace
clone and hooks.
Critical fixes
fix(stats) — session counters survive /ctx-upgrade again (505fb01)
What broke: After a mid-session /ctx-upgrade (or any MCP server
restart triggered by --continue, compact, or hook-driven reload), the
statusline session counter dropped to 0 calls · $0.00 this session,
even though the session had been actively used. The promise of "session
stats preserved across compact, restart & upgrade" was broken on the
SESSION dimension specifically.
Root cause: The May 2 concurrency refactor (commit b392c2f) dropped
persistToolCallCounter as collateral damage. The matching
restoreSessionStats read-on-startup path was never written in the first
place. The tool_calls table and helper methods on SessionDB
(incrementToolCall, getToolCallTotals, getToolCallByTool) all stayed
intact in src/session/db.ts — they just had no consumer wiring them up.
Fix:
- New module
src/session/persist-tool-calls.tsexporting:persistToolCallCounter()— write-back after every MCP responserestoreSessionStats()— read-on-startup hydrationRestoredSessionStatsinterface
server.tstrackResponse()nowsetImmediate-schedules a write-back
after every MCP tool response (zero hot-path overhead).server.ts main()hydratessessionStats.calls,
sessionStats.bytesReturned, andsessionStats.sessionStartfrom
SessionDBbefore the heartbeatsetIntervalregisters — counters
now survive process restart,--continue, and/ctx-upgrade.- Both helpers are pure, never throw, and no-op cleanly when the DB is
missing or the row is absent. - New centralized
getSessionDbPath()helper atsrc/server.tsso
write-back, restore, and any futureSessionDBcaller hash to the same
file under worktree isolation (no more cross-process drift).
Test coverage: 9 new tests in
tests/session/server-tool-call-wiring.test.ts — 4 write-back paths,
5 restore-on-startup paths, plus edge cases for multi-session
"latest wins" selection and sessionStart hydration.
fix(stats) — ctx_stats cosmetic gaps (same commit 505fb01)
Two display issues in ctx_stats output, both shipped in v1.0.108 and
both landed quietly:
- Auto-memory section — rows now render proportional
█bars next to
counts, matching every other section in the report. Previously the
Auto-memory rows were the only bar-less rows in the entire output. - Persistent memory section — the bar block is no longer silently
empty when the project's localSessionDBhappens to be fresh. The
section header has always promised lifetime data, so the bars now use
lifetime-widecategoryCountsaggregated across all per-project
SessionDBfiles (matching the section's lifetime framing) instead of
the just-this-project counts that frequently resolved to zero.
Schema improvements
feat(session) — #419 by @ShmidtS (92997e4)
Big DX win on the session-event API surface. PR
#419 by Svyatoslav
Shmidt (@ShmidtS):
insertEventno longer requiresdata_hash— the hash is now
computed internally fromevent.datavia SHA256. All call sites and
test fixtures get simpler; integrators no longer have to pre-compute
hashes (or get them subtly wrong).AttributionSourceunion widened to includeenvandtestso
test fixtures and env-driven attribution paths are valid without
as anycasts.- Removed deprecated
forceExitfrom vitest config — Vitest v4
dropped the option and emits a config warning when it's present.
Files touched:
src/session/db.tssrc/session/project-attribution.tsvitest.config.tscli.bundle.mjs+server.bundle.mjs(CI-rebuilt)
fix(tests) — Windows CI follow-up to #419 (e14f92b)
#419 surfaced two pre-existing Windows-only test failures that
Linux/macOS had been tolerating:
tests/hooks/run-hook.test.ts:53,64,96,125— subprocess scripts
were doingimport { runHook } from "C:\\...\\run-hook.mjs", which
Windows ESM rejects withERR_UNSUPPORTED_ESM_URL_SCHEME(Linux/macOS
silently tolerate the bare drive path). Fix: convertRUN_HOOK_PATH
and the staged fake-hook path tofile://URLs via
pathToFileURL().hrefbefore interpolating into the spawned
--input-type=modulescript.tests/core/cli.test.ts:180— the plugin-manifest test was
asserting the working-tree.claude-plugin/plugin.jsonstill
contained${CLAUDE_PLUGIN_ROOT}, but on Windows our
scripts/postinstall.mjsintentionally invokes
hooks/normalize-hooks.mjsto rewrite that placeholder into a
forward-slash absolute path (#378 — MSYS path mangling). The on-disk
file is therefore EXPECTED to be normalized on Windows after
npm ci. The marketplace invariant is about what we ship, not
about what install scripts mutate locally. Fix: read the file via
git show HEAD:.claude-plugin/plugin.jsonso the assertion validates
committed state, cross-platform.
No production source changed; only test scaffolding.
Action required for v1.0.108 victims
If you upgraded to v1.0.108 and saw your statusline session counter reset
to zero after /ctx-upgrade or after a --continue resume — that's
exactly the regression fixed in this release. After upgrading to v1.0.109
the counter restores from SessionDB on every MCP server startup and is
written back after every tool response.
Lifetime totals (dollars_saved_lifetime, persistent-memory category
counts, etc.) were never affected — only the in-process session
counter. So nothing was lost; the statusline just stopped reading from
the persisted state.
Credits
- @ShmidtS (Svyatoslav Shmidt) — #419:
cleanerinsertEventsignature, widenedAttributionSourceunion,
vitest v4 cleanup. Thanks for the focused PR with a clear summary.
Compatibility
- 14 adapters supported, no adapter behavior change
- 3 OS supported (Linux / macOS / Windows), no breaking changes
- MCP tool surface unchanged — same tool names, same schemas
- SessionDB schema unchanged —
tool_callstable was already shipping in
v1.0.108; this release just wires it back into the runtime