Skip to content

Commit 1f4d16f

Browse files
committed
Fix comments in the test
1 parent 728bd9d commit 1f4d16f

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

codex-rs/tui/src/chatwidget/tests.rs

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,51 +1461,37 @@ fn deltas_then_same_final_message_are_rendered_snapshot() {
14611461
fn local_bang_exec_lists_files() {
14621462
use std::fs;
14631463

1464-
// Prepare a temporary working directory with two files
14651464
let tmp = tempfile::tempdir().expect("tempdir");
14661465
let f1 = tmp.path().join("alpha.txt");
14671466
let f2 = tmp.path().join("beta.txt");
14681467
fs::write(&f1, b"one").unwrap();
14691468
fs::write(&f2, b"two").unwrap();
14701469

1471-
// Set up widget and force CWD to the temp dir so the test is hermetic
14721470
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual();
14731471
chat.config.cwd = tmp.path().to_path_buf();
14741472

1475-
// Simulate typing a local command and pressing Enter
1476-
#[cfg(windows)]
1477-
let typed = "!dir".to_string();
1478-
#[cfg(not(windows))]
14791473
let typed = "!ls".to_string();
14801474
// Use paste to avoid triggering burst heuristics that suppress Enter submission
14811475
chat.bottom_pane.handle_paste(typed);
14821476
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
14831477

1484-
// Expect an Op::LocalExec emitted to the codex channel
1478+
14851479
let op = op_rx.try_recv().expect("expected LocalExec op emitted");
14861480
let raw_cmd = match op {
14871481
Op::LocalExec { raw_cmd } => raw_cmd,
14881482
other => panic!("unexpected op: {other:?}"),
14891483
};
1490-
#[cfg(windows)]
1491-
assert!(raw_cmd.to_ascii_lowercase().starts_with("dir"));
1492-
#[cfg(not(windows))]
14931484
assert_eq!(raw_cmd, "ls");
14941485

14951486
// Feed the corresponding LocalCommand events back into the widget as if from core
1496-
#[cfg(windows)]
1497-
let begin_cmd = vec!["cmd".to_string(), "/C".to_string(), raw_cmd.clone()];
1498-
#[cfg(not(windows))]
14991487
let begin_cmd = vec!["bash".to_string(), "-lc".to_string(), raw_cmd.clone()];
1500-
15011488
chat.handle_codex_event(Event {
15021489
id: "sub-1".into(),
15031490
msg: EventMsg::LocalCommandBegin(codex_core::protocol::LocalCommandBeginEvent {
15041491
command: begin_cmd,
15051492
}),
15061493
});
15071494

1508-
// Create a deterministic stdout that includes both filenames, one per line
15091495
let mut stdout = String::new();
15101496
stdout.push_str("alpha.txt\n");
15111497
stdout.push_str("beta.txt\n");
@@ -1518,7 +1504,6 @@ fn local_bang_exec_lists_files() {
15181504
}),
15191505
});
15201506

1521-
// Drain history insertions and assert both files are present
15221507
let cells = drain_insert_history(&mut rx);
15231508
let combined = cells
15241509
.iter()
@@ -1550,21 +1535,14 @@ fn local_bang_exec_respects_max_lines() {
15501535

15511536
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual();
15521537
chat.config.cwd = tmp.path().to_path_buf();
1553-
// Enforce a small cap to test truncation clearly
15541538
chat.config.tui.local_shell_max_lines = 10;
1555-
1556-
#[cfg(windows)]
1557-
let typed = format!("!type {}", big.display());
1558-
#[cfg(not(windows))]
15591539
let typed = format!("!cat {}", big.display());
15601540

15611541
chat.bottom_pane.handle_paste(typed);
15621542
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
15631543

1564-
// Expect the local exec op
15651544
let _ = op_rx.try_recv().expect("expected LocalExec op emitted");
15661545

1567-
// Simulate begin/end events with stdout equal to the file contents we wrote
15681546
let stdout = {
15691547
let mut s = String::new();
15701548
for i in 0..total_lines {
@@ -1593,7 +1571,6 @@ fn local_bang_exec_respects_max_lines() {
15931571
.map(|lines| lines_to_single_string(lines))
15941572
.collect::<String>();
15951573

1596-
// Count rendered content lines that begin with our marker 'L'
15971574
let rendered_content_lines = combined
15981575
.lines()
15991576
.filter(|l| l.trim_start().starts_with('L'))
@@ -1613,29 +1590,28 @@ fn local_bang_exec_can_be_interrupted_with_ctrl_c() {
16131590
use codex_core::protocol::LocalCommandBeginEvent;
16141591
use codex_core::protocol::LocalCommandEndEvent;
16151592

1616-
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual();
1593+
let (mut chat, _, mut op_rx) = make_chatwidget_manual();
16171594

1618-
// Simulate a long-running local command begin (sleep)
16191595
chat.handle_codex_event(Event {
16201596
id: "sub-ctrlc".into(),
16211597
msg: EventMsg::LocalCommandBegin(LocalCommandBeginEvent {
16221598
command: vec!["bash".into(), "-lc".into(), "sleep 10000".into()],
16231599
}),
16241600
});
16251601

1626-
// Ensure UI marks a running task
16271602
assert!(chat.bottom_pane.is_task_running(), "task should be running");
16281603

1629-
// Press Ctrl-C; widget should send Op::Interrupt and clear running state
1630-
let _ = chat.on_ctrl_c();
1604+
// Press Ctrl-C; widget should send Op::Interrupt and running state should remain until LocalCommandEnd is received
1605+
chat.on_ctrl_c();
16311606
let op = op_rx.try_recv().expect("expected Interrupt op emitted");
16321607
match op {
16331608
Op::Interrupt => {}
16341609
other => panic!("unexpected op: {other:?}"),
16351610
}
1611+
// At this point, the task is still running until LocalCommandEnd is received
16361612
assert!(
1637-
!chat.bottom_pane.is_task_running(),
1638-
"task running flag should be cleared after Ctrl-C"
1613+
chat.bottom_pane.is_task_running(),
1614+
"task running flag should remain set after Ctrl-C until LocalCommandEnd"
16391615
);
16401616

16411617
// Core would reply with LocalCommandEnd after termination; simulate it
@@ -1644,10 +1620,14 @@ fn local_bang_exec_can_be_interrupted_with_ctrl_c() {
16441620
msg: EventMsg::LocalCommandEnd(LocalCommandEndEvent {
16451621
stdout: String::new(),
16461622
stderr: String::new(),
1647-
exit_code: 130, // common SIGINT exit
1623+
// Anything non-zero to signal interruption but we don't care about the value here.
1624+
exit_code: 1,
16481625
}),
16491626
});
16501627

1651-
// Drain any history updates to ensure no panics and UI progressed
1652-
let _ = drain_insert_history(&mut rx);
1628+
// Now the running state should be cleared
1629+
assert!(
1630+
!chat.bottom_pane.is_task_running(),
1631+
"task running flag should be cleared after LocalCommandEnd"
1632+
);
16531633
}

0 commit comments

Comments
 (0)