github mksglu/context-mode v1.0.109

latest releases: v1.0.111, v1.0.110
4 hours ago

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-mode

Then 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.ts exporting:
    • persistToolCallCounter() — write-back after every MCP response
    • restoreSessionStats() — read-on-startup hydration
    • RestoredSessionStats interface
  • server.ts trackResponse() now setImmediate-schedules a write-back
    after every MCP tool response (zero hot-path overhead).
  • server.ts main() hydrates sessionStats.calls,
    sessionStats.bytesReturned, and sessionStats.sessionStart from
    SessionDB before the heartbeat setInterval registers — 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 at src/server.ts so
    write-back, restore, and any future SessionDB caller 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 local SessionDB happens to be fresh. The
    section header has always promised lifetime data, so the bars now use
    lifetime-wide categoryCounts aggregated across all per-project
    SessionDB files (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):

  • insertEvent no longer requires data_hash — the hash is now
    computed internally from event.data via SHA256. All call sites and
    test fixtures get simpler; integrators no longer have to pre-compute
    hashes (or get them subtly wrong).
  • AttributionSource union widened to include env and test so
    test fixtures and env-driven attribution paths are valid without
    as any casts.
  • Removed deprecated forceExit from vitest config — Vitest v4
    dropped the option and emits a config warning when it's present.

Files touched:

  • src/session/db.ts
  • src/session/project-attribution.ts
  • vitest.config.ts
  • cli.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:

  1. tests/hooks/run-hook.test.ts:53,64,96,125 — subprocess scripts
    were doing import { runHook } from "C:\\...\\run-hook.mjs", which
    Windows ESM rejects with ERR_UNSUPPORTED_ESM_URL_SCHEME (Linux/macOS
    silently tolerate the bare drive path). Fix: convert RUN_HOOK_PATH
    and the staged fake-hook path to file:// URLs via
    pathToFileURL().href before interpolating into the spawned
    --input-type=module script.
  2. tests/core/cli.test.ts:180 — the plugin-manifest test was
    asserting the working-tree .claude-plugin/plugin.json still
    contained ${CLAUDE_PLUGIN_ROOT}, but on Windows our
    scripts/postinstall.mjs intentionally invokes
    hooks/normalize-hooks.mjs to 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.json so 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:
    cleaner insertEvent signature, widened AttributionSource union,
    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_calls table was already shipping in
    v1.0.108; this release just wires it back into the runtime

Don't miss a new context-mode release

NewReleases is sending notifications on new releases.