4 Commits
Author SHA1 Message Date
AlexKucera dc75ef8a7b feat(status): show session compaction count
Add a compactions row to the /smart-compact overlay counting the
session's persisted compaction entries via ctx.sessionManager, so the
number stays correct across resume and restart. An in-memory
session_compact counter remains as the fallback where sessionManager
is unavailable.
2026-11-16 17:20:24 +01:00
AlexKucera ea51a574c1 feat(status): render state as centered overlay
Replace the /smart-compact notify() text with a ctx.ui.custom overlay
panel (the /dcp context look): usage bar, threshold rows with crossed
indicators, cycle flags, esc/enter/q/ctrl+c dismissal (keybindings-aware
with a raw kitty/legacy fallback set), and notify() fallback for
print/RPC mode.

Hardened by a fresh-context reviewer fanout (ponytail/security/general):
kitty explicit-modifier close forms added, render() now honors the
requested width exactly with a degenerate-narrow fallback, label width
simplified. Harness gains a ctx.ui.custom mock; 22 tests green.
2026-11-16 12:29:47 +01:00
AlexKucera a6cfb51626 fix(compact): move force tier to agent_settled
Manual compaction (ctx.compact) aborts the active run and never
resumes the interrupted turn (Pi 1.5.2 agent-session.js:2321-2327),
so triggering it from turn_end destroyed in-progress agent work.
The force tier now fires at agent_settled, where ctx.isIdle() is
guaranteed and compaction aborts nothing; Pi's built-in mid-run
threshold check stays the actor and preserves runs.

Also: the settled handler awaits compaction completion so prompts
deferred from settled handlers cannot race an in-flight compaction;
per-field config validation falls back to defaults (null token
values previously zeroed thresholds via Math.min, strings silently
NaN-disabled them); the cached token count is cleared on
session_compact so stale pre-compaction counts cannot re-trigger.

Adds harness.ts: 15-test mock harness (node --test, type
stripping, zero deps) covering both regressions, locks, cooldown,
validation, and cycle resets. README corrected accordingly.
2026-11-15 19:27:40 +01:00
AlexKucera 2c6d98995a feat: two-tier smart compaction for Pi
Warn tier injects a one-shot context notice to the agent; force tier
triggers ctx.compact() at a clean turn boundary before Pi's built-in
threshold compaction. Never registers session_before_compact, so
pi-lcm stays in charge of DAG summaries; mirrors pi-dcp's null-token
caching and session_compact cycle reset.
2026-11-15 18:51:02 +01:00