From a853c9c03897bde8aa6681524fd5e076dc561b53 Mon Sep 17 00:00:00 2001 From: bRRRITSCOLD Date: Tue, 24 Nov 2026 05:07:28 -0700 Subject: [PATCH] fix(gui): label every Field with FieldLabel, as Penpot's Field/Label (#405, #288) Every Field in Penpot labels with the library's `Field/Label` part, core-react's FieldLabel (`leading-snug`, 19.25px), but the app drew a plain Label (`leading-none`, 14px). Each field came out about 5px short, which put Edit workspace's lines 3-4px above Penpot's once the dialog centred, and made the Quit dialog's options and buttons sit high. All Field labels (Edit and New workspace, New agent, Delete workspace, Paste token, Settings, the GitHub client ID and Quit's options) now use FieldLabel. Layout tests pin the Edit workspace form's lines and Quit's spacing. Co-Authored-By: Claude Opus 5.5 --- crates/agentdeck-gui/src/delete_workspace.rs | 6 +- crates/agentdeck-gui/src/edit_workspace.rs | 67 +++++++++++++++++-- crates/agentdeck-gui/src/github/mod.rs | 4 +- .../agentdeck-gui/src/github/paste_token.rs | 4 +- crates/agentdeck-gui/src/new_agent.rs | 6 +- crates/agentdeck-gui/src/new_workspace.rs | 6 +- crates/agentdeck-gui/src/settings.rs | 13 ++-- crates/agentdeck-gui/src/shell.rs | 28 +++++++- 8 files changed, 107 insertions(+), 27 deletions(-) diff --git a/crates/agentdeck-gui/src/delete_workspace.rs b/crates/agentdeck-gui/src/delete_workspace.rs index aec2623..a8e9f18 100644 --- a/crates/agentdeck-gui/src/delete_workspace.rs +++ b/crates/agentdeck-gui/src/delete_workspace.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use agentdeck_core::{AgentState, WorkspaceId}; use brrritscold_core_gpui::{ ActiveTheme as _, Button, ButtonVariant, Dialog, DialogClose, DialogContent, DialogDescription, - DialogFooter, DialogHandle, DialogHeader, DialogTitle, Field, Input, InputState, Label, + DialogFooter, DialogHandle, DialogHeader, DialogTitle, Field, FieldLabel, Input, InputState, }; use brrritscold_core_gpui_tokens::primitive::space; use gpui::prelude::FluentBuilder as _; @@ -255,7 +255,9 @@ impl Render for DeleteWorkspaceDialog { ) .child( Field::new() - .child(Label::new().child(format!("Type {name} to confirm"))) + .child( + FieldLabel::new().child(format!("Type {name} to confirm")), + ) .child(Input::new(&self.confirm)), ), ) diff --git a/crates/agentdeck-gui/src/edit_workspace.rs b/crates/agentdeck-gui/src/edit_workspace.rs index 4454452..7039095 100644 --- a/crates/agentdeck-gui/src/edit_workspace.rs +++ b/crates/agentdeck-gui/src/edit_workspace.rs @@ -16,7 +16,7 @@ use agentdeck_client::ApiError; use agentdeck_core::WorkspaceId; use brrritscold_core_gpui::{ Button, ButtonVariant, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, - DialogHandle, DialogHeader, DialogTitle, Field, FieldError, Input, InputState, Label, + DialogHandle, DialogHeader, DialogTitle, Field, FieldError, FieldLabel, Input, InputState, }; use brrritscold_core_gpui_tokens::primitive::space; use gpui::prelude::FluentBuilder as _; @@ -239,11 +239,17 @@ impl EditWorkspaceDialog { .flex_col() .gap(space::S4) .child( - Field::new().child(Label::new().child("Name")).child( - div() - .debug_selector(|| "edit workspace name".into()) - .child(Input::new(&self.name).aria_invalid(problem.is_some())), - ), + Field::new() + .child( + div() + .debug_selector(|| "edit workspace name label".into()) + .child(FieldLabel::new().child("Name")), + ) + .child( + div() + .debug_selector(|| "edit workspace name".into()) + .child(Input::new(&self.name).aria_invalid(problem.is_some())), + ), ) .when_some(problem, |form, why| { form.child( @@ -629,6 +635,55 @@ mod tests { } } + /// Where the form's lines sit (#405), against Penpot "Screens · Dialogs" → "Edit + /// workspace": each line's top below the Name label's top, as core-react lays it out, + /// within the pixel GPUI snaps to. Penpot draws each `leading-snug` label 20px tall + /// where code has 19.25, so its lines sit 0.75px lower (input 32, rows 106). The + /// header above is core-gpui's, and the test platform's text widths wrap its + /// description differently, so the form is measured from its own first line. + mod layout { + use super::*; + + /// The Name input's top: the label is a `Field/Label`, core-react's FieldLabel + /// (`leading-snug`, 19.25px), then the Field's `gap-3`. + const NAME_INPUT: f32 = 31.25; + /// The linked rows' top: the 36px input, the form's `space.4`, the Repositories + /// label (a plain `Label`, `leading-none`, 14px), then the picker's `space.2`. + const REPOSITORY_ROWS: f32 = 105.25; + + fn assert_below_the_name_label( + selector: &'static str, + expected: f32, + cx: &mut VisualTestContext, + ) { + let label = cx + .debug_bounds("edit workspace name label") + .expect("the Name label"); + let at = cx + .debug_bounds(selector) + .unwrap_or_else(|| panic!("{selector} shown")); + let app = f32::from(at.top() - label.top()); + assert!( + (app - expected).abs() <= 1., + "{selector}: {app}px below the Name label's top, expected {expected}px" + ); + } + + #[gpui::test] + fn should_place_the_name_input_under_a_field_label(cx: &mut TestAppContext) { + let (_harness, cx) = Harness::open(cx); + + assert_below_the_name_label("edit workspace name", NAME_INPUT, cx); + } + + #[gpui::test] + fn should_place_the_repositories_under_the_name_field(cx: &mut TestAppContext) { + let (_harness, cx) = Harness::open(cx); + + assert_below_the_name_label("repository rows", REPOSITORY_ROWS, cx); + } + } + mod repositories { use super::*; diff --git a/crates/agentdeck-gui/src/github/mod.rs b/crates/agentdeck-gui/src/github/mod.rs index 2746cea..2fbba6d 100644 --- a/crates/agentdeck-gui/src/github/mod.rs +++ b/crates/agentdeck-gui/src/github/mod.rs @@ -17,7 +17,7 @@ use agentdeck_client::types::{GithubAuthInfo, TokenEnvVar, TokenSource}; use agentdeck_core::ws::ServerMessage; use brrritscold_core_gpui::{ ActiveTheme as _, Button, ButtonSize, ButtonVariant, Field, FieldDescription, FieldError, - Input, InputState, Label, + FieldLabel, Input, InputState, }; use brrritscold_core_gpui_tokens::primitive::{font_size, font_weight, space}; use gpui::prelude::FluentBuilder as _; @@ -489,7 +489,7 @@ impl GithubSection { let blank = self.client_id.read(cx).value().trim().is_empty(); let error = self.client_id_error.clone(); Field::new() - .child(Label::new().child("OAuth client ID")) + .child(FieldLabel::new().child("OAuth client ID")) .child( div() .flex() diff --git a/crates/agentdeck-gui/src/github/paste_token.rs b/crates/agentdeck-gui/src/github/paste_token.rs index ff84b5e..1142541 100644 --- a/crates/agentdeck-gui/src/github/paste_token.rs +++ b/crates/agentdeck-gui/src/github/paste_token.rs @@ -12,7 +12,7 @@ use agentdeck_client::ApiError; use agentdeck_client::types::GithubAuthInfo; use brrritscold_core_gpui::{ Button, ButtonVariant, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHandle, - DialogHeader, DialogTitle, Field, FieldError, Input, InputState, Label, + DialogHeader, DialogTitle, Field, FieldError, FieldLabel, Input, InputState, }; use brrritscold_core_gpui_tokens::primitive::space; use gpui::prelude::FluentBuilder as _; @@ -174,7 +174,7 @@ impl Render for PasteTokenDialog { .flex_col() .gap(space::S4) .child( - Field::new().child(Label::new().child("Token")).child( + Field::new().child(FieldLabel::new().child("Token")).child( div() .debug_selector(|| "paste token input".into()) .child(Input::new(&self.token).aria_invalid(error.is_some())), diff --git a/crates/agentdeck-gui/src/new_agent.rs b/crates/agentdeck-gui/src/new_agent.rs index 7961ccb..e36cd27 100644 --- a/crates/agentdeck-gui/src/new_agent.rs +++ b/crates/agentdeck-gui/src/new_agent.rs @@ -16,8 +16,8 @@ use agentdeck_client::ApiError; use agentdeck_core::{Agent, PaneId, TabId, WorkspaceId}; use brrritscold_core_gpui::{ Button, ButtonVariant, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, - DialogHandle, DialogHeader, DialogTitle, Field, FieldDescription, Label, Select, SelectContent, - SelectItem, SelectTrigger, + DialogHandle, DialogHeader, DialogTitle, Field, FieldDescription, FieldLabel, Select, + SelectContent, SelectItem, SelectTrigger, }; use brrritscold_core_gpui_tokens::primitive::space; use gpui::{ @@ -238,7 +238,7 @@ impl NewAgentDialog { fn field(label: &'static str, select: Select, description: Option) -> impl IntoElement { Field::new() - .child(Label::new().child(label)) + .child(FieldLabel::new().child(label)) .child(select) .children(description.map(FieldDescription::new)) } diff --git a/crates/agentdeck-gui/src/new_workspace.rs b/crates/agentdeck-gui/src/new_workspace.rs index dbbb04d..b2abf70 100644 --- a/crates/agentdeck-gui/src/new_workspace.rs +++ b/crates/agentdeck-gui/src/new_workspace.rs @@ -13,8 +13,8 @@ use agentdeck_client::ApiError; use agentdeck_core::{RepositoryName, WorkspaceId}; use brrritscold_core_gpui::{ Button, ButtonVariant, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, - DialogHandle, DialogHeader, DialogTitle, Field, FieldDescription, FieldError, Input, - InputState, Label, + DialogHandle, DialogHeader, DialogTitle, Field, FieldDescription, FieldError, FieldLabel, + Input, InputState, }; use brrritscold_core_gpui_tokens::primitive::space; use gpui::prelude::FluentBuilder as _; @@ -181,7 +181,7 @@ impl NewWorkspaceDialog { .child( div().debug_selector(|| "name field".into()).child( Field::new() - .child(Label::new().child("Name")) + .child(FieldLabel::new().child("Name")) .child(Input::new(&self.name).aria_invalid(problem.is_some())) .child(FieldDescription::new(NAME_HINT)) .when_some(problem, |field, why| field.child(FieldError::new(why))), diff --git a/crates/agentdeck-gui/src/settings.rs b/crates/agentdeck-gui/src/settings.rs index 82ef7b7..a0c1e1c 100644 --- a/crates/agentdeck-gui/src/settings.rs +++ b/crates/agentdeck-gui/src/settings.rs @@ -28,8 +28,9 @@ use agentdeck_client::types::{ use agentdeck_core::opener::{FileOpener, OpenerError}; use agentdeck_core::ws::{Entity as Changed, ServerMessage}; use brrritscold_core_gpui::{ - ActiveTheme as _, Field, FieldContent, FieldDescription, FieldError, FieldOrientation, Input, - InputState, Label, Select, SelectContent, SelectItem, SelectTrigger, Switch, Theme, + ActiveTheme as _, Field, FieldContent, FieldDescription, FieldError, FieldLabel, + FieldOrientation, Input, InputState, Select, SelectContent, SelectItem, SelectTrigger, Switch, + Theme, }; use brrritscold_core_gpui_tokens::primitive::{font_size, font_weight, space}; use gpui::prelude::FluentBuilder as _; @@ -503,7 +504,7 @@ impl SettingsView { } })); Field::new() - .child(Label::new().child("Theme")) + .child(FieldLabel::new().child("Theme")) .child( // Penpot fits the trigger to its value, so the field doesn't stretch it. div() @@ -521,7 +522,7 @@ impl SettingsView { fn days_field(&self) -> gpui::AnyElement { let error = self.days_error().cloned(); Field::new() - .child(Label::new().child("Sync PRs updated in the last (days)")) + .child(FieldLabel::new().child("Sync PRs updated in the last (days)")) .child( div() .debug_selector(|| "settings days".into()) @@ -562,7 +563,7 @@ impl SettingsView { .content( FieldContent::new() .min_w_0() - .child(Label::new().child("Ask before quitting while agents run")) + .child(FieldLabel::new().child("Ask before quitting while agents run")) .child(FieldDescription::new(CONFIRM_QUIT_DESCRIPTION)), ); div() @@ -575,7 +576,7 @@ impl SettingsView { fn opener_field(&self) -> gpui::AnyElement { let error = self.opener_error().cloned(); Field::new() - .child(Label::new().child("Open file paths with")) + .child(FieldLabel::new().child("Open file paths with")) .child( div() .debug_selector(|| "settings opener".into()) diff --git a/crates/agentdeck-gui/src/shell.rs b/crates/agentdeck-gui/src/shell.rs index 469b6ad..7b84f38 100644 --- a/crates/agentdeck-gui/src/shell.rs +++ b/crates/agentdeck-gui/src/shell.rs @@ -42,8 +42,8 @@ use brrritscold_core_gpui::{ ActiveTheme as _, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertTitle, AlertVariant, Button, ButtonSize, - ButtonVariant, Checkbox, DialogHandle, Field, FieldContent, FieldOrientation, IconName, Label, - Separator, SeparatorOrientation, + ButtonVariant, Checkbox, DialogHandle, Field, FieldContent, FieldLabel, FieldOrientation, + IconName, Separator, SeparatorOrientation, }; use brrritscold_core_gpui_tokens::primitive::space; use futures_util::future::{self, Either}; @@ -305,7 +305,7 @@ impl Shell { .id(SharedString::from(format!("{id}-label"))) .cursor_pointer() .on_click(move |_, _, cx| tick_label(!on, cx)) - .child(Label::new().child(label)), + .child(FieldLabel::new().child(label)), ), ) } @@ -3549,6 +3549,28 @@ mod tests { assert!(ticked); } + /// Penpot "Quit · agents running" (#288): each option is a Field whose label is a + /// `Field/Label`, core-react's FieldLabel (`leading-snug`, 19.25px), the options + /// `space.3` apart and `space.6` above the buttons. Each top is as core-react lays + /// it out, within the pixel GPUI snaps to; Penpot draws each label 20px tall, so its + /// lines sit 0.75px lower per option (32 and 76). + #[gpui::test] + fn should_space_the_options_and_buttons_by_their_field_labels(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open(daemon(vec![agent(1)], true), cx); + harness.press_quit(cx); + let top = |selector: &'static str, cx: &mut VisualTestContext| { + let at = cx.debug_bounds(selector); + f32::from(at.unwrap_or_else(|| panic!("{selector} shown")).top()) + }; + + let dont_ask = top("quit dont ask again", cx); + let stop = top("quit stop agents", cx) - dont_ask; + let buttons = top("quit confirm", cx) - dont_ask; + + assert!((stop - 31.25).abs() <= 1., "Stop the agents {stop}px down"); + assert!((buttons - 74.5).abs() <= 1., "the buttons {buttons}px down"); + } + #[gpui::test] fn should_leave_the_agents_running_with_stop_the_agents_unticked(cx: &mut TestAppContext) { let (harness, cx) = Harness::open(daemon(vec![agent(1)], true), cx);