Skip to content

Commit 672368e

Browse files
committed
fix(tui): prefer auto-drive summary before next prompt
1 parent 60373fd commit 672368e

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

code-rs/tui/src/chatwidget.rs

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20515,10 +20515,6 @@ Have we met every part of this goal and is there no further work to do?"#
2051520515

2051620516
fn auto_rebuild_live_ring(&mut self) {
2051720517
if !self.auto_state.is_active() {
20518-
if self.auto_state.should_show_goal_entry() {
20519-
self.auto_show_goal_entry_panel();
20520-
return;
20521-
}
2052220518
if let Some(summary) = self.auto_state.last_run_summary.clone() {
2052320519
self.bottom_pane.clear_live_ring();
2052420520
self.auto_reset_intro_timing();
@@ -20570,6 +20566,11 @@ Have we met every part of this goal and is there no further work to do?"#
2057020566
return;
2057120567
}
2057220568

20569+
if self.auto_state.should_show_goal_entry() {
20570+
self.auto_show_goal_entry_panel();
20571+
return;
20572+
}
20573+
2057320574
self.bottom_pane.clear_auto_coordinator_view(true);
2057420575
self.bottom_pane.clear_live_ring();
2057520576
self.bottom_pane.set_standard_terminal_hint(None);
@@ -33399,6 +33400,52 @@ use code_core::protocol::OrderMeta;
3339933400
assert_eq!(route.intent, EscIntent::AutoDismissSummary);
3340033401
}
3340133402

33403+
#[test]
33404+
fn completed_auto_drive_prefers_summary_before_next_goal_prompt() {
33405+
let mut harness = ChatWidgetHarness::new();
33406+
let chat = harness.chat();
33407+
33408+
chat.auto_state.last_run_summary = Some(AutoRunSummary {
33409+
duration: Duration::from_secs(42),
33410+
turns_completed: 3,
33411+
message: Some("All tasks done.".to_string()),
33412+
goal: Some("Finish feature".to_string()),
33413+
});
33414+
chat.auto_state.set_phase(AutoRunPhase::AwaitingGoalEntry);
33415+
33416+
chat.auto_rebuild_live_ring();
33417+
33418+
let model = chat
33419+
.bottom_pane
33420+
.auto_view_model()
33421+
.expect("auto coordinator view should be active");
33422+
let AutoCoordinatorViewModel::Active(active) = model;
33423+
assert_eq!(active.goal.as_deref(), Some("Finish feature"));
33424+
assert_eq!(active.status_lines, vec!["All tasks done.".to_string()]);
33425+
assert!(active.ctrl_switch_hint.contains("Esc"));
33426+
33427+
assert!(chat.auto_state.should_show_goal_entry());
33428+
assert!(chat.auto_state.last_run_summary.is_some());
33429+
33430+
let route = chat.describe_esc_context();
33431+
assert_eq!(route.intent, EscIntent::AutoDismissSummary);
33432+
assert!(chat.execute_esc_intent(
33433+
route.intent,
33434+
KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE),
33435+
));
33436+
33437+
let model = chat
33438+
.bottom_pane
33439+
.auto_view_model()
33440+
.expect("auto coordinator view should show goal entry after dismissing summary");
33441+
let AutoCoordinatorViewModel::Active(active) = model;
33442+
assert!(active.goal.is_none());
33443+
assert_eq!(
33444+
active.status_lines,
33445+
vec!["Let's do this! What's your goal?".to_string()]
33446+
);
33447+
}
33448+
3340233449
#[test]
3340333450
fn goal_entry_typing_arms_escape_state() {
3340433451
let mut harness = ChatWidgetHarness::new();

code-rs/tui/src/chatwidget/esc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ impl ChatWidget<'_> {
152152
return EscRoute::new(EscIntent::CancelAgents, true, false);
153153
}
154154

155+
if self.auto_state.last_run_summary.is_some() {
156+
return EscRoute::new(EscIntent::AutoDismissSummary, true, false);
157+
}
158+
155159
if self.auto_state.should_show_goal_entry() {
156160
return EscRoute::new(
157161
match self.auto_goal_escape_state {
@@ -164,10 +168,6 @@ impl ChatWidget<'_> {
164168
);
165169
}
166170

167-
if self.auto_state.last_run_summary.is_some() {
168-
return EscRoute::new(EscIntent::AutoDismissSummary, true, false);
169-
}
170-
171171
if self.auto_manual_entry_active() && !self.composer_is_empty() {
172172
return EscRoute::new(EscIntent::ClearComposer, true, false);
173173
}

0 commit comments

Comments
 (0)