generated from nhcarrigan/template
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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user