From 8d54309893ac6309f09fc15ab49fdedf8b3a73b1 Mon Sep 17 00:00:00 2001 From: Joshua Cold Date: Mon, 23 Nov 2026 14:55:39 -0700 Subject: [PATCH 1/2] fix(lua): a float shown during a question gives the keyboard back to it Showing a float's overlay takes the keyboard. Outside a question riptide hands it back to the tab, but during one it handed it to nothing, so the keys went to the float and the question could no longer be typed into, e.g. a password manager's master password while its status float appeared. The status bar, which takes a question's keys, now gets them back. Co-Authored-By: Claude Opus 5.5 --- crates/rt-cef/src/float.rs | 26 +++++++++++++-------- crates/rt-e2e/tests/lua_events.rs | 39 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/crates/rt-cef/src/float.rs b/crates/rt-cef/src/float.rs index c9dc51f6..13908daf 100644 --- a/crates/rt-cef/src/float.rs +++ b/crates/rt-cef/src/float.rs @@ -285,19 +285,25 @@ pub fn reposition() { shown = true; } } - // During a prompt the status bar keeps the keyboard, on purpose. - let prompting = shell::with(|s| { - matches!( + if !shown { + return; + } + // During a prompt the keys belong to the status bar (see + // `shell::focus_for_prompt`), so it gets them back rather than the tab. + let back = shell::with(|s| { + let prompting = matches!( s.engine.mode(), rt_core::Mode::Prompt | rt_core::Mode::YesNo - ) + ); + if prompting { + s.statusbar.clone() + } else { + s.tabs.current().map(|t| t.view.clone()) + } }) - .unwrap_or(false); - if shown - && !prompting - && let Some(tab) = shell::with(|s| s.tabs.current().map(|t| t.view.clone())).flatten() - { - crate::panes::focus_view(&tab); + .flatten(); + if let Some(view) = back { + crate::panes::focus_view(&view); } } diff --git a/crates/rt-e2e/tests/lua_events.rs b/crates/rt-e2e/tests/lua_events.rs index 2919eedd..de06b80b 100644 --- a/crates/rt-e2e/tests/lua_events.rs +++ b/crates/rt-e2e/tests/lua_events.rs @@ -198,6 +198,45 @@ end) }); } +/// A float that appears while riptide asks something leaves the keyboard +/// with the question: real keys, not the test channel, which skips focus. +#[test] +#[ignore = "starts a browser; run with ./task e2e"] +fn a_float_shown_during_a_question_leaves_it_the_keyboard() { + let b = Browser::launch() + .lua( + r#" +rt.command("ask-then-float", function() + rt.ui.input({ prompt = "Password", secret = true }, function(text) + rt.notify("typed " .. tostring(text)) + end) + rt.defer(300, function() rt.ui.float({ title = "Status", lines = { "working" } }) end) +end) +"#, + ) + .start("page.html"); + b.run("ask-then-float"); + b.wait_mode("prompt"); + b.wait_until("the float is placed", |s| { + s.floats.first().is_some_and(|f| f["placed"] == true) + }); + let status = std::process::Command::new("xdotool") + .args(["type", "--delay", "20", "hunter2"]) + .env("DISPLAY", format!(":{}", b.display())) + .status() + .expect("xdotool"); + assert!(status.success()); + let status = std::process::Command::new("xdotool") + .args(["key", "Return"]) + .env("DISPLAY", format!(":{}", b.display())) + .status() + .expect("xdotool"); + assert!(status.success()); + b.wait_until("the question got the keys", |s| { + s.message() == Some("typed hunter2") + }); +} + #[test] #[ignore = "starts a browser; run with ./task e2e"] fn panels_dock_beside_the_page_and_take_keys_when_focused() { From c4cfe16bb609f735912b2dce92a2cf269d3d1f45 Mon Sep 17 00:00:00 2001 From: Joshua Cold Date: Mon, 23 Nov 2026 14:58:15 -0700 Subject: [PATCH 2/2] test(lua): type the question's keys through one xdotool closure Co-Authored-By: Claude Opus 5.5 --- crates/rt-e2e/tests/lua_events.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/rt-e2e/tests/lua_events.rs b/crates/rt-e2e/tests/lua_events.rs index de06b80b..79cc9843 100644 --- a/crates/rt-e2e/tests/lua_events.rs +++ b/crates/rt-e2e/tests/lua_events.rs @@ -220,18 +220,16 @@ end) b.wait_until("the float is placed", |s| { s.floats.first().is_some_and(|f| f["placed"] == true) }); - let status = std::process::Command::new("xdotool") - .args(["type", "--delay", "20", "hunter2"]) - .env("DISPLAY", format!(":{}", b.display())) - .status() - .expect("xdotool"); - assert!(status.success()); - let status = std::process::Command::new("xdotool") - .args(["key", "Return"]) - .env("DISPLAY", format!(":{}", b.display())) - .status() - .expect("xdotool"); - assert!(status.success()); + let xdotool = |args: &[&str]| { + let status = std::process::Command::new("xdotool") + .args(args) + .env("DISPLAY", format!(":{}", b.display())) + .status() + .expect("xdotool"); + assert!(status.success()); + }; + xdotool(&["type", "--delay", "20", "hunter2"]); + xdotool(&["key", "Return"]); b.wait_until("the question got the keys", |s| { s.message() == Some("typed hunter2") });