Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/agentdeck-gui/src/delete_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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)),
),
)
Expand Down
67 changes: 61 additions & 6 deletions crates/agentdeck-gui/src/edit_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/agentdeck-gui/src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions crates/agentdeck-gui/src/github/paste_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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())),
Expand Down
6 changes: 3 additions & 3 deletions crates/agentdeck-gui/src/new_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -238,7 +238,7 @@ impl NewAgentDialog {

fn field(label: &'static str, select: Select, description: Option<String>) -> impl IntoElement {
Field::new()
.child(Label::new().child(label))
.child(FieldLabel::new().child(label))
.child(select)
.children(description.map(FieldDescription::new))
}
Expand Down
6 changes: 3 additions & 3 deletions crates/agentdeck-gui/src/new_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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))),
Expand Down
13 changes: 7 additions & 6 deletions crates/agentdeck-gui/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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()
Expand All @@ -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())
Expand Down Expand Up @@ -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()
Expand All @@ -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())
Expand Down
28 changes: 25 additions & 3 deletions crates/agentdeck-gui/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)),
),
)
}
Expand Down Expand Up @@ -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);
Expand Down