From 2772e0723cfc7898443320515e165a625de1db46 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Mon, 22 Jun 2026 01:31:29 +0900 Subject: feat(compaction): conversation compacting + auto-compact threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consume the compaction handoff (wire@0.11.0, transport-contract@0.15.0). Re-pinned file: deps + re-mirrored .dispatch/*.reference.md. - New 'Compaction' sidebar view (CompactionView.svelte): - 'Compact now' button → POST /conversations/:id/compact (loading indicator + result: 'N messages summarized, M kept') - Auto-compact threshold number input → GET/PUT /conversations/:id/compact-threshold (0 = disabled, default 350000) - Re-mounts per conversation via {#key} - App store: compactNow() + compactThreshold reactive state + setCompactThreshold(), seeded on focus change (like reasoning-effort + cwd) - conversation.compacted WS handler: reloads the SAME conversation's history (ID unchanged — old history forked to an archive, not a tab switch) - WS adapter parses newConversationId field on ConversationCompactedMessage - conformance guards + tests cover the new type 686 tests green. --- src/features/chat/ui/CompactionView.svelte | 153 +++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/features/chat/ui/CompactionView.svelte (limited to 'src/features/chat/ui/CompactionView.svelte') diff --git a/src/features/chat/ui/CompactionView.svelte b/src/features/chat/ui/CompactionView.svelte new file mode 100644 index 0000000..ce2a0a0 --- /dev/null +++ b/src/features/chat/ui/CompactionView.svelte @@ -0,0 +1,153 @@ + + +
+ +
+ Manual compaction + + {#if !canCompact} +

Open or start a conversation to compact its history.

+ {:else if compactError} +

{compactError}

+ {:else if compactResult} +

+ Compacted — {compactResult.summarized} messages summarized, {compactResult.kept} kept. +

+ {:else} +

+ Summarizes old messages into a system summary + retains the most recent messages. +

+ {/if} +
+ + +
+ Auto-compact threshold +
+ + tokens + {#if savingThreshold} + + {/if} +
+

+ Current: {thresholdLabel} +
+ 0 disables auto-compact. Default is {DEFAULT_THRESHOLD.toLocaleString("en-US")}. +

+ {#if thresholdError} +

{thresholdError}

+ {:else if thresholdSaved} +

Saved.

+ {/if} +
+
-- cgit v1.2.3