Commit Graph

4 Commits

Author SHA1 Message Date
Mario Hernandez 262da50f98 fix(context-timeline): detect Opus 1M context window dynamically (#548)
CONTEXT_LIMIT was hardcoded at 200_000 tokens. Users on Claude Opus 4.7
with the 1M context window (model: "opus[1m]") saw the dashboard report
80–90% usage when actual usage was 16–18%, producing constant false
alarms and making the meter unusable on long sessions.

Replace the constant with _detect_context_limit(cwd) which resolves the
limit in this order:

1. CONTEXT_TIMELINE_LIMIT env var (explicit override).
2. "[1m]" / "[1000k]" / "[200k]" suffix in the model field of
   <cwd>/.claude/settings.json or ~/.claude/settings.json.
3. 200_000 fallback (current behaviour).

The limit is resolved once per _Builder instance, not per update tick,
so there is no per-event filesystem cost.

No new dependencies (still stdlib only). Default behaviour is unchanged
for users without [1m] in settings.

Verified live on a real Opus 1M session of ~178K tokens: meter went
from 89% (red, false alarm) to 17.9% (cyan, correct).
2026-04-27 20:10:27 -04:00
Fernando Basilis e11ff2e105 fix(context-timeline): cross-platform path encoding for transcript lookup (#550)
The `_encode_cwd` function only replaced `/` with `-`, which fails on
Windows where paths use `\` and include drive letters like `D:`.

Use regex to replace any non-alphanumeric character with `-`.
This handles all edge cases across platforms in a single expression.

Before: D:\Claude\mcx -> lookup failed
After:  D:\Claude\mcx -> D--Claude-mcx (matches Claude Code encoding)
2026-04-27 20:09:13 -04:00
Dani fc2155655c fix(context-timeline): reload sessions from disk on cache miss when daemon predates session 2026-04-25 23:24:30 -04:00
Dani 99f423049d feat(hook): add monitoring/context-timeline real-time session visualizer
Persistent local HTTP daemon (port 7878, 1h watchdog) that reads Claude Code
JSONL transcripts and renders a git-graph timeline in the browser — one column
per agent (main + subagents), tool nodes color-coded by type, context-window
sidebar with cache/input/output breakdown. Pure stdlib Python, zero pip deps.
2026-04-25 23:08:28 -04:00