mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
tui: avoid loop-shaped op drain helpers in tests
This commit is contained in:
@@ -1748,25 +1748,23 @@ async fn make_chatwidget_manual(
|
||||
// ChatWidget may emit other `Op`s (e.g. history/logging updates) on the same channel; this helper
|
||||
// filters until we see a submission op.
|
||||
fn next_submit_op(op_rx: &mut tokio::sync::mpsc::UnboundedReceiver<Op>) -> Op {
|
||||
loop {
|
||||
match op_rx.try_recv() {
|
||||
Ok(op @ Op::UserTurn { .. }) => return op,
|
||||
Ok(_) => continue,
|
||||
Err(TryRecvError::Empty) => panic!("expected a submit op but queue was empty"),
|
||||
Err(TryRecvError::Disconnected) => panic!("expected submit op but channel closed"),
|
||||
while let Ok(op) = op_rx.try_recv() {
|
||||
if matches!(op, Op::UserTurn { .. }) {
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
||||
panic!("expected a submit op but queue was empty");
|
||||
}
|
||||
|
||||
fn next_interrupt_op(op_rx: &mut tokio::sync::mpsc::UnboundedReceiver<Op>) {
|
||||
loop {
|
||||
match op_rx.try_recv() {
|
||||
Ok(Op::Interrupt) => return,
|
||||
Ok(_) => continue,
|
||||
Err(TryRecvError::Empty) => panic!("expected an interrupt op but queue was empty"),
|
||||
Err(TryRecvError::Disconnected) => panic!("expected interrupt op but channel closed"),
|
||||
while let Ok(op) = op_rx.try_recv() {
|
||||
if op == Op::Interrupt {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
panic!("expected an interrupt op but queue was empty");
|
||||
}
|
||||
|
||||
fn assert_no_submit_op(op_rx: &mut tokio::sync::mpsc::UnboundedReceiver<Op>) {
|
||||
|
||||
Reference in New Issue
Block a user