Impact\n- Users think context is still full after compaction; sessions get reset/compacted unnecessarily.\n- False alarms in long-running sessions.\n\nRoot cause\n- UI and backend use different context measurement sources.\n- UI continues showing stale inputTokens after compaction.\n\nPlanned fix\n- Align UI and backend to a single source of truth for context usage.\n- After compaction, clear/zero stale inputTokens so UI reflects real-time active usage.\n\nAcceptance criteria\n- UI displays context usage from the backend’s canonical metric (e.g., activeContextTokens + capacity).\n- After a compaction event, UI no longer shows pre-compaction inputTokens; no false "context full" warning persists.\n- Backend exposes a single canonical context usage metric and resets relevant counters on compaction.\n- Add an automated test that: (1) fills context to trigger compaction, (2) verifies post-compaction UI reflects cleared usage, (3) confirms no false warning.\n\nRepro steps\n1) Run a long session to trigger compaction.\n2) Observe UI continues to display near-full usage based on stale inputTokens.\n3) Compare with backend session status which reflects compacted state.\n\nNotes\n- Prefer publishing context:compacted events with a monotonically increasing sequence/timestamp so UI can deterministically reset/refresh.\n- If helpful, I can implement and open a PR once this issue is confirmed.
Impact\n- Users think context is still full after compaction; sessions get reset/compacted unnecessarily.\n- False alarms in long-running sessions.\n\nRoot cause\n- UI and backend use different context measurement sources.\n- UI continues showing stale inputTokens after compaction.\n\nPlanned fix\n- Align UI and backend to a single source of truth for context usage.\n- After compaction, clear/zero stale inputTokens so UI reflects real-time active usage.\n\nAcceptance criteria\n- UI displays context usage from the backend’s canonical metric (e.g., activeContextTokens + capacity).\n- After a compaction event, UI no longer shows pre-compaction inputTokens; no false "context full" warning persists.\n- Backend exposes a single canonical context usage metric and resets relevant counters on compaction.\n- Add an automated test that: (1) fills context to trigger compaction, (2) verifies post-compaction UI reflects cleared usage, (3) confirms no false warning.\n\nRepro steps\n1) Run a long session to trigger compaction.\n2) Observe UI continues to display near-full usage based on stale inputTokens.\n3) Compare with backend session status which reflects compacted state.\n\nNotes\n- Prefer publishing context:compacted events with a monotonically increasing sequence/timestamp so UI can deterministically reset/refresh.\n- If helpful, I can implement and open a PR once this issue is confirmed.