feat: add PreCompact hook support (#267)

Parses [PreCompact Hook] events from the CLI stream and emits a claude:pre-compact Tauri event. Shows a "Compacting context..." toast and thinking state on the frontend, complementing the existing PostCompact handling.
This commit is contained in:
2026-05-06 14:18:57 -07:00
committed by Naomi Carrigan
parent 38692391e0
commit f3a2f8a491
4 changed files with 101 additions and 2 deletions
+7
View File
@@ -11,6 +11,7 @@ import type {
ElicitationEvent,
PermissionPromptEvent,
PostCompactEvent,
PreCompactEvent,
StopFailureEvent,
UserQuestionEvent,
} from "$lib/types/messages";
@@ -661,6 +662,12 @@ export async function initializeTauriListeners() {
});
unlisteners.push(stopFailureUnlisten);
const preCompactUnlisten = await listen<PreCompactEvent>("claude:pre-compact", () => {
toastStore.addInfo("Compacting context...", "🗜️");
characterState.setTemporaryState("thinking", 3000);
});
unlisteners.push(preCompactUnlisten);
const postCompactUnlisten = await listen<PostCompactEvent>("claude:post-compact", () => {
toastStore.addInfo("Context compacted", "🗜️");
characterState.setTemporaryState("success", 2000);
+5
View File
@@ -187,6 +187,11 @@ export interface PostCompactEvent {
conversation_id?: string;
}
export interface PreCompactEvent {
session_id?: string;
conversation_id?: string;
}
export type ConnectionStatus = "disconnected" | "connecting" | "connected" | "error";
export interface Attachment {