Skip to content

feat(ui): render compacted history as a collapsible card on all three surfaces#1649

Merged
esengine merged 1 commit into
mainfrom
feat/compaction-card-three-surfaces
May 24, 2026
Merged

feat(ui): render compacted history as a collapsible card on all three surfaces#1649
esengine merged 1 commit into
mainfrom
feat/compaction-card-three-surfaces

Conversation

@esengine

Copy link
Copy Markdown
Owner

Summary

After auto-compaction, the synthesized recap was being stored as a plain assistant message with a HISTORY_FOLD_MARKER prefix. None of the three surfaces special-cased it:

  • TUI: hydrated as a regular streaming card on session resume — recap looked like a real reply.
  • Desktop / Dashboard: rendered inline through AssistantText — users couldn't tell compaction had happened, and the recap blended in with normal model output.

This PR closes that gap on all three surfaces.

What changed

  • Single-source the marker + helpers in @reasonix/core-utils/compaction (COMPACTION_SUMMARY_MARKER, isCompactionSummary, stripCompactionMarker). Re-export the constant from src/context-manager.ts so existing HISTORY_FOLD_MARKER imports keep resolving.
  • Add a CompactionCard to each surface:
    • TUI — new kind: "compaction" in state/cards.ts, renderer in cards/CompactionCard.tsx, hydrate.ts emits a compaction card instead of a streaming card when the marker is present. Resumed sessions now show the recap distinctly (info tone, preview lines + char/line count meta).
    • Desktop / DashboardCompactionCard component in ui/cards.tsx, intercepted in the assistant-segment renderer in ui/thread.tsx. Default-collapsed, archive icon, header shows char count, body renders the recap markdown.
  • Wire vite + tsconfig aliases for the new @reasonix/core-utils/compaction sub-import path so the browser bundles don't pull in Node-only siblings (tildeify) via the barrel.

Test plan

  • npm run verify — 262 files / 3595 tests pass (was 261/3593 + 2 new)
  • New packages/core-utils/tests/compaction.test.ts — marker detection edge cases
  • New tests/hydrate-cards.test.ts case — fold summary message hydrates as a CompactionCard, not a streaming card

Follow-ups (not in this PR)

  • Surface the warning event for loop.foldedHistory / loop.turnStartFolded as a visible row in Desktop / Dashboard (currently only flows through the protocol, no ChatMessage reducer). One-line banner would close the "compaction happened invisibly" gap completely.
  • Persist the pre-compaction message tail in a sidecar file so the expanded card can offer a "view original turns" jump.

… surfaces

After auto-compaction the synthesized recap was being stored as a plain
assistant message with a HISTORY_FOLD_MARKER prefix. The TUI showed it
as a regular streaming card on resume, and Desktop / Dashboard showed
it inline as if the model had said it — users had no idea compaction
had happened and could not distinguish the recap from a real reply.

- Single-source the marker + helpers in @reasonix/core-utils/compaction
  (COMPACTION_SUMMARY_MARKER, isCompactionSummary, stripCompactionMarker)
  and re-export the constant from src/context-manager.ts so existing
  HISTORY_FOLD_MARKER imports keep resolving.
- Add a CompactionCard to all three surfaces:
  * TUI: new kind in state/cards.ts, renderer in cards/CompactionCard.tsx,
    hydrate.ts emits it instead of a streaming card when the marker is
    present (so resumed sessions show the recap distinctly).
  * Desktop / Dashboard: CompactionCard component in ui/cards.tsx,
    intercepted in the assistant-segment renderer in ui/thread.tsx.
  * Default-collapsed, distinct tone, header shows char count.
- Wire vite + tsconfig aliases for the new sub-import path to keep the
  browser bundles from pulling in Node-only siblings (tildeify) via the
  barrel.

Tests: COMPACTION_SUMMARY_MARKER detection in core-utils, hydrate emits
compaction card for the marker, full verify (262 files / 3595 tests).
@esengine esengine merged commit 106255b into main May 24, 2026
4 checks passed
@esengine esengine deleted the feat/compaction-card-three-surfaces branch May 24, 2026 04:05
esengine added a commit that referenced this pull request May 24, 2026
… chatty ones (#1650)

Layer 1 follow-up to #1649 (CompactionCard). Before this, every loop
warning fell through eventize.classifyWarning's default branch and
became an "error" event — Dashboard rendered compaction notices and
storm-stuck interrupts as alarming red error cards. Chatty warnings
(per-iter repeat-tool nudges, storm-suppressed counters) flooded the
thread.

- Add EventSeverity ("low" | "high") to LoopEvent. Tag the two known
  chatty sites in loop.ts (repeatToolCallWarning, stormSuppressed
  counter) as "low"; everything else is "high" by default — safer for
  new emit sites added later.
- Add a typed WarningEvent to the kernel + dashboard protocol.
  Eventize.classifyWarning now: drops low-severity entirely, emits a
  proper warning event (not an error) for high-severity. Existing
  policy.escalated / policy.budget classification still wins for those
  patterns.
- Dashboard SPA: add warning kind to ChatMessage, reducer case in
  applyIncoming (filters anything not "high"), render as a quiet
  inline divider (.sys-event-row) — single line, dim, ~0.7 opacity,
  flanked by hairline rules. Visually weak so several can stack
  through a long session without crowding the conversation.

Tests: low-severity warnings dropped, high-severity emit typed warning
(not error), unmarked warnings default to high.

Follow-ups not in this PR:
- Desktop bridge equivalent (Tauri IPC + Tauri-side event types).
- Settings toggle to fully hide system events for users who want a
  cleaner thread.

Co-authored-by: reasonix <reasonix@deepseek.com>
esengine pushed a commit that referenced this pull request May 24, 2026
…moved, persisted usage stats, plan dispatch gate

Headline themes:
- Desktop: bundle the CLI-hosted React dashboard, retire Tauri+Preact duplicate (#1418)
- Config: drop preset abstraction; flash/pro are direct model selections (#1657, #1630)
- Stats: persist cumulative usage to session meta + auto-restore on startup (#1667, #1680, #1643, #1628)
- Plans: editMode="plan" enforced at the ToolRegistry dispatch gate (#1681); step advance fix (#1629)
- Context: fold once at turn start, drop pre-flight + byte-ceiling (#1642, #1646); collapsible compacted card (#1649)
- Subagents: per-skill flash/pro override + Settings UI (#1632)
- Desktop polish: sidebar drag-resize (#1688), responsive collapse (#1585), copy/edit overlay + msg-history nav (#1645), Esc closes modal not turn (#1685), QQ tab isolation (#1672), DiffCard for edits (#1662), theme-aware highlighting (#1655), system events toggle (#1654/#1650), macOS TCC inheritance (#1614), dashboard.enabled (#1612)
- Dashboard polish: persistent session URL (#1586, #1589, #1599), theme-aware highlighting (#1664), IME confirm-enter guard (#1689), code-fence lang fix (#1677), vendor chunk split (#1587), markdown table h-scroll (#1562)
- TUI: Alt+S input stash/recall; static history isolated from input rerenders (#1635); legacy mouse drop (#1637, #1648); multi-edit gated in review (#1647)
- Diff: SplitDiff column border holds under CJK (#1686)
- MCP: workspace roots passed to servers (#1625); codeCommand honors mcpServers (#1603)
- Config plumbing: (baseUrl, apiKey) resolved as a tuple (#1658); stale model id self-heal (#1663)

See CHANGELOG for the full list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant