Generative: a picture with nothing to open takes no focus

A done result tracks its focus only beside its press, so a grid with
no open handler leaves focus where it was. A decided comparison drops
its empty verdict row, so no gap is left under the sides.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 12:44:18 -04:00
1 parent ac949fb1ce
commit 2a992f0399
4 files changed
+46 -13

No files matched your search

+31 -1
View File
@@ -1,6 +1,9 @@
use std::{cell::RefCell, rc::Rc, time::Duration};
use gpui::{Context, IntoElement, ParentElement, Render, Styled, TestAppContext, Window, div, px};
use gpui::{
Context, IntoElement, Modifiers, ParentElement, Render, Styled, TestAppContext, Window, div,
point, px,
};
use super::{press, settle, setup, tab};
use crate::generative::{
@@ -94,6 +97,33 @@ fn only_done_results_open_and_a_failure_retries(cx: &mut TestAppContext) {
);
}
/// A single picture with nothing to open it.
struct Still;
impl Render for Still {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().w(px(420.0)).child(GenerationGrid::new(
"still",
[Outcome::Done("missing.jpg".into())],
1.5,
))
}
}
#[gpui::test]
fn a_picture_with_nothing_to_open_takes_no_focus(cx: &mut TestAppContext) {
setup(cx);
let (_, cx) = cx.add_window_view(|_, _| Still);
cx.update(|window, _| window.activate_window());
settle(cx);
cx.simulate_click(point(px(100.0), px(60.0)), Modifiers::none());
settle(cx);
assert!(
cx.update(|window, cx| window.focused(cx).is_none()),
"no ring on a picture the keys cannot use"
);
}
/// Three variations with the first chosen, and what it heard.
struct Variations(Heard);