From 35707684b9de1b2e2b6be5de5a49e69ad57ac36b Mon Sep 17 00:00:00 2001 From: Eric Yue Date: Tue, 15 Sep 2026 21:28:59 +0800 Subject: test: wait for runtime readiness in integration tests (#4168) Root cause: The handoff test starts an agent immediately after workspace creation, before the new shell is necessarily ready. The reconnect test assumes a fixed sidebar row and searches raw ANSI output for text that can arrive as separate incremental cell updates. Fix: Wait for a shell builtin to write a readiness marker before sending the single raw agent.start request. Exercise the gap with a delayed shell. Locate the recovered workspace in the rendered sidebar and check the reconstructed screen for selection and input, including overlay borders. Do not extend existing timeouts or add retries that hide failures. Validation: All 25 affected group and helper tests pass. Ten repeated rounds of the two runtime tests and the row helper pass, for 30 test executions without retries. Standalone native just ci passes 3582 Rust tests with six default skips, formatting, all-target Clippy, 106 maintenance tests, six architecture tests and 39 integration-asset tests. Windows cross-lint was not run because its SDK is not installed. Co-authored-by: JJ Liebig --- tests/live_handoff.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests/live_handoff.rs') diff --git a/tests/live_handoff.rs b/tests/live_handoff.rs index e40f8268..ea4b84df 100644 --- a/tests/live_handoff.rs +++ b/tests/live_handoff.rs @@ -1581,9 +1581,13 @@ fn live_handoff_keeps_agent_started_pane_after_agent_exits() { let api_socket = runtime_dir.join("herdr.sock"); let started_marker = base.join("agent-started"); let exited_marker = base.join("agent-exited"); + let ready_marker = base.join("shell-ready"); let shell_marker = base.join("shell-after-agent"); let bin = base.join("bin"); fs::create_dir_all(&bin).unwrap(); + let delayed_shell = bin.join("delayed-shell"); + fs::write(&delayed_shell, "#!/bin/sh\n/bin/sleep 0.4\nexec /bin/sh\n").unwrap(); + fs::set_permissions(&delayed_shell, fs::Permissions::from_mode(0o755)).unwrap(); let fake_pi = bin.join("pi"); fs::write( &fake_pi, @@ -1601,7 +1605,10 @@ fn live_handoff_keeps_agent_started_pane_after_agent_exits() { &config_home, &runtime_dir, &api_socket, - &[("PATH", path.as_str())], + &[ + ("PATH", path.as_str()), + ("SHELL", delayed_shell.to_str().unwrap()), + ], ); wait_for_socket(&api_socket, Duration::from_secs(10)); register_runtime_dir(&runtime_dir); @@ -1619,6 +1626,22 @@ fn live_handoff_keeps_agent_started_pane_after_agent_exits() { .unwrap() .to_string(); + assert_ok(request( + &api_socket, + serde_json::json!({ + "id": "test:shell-ready", + "method": "pane.send_input", + "params": { + "pane_id": pane_id, + "text": format!("printf ready > {}", ready_marker.display()), + "keys": ["Enter"] + } + }), + )); + // Creation acknowledges the PTY, not an idle interactive shell. A real + // shell command must execute before this raw agent.start request. + support::wait_for_file(&ready_marker, Duration::from_secs(5)); + let started = request( &api_socket, serde_json::json!({ -- cgit v1.2.3