Inline request_user_input history cell

This commit is contained in:
Charles Cunningham
2026-01-31 18:19:27 -08:00
parent 470e019d35
commit 2069033627
2 changed files with 13 additions and 27 deletions

View File

@@ -727,11 +727,11 @@ impl RequestUserInputOverlay {
},
}));
self.app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_request_user_input_result(
self.request.questions.clone(),
history_answers,
history_cell::RequestUserInputResultCell {
questions: self.request.questions.clone(),
answers: history_answers,
interrupted,
),
},
)));
}
@@ -795,11 +795,11 @@ impl RequestUserInputOverlay {
},
}));
self.app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_request_user_input_result(
self.request.questions.clone(),
history_answers,
false,
),
history_cell::RequestUserInputResultCell {
questions: self.request.questions.clone(),
answers: history_answers,
interrupted: false,
},
)));
if let Some(next) = self.queue.pop_front() {
self.request = next;
@@ -1856,8 +1856,7 @@ mod tests {
panic!("expected UserInputAnswer");
};
assert!(response.interrupted, "expected interrupted flag");
let answer = response.answers.get("q1").expect("answer missing");
assert_eq!(answer.answers, vec!["Option 1".to_string()]);
assert!(response.answers.is_empty(), "expected no committed answers");
let event = rx.try_recv().expect("expected history cell");
assert!(matches!(event, AppEvent::InsertHistoryCell(_)));

View File

@@ -1761,25 +1761,12 @@ pub(crate) fn new_error_event(message: String) -> PlainHistoryCell {
PlainHistoryCell { lines }
}
/// Build a history cell that renders request_user_input questions and answers.
pub(crate) fn new_request_user_input_result(
questions: Vec<RequestUserInputQuestion>,
answers: HashMap<String, RequestUserInputAnswer>,
interrupted: bool,
) -> RequestUserInputResultCell {
RequestUserInputResultCell {
questions,
answers,
interrupted,
}
}
/// Renders a completed (or interrupted) request_user_input exchange in history.
#[derive(Debug)]
pub(crate) struct RequestUserInputResultCell {
questions: Vec<RequestUserInputQuestion>,
answers: HashMap<String, RequestUserInputAnswer>,
interrupted: bool,
pub(crate) questions: Vec<RequestUserInputQuestion>,
pub(crate) answers: HashMap<String, RequestUserInputAnswer>,
pub(crate) interrupted: bool,
}
impl HistoryCell for RequestUserInputResultCell {