From 108a1b16b2936dd3918510f16af91f95ad600c66 Mon Sep 17 00:00:00 2001 From: Hikari Date: Tue, 24 Feb 2026 17:18:44 -0800 Subject: [PATCH] feat: detect prompt-too-long errors and offer compact action Closes #158 - Detect "Prompt is too long" in assistant text blocks in wsl_bridge - Emit error line type instead of assistant for better visibility - Emit compact-prompt event after the error line - Render a compact-prompt line as an action button in the terminal - Clicking the button sends /compact to the active session - Add getLineClass/getLinePrefix tests for compact-prompt type --- src-tauri/src/wsl_bridge.rs | 24 ++++++++++++++++-- src/lib/components/Terminal.svelte | 38 ++++++++++++++++++++++++++++- src/lib/components/Terminal.test.ts | 10 ++++++++ src/lib/tauri.ts | 20 +++++++++++++-- src/lib/types/messages.ts | 10 +++++++- 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/wsl_bridge.rs b/src-tauri/src/wsl_bridge.rs index e8e4725..120de9f 100644 --- a/src-tauri/src/wsl_bridge.rs +++ b/src-tauri/src/wsl_bridge.rs @@ -1082,17 +1082,37 @@ fn process_json_line( stats.write().increment_code_blocks(); } + let is_prompt_too_long = text.starts_with("Prompt is too long"); + let _ = app.emit( "claude:output", OutputEvent { - line_type: "assistant".to_string(), + line_type: if is_prompt_too_long { + "error".to_string() + } else { + "assistant".to_string() + }, content: text.clone(), tool_name: None, conversation_id: conversation_id.clone(), - cost: message_cost.clone(), // Include cost with assistant text + cost: message_cost.clone(), parent_tool_use_id: parent_tool_use_id.clone(), }, ); + + if is_prompt_too_long { + let _ = app.emit( + "claude:output", + OutputEvent { + line_type: "compact-prompt".to_string(), + content: String::new(), + tool_name: None, + conversation_id: conversation_id.clone(), + cost: None, + parent_tool_use_id: None, + }, + ); + } } ContentBlock::Thinking { thinking } => { state = CharacterState::Thinking; diff --git a/src/lib/components/Terminal.svelte b/src/lib/components/Terminal.svelte index ebd682b..9933d3c 100644 --- a/src/lib/components/Terminal.svelte +++ b/src/lib/components/Terminal.svelte @@ -1,6 +1,7 @@