Generative: the embedding turns by drag past its edge; version diffs are tested

The turned embedding turns through gpui's drag, marked with its view, so a
drag keeps turning past the plot's edge. What a chosen version is set
against, and its heading, move into versions::compared, with a test. A
hidden legend entry dims its key and not its ring, and an embedding refuses
a group named twice.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 15:17:45 -04:00
1 parent e3038647c8
commit 3d9cf1008e
6 files changed
+122 -52

No files matched your search

+30 -3
View File
@@ -1,6 +1,6 @@
use gpui::{
AppContext, Bounds, Context, Entity, IntoElement, Modifiers, ParentElement, Pixels, Render,
Styled, TestAppContext, VisualTestContext, Window, div, point, px,
AppContext, Bounds, Context, Entity, IntoElement, Modifiers, MouseButton, ParentElement,
Pixels, Render, Styled, TestAppContext, VisualTestContext, Window, div, point, px,
};
use jiff::Timestamp;
@@ -9,7 +9,7 @@ use crate::{
forms::TextInput,
generative::{
Embedded, EmbeddingVisualizer, PromptPlayground, PromptVersion, PromptVersionHistory,
lens::{Lens, START, STEP, radius, turned},
lens::{DRAG, Lens, START, STEP, radius, turned},
},
};
@@ -105,6 +105,33 @@ fn a_turned_view_takes_tab_and_spins_with_the_arrows(cx: &mut TestAppContext) {
assert!((tip.origin - at).x.abs() < px(0.5) && (tip.origin - at).y.abs() < px(0.5));
}
#[gpui::test]
fn a_drag_keeps_turning_past_the_plots_edge(cx: &mut TestAppContext) {
let cx = space(true, cx);
let middle = cx
.debug_bounds("embedding-area")
.expect("the area draws")
.center();
let (none, down) = (Modifiers::none(), |y: f32| middle + point(px(0.0), px(y)));
cx.simulate_mouse_down(middle, MouseButton::Left, none);
cx.simulate_mouse_move(down(50.0), MouseButton::Left, none);
cx.simulate_mouse_move(down(250.0), MouseButton::Left, none);
cx.simulate_mouse_up(down(250.0), MouseButton::Left, none);
settle(cx);
let at = aim(A, Some(turned(START, (0.0, 250.0 * DRAG))), cx);
hover(at, cx);
let tip = cx
.debug_bounds("embedding-tip")
.expect("a is named where the whole drag turned it");
assert!((tip.origin - at).x.abs() < px(0.5) && (tip.origin - at).y.abs() < px(0.5));
}
#[gpui::test]
#[should_panic(expected = "named twice")]
fn a_group_named_twice_fails_loud() {
EmbeddingVisualizer::new("space", points(), ["Docs", "Docs"]);
}
#[gpui::test]
#[should_panic(expected = "sits outside -1 to 1")]
fn a_point_past_the_cube_fails_loud() {