tui: centralize command drain

This commit is contained in:
Charles Cunningham
2026-01-31 20:40:52 -08:00
parent 7cd81adcca
commit 389e850ff9
2 changed files with 11 additions and 20 deletions

View File

@@ -218,6 +218,12 @@ impl BottomPane {
self.composer.take_mention_paths()
}
/// Clear pending attachments and mention paths when a command doesn't submit text.
pub(crate) fn drain_pending_submission_state(&mut self) {
let _ = self.take_recent_submission_images_with_placeholders();
let _ = self.take_mention_paths();
}
pub fn set_steer_enabled(&mut self, enabled: bool) {
self.composer.set_steer_enabled(enabled);
}

View File

@@ -2783,10 +2783,7 @@ impl ChatWidget {
cmd.command()
);
self.add_to_history(history_cell::new_error_event(message));
let _ = self
.bottom_pane
.take_recent_submission_images_with_placeholders();
let _ = self.bottom_pane.take_mention_paths();
self.bottom_pane.drain_pending_submission_state();
self.request_redraw();
return;
}
@@ -3035,10 +3032,7 @@ impl ChatWidget {
cmd.command()
);
self.add_to_history(history_cell::new_error_event(message));
let _ = self
.bottom_pane
.take_recent_submission_images_with_placeholders();
let _ = self.bottom_pane.take_mention_paths();
self.bottom_pane.drain_pending_submission_state();
self.request_redraw();
return;
}
@@ -3055,18 +3049,12 @@ impl ChatWidget {
self.request_redraw();
self.app_event_tx
.send(AppEvent::CodexOp(Op::SetThreadName { name }));
let _ = self
.bottom_pane
.take_recent_submission_images_with_placeholders();
let _ = self.bottom_pane.take_mention_paths();
self.bottom_pane.drain_pending_submission_state();
}
SlashCommand::Plan if !trimmed.is_empty() => {
self.dispatch_command(cmd);
if self.active_mode_kind() != ModeKind::Plan {
let _ = self
.bottom_pane
.take_recent_submission_images_with_placeholders();
let _ = self.bottom_pane.take_mention_paths();
self.bottom_pane.drain_pending_submission_state();
return;
}
let user_message = UserMessage {
@@ -3095,10 +3083,7 @@ impl ChatWidget {
user_facing_hint: None,
},
});
let _ = self
.bottom_pane
.take_recent_submission_images_with_placeholders();
let _ = self.bottom_pane.take_mention_paths();
self.bottom_pane.drain_pending_submission_state();
}
_ => self.dispatch_command(cmd),
}