A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
feat(desktop): put the rose in a black circle and place the Dot in logical points
Alan Buscaglia8626a7d0eca0
diff --git a/apps/desktop/README.md b/apps/desktop/README.mdindex 6e6a6fb..4147478 100644--- a/apps/desktop/README.md+++ b/apps/desktop/README.md@@ -45,7 +45,7 @@ Runtime overrides:| `GENTLE_DOT_DATA_DIR` | Data directory (default `~/.gentle-dot`) || `GENTLE_DOT_PORT` | Daemon port (default `4317`, otherwise `port` in `config.json`) |-`shortcut` in `~/.gentle-dot/config.json` changes the global shortcut (default `Alt+Space`). The Dot position is saved in `~/.gentle-dot/desktop.json`.+`shortcut` in `~/.gentle-dot/config.json` changes the global shortcut (default `Alt+Space`). The Dot position is saved in `~/.gentle-dot/desktop.json` as `dot_points`, in macOS points (the screen space every monitor shares, whatever its scale factor). The `dot` key written by older builds was in physical pixels and is ignored, so the Dot starts once more at the right edge of the main display.## Menu bardiff --git a/apps/desktop/src-tauri/src/geometry.rs b/apps/desktop/src-tauri/src/geometry.rsindex 1417e6e..c77f5ce 100644--- a/apps/desktop/src-tauri/src/geometry.rs+++ b/apps/desktop/src-tauri/src/geometry.rs@@ -1,4 +1,5 @@-//! Pure placement math for the Dot and the panel, in physical pixels.+//! Pure placement math for the Dot and the panel, in logical points: the+//! global macOS screen space that every monitor shares, whatever its scale.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub struct Rect {@@ -37,6 +38,21 @@ impl Rect {}}+/// Converts a rectangle tao reports in physical pixels back to points. Tao+/// derives each physical rectangle from points times one scale factor (a+/// monitor's own, or the window's current one), so `scale` must be that same+/// factor. Physical rectangles of monitors with different scales overlap and+/// cannot be compared; their points can.+pub fn to_points(position: (i32, i32), size: (u32, u32), scale: f64) -> Rect {+ let points = |value: f64| (value / scale).round() as i32;+ Rect::new(+ points(position.0.into()),+ points(position.1.into()),+ points(size.0.into()),+ points(size.1.into()),+ )+}+/// Keeps `[value, value + size]` inside `[start + margin, end - margin]`; when/// it cannot fit, the start wins.fn clamp_span(value: i32, size: i32, start: i32, end: i32, margin: i32) -> i32 {@@ -169,7 +185,7 @@ mod tests {assert_eq!(default_dot_position(Rect::new(1920, -200, 2560, 1440), (112, 112), 24), (4344, 464));}- /// The rose window is taller than wide: 64 × 84 pt, here at 2× scale.+ /// A window taller than wide: snapping must use its real size, whatever the shape.fn rose(x: i32, y: i32) -> Rect {Rect::new(x, y, 128, 168)}@@ -196,6 +212,37 @@ mod tests {assert_eq!(initial_dot_position(None, (128, 168), &[], None, 24), None);}+ #[test]+ fn converts_each_rectangle_with_its_own_scale_factor() {+ // A 1512 × 945 pt Retina built-in (2×) and, to its right, a 2560 × 1440 pt display at 1×.+ // Tao reports them as (0, 0, 3024, 1890) and (1512, 0, 2560, 1440): in physical pixels the+ // two monitors overlap, so only points put every monitor in one coordinate space.+ let built_in = to_points((0, 0), (3024, 1890), 2.0);+ let external = to_points((1512, 0), (2560, 1440), 1.0);+ assert_eq!(built_in, Rect::new(0, 0, 1512, 945));+ assert_eq!(external, Rect::new(1512, 0, 2560, 1440));+ // The Dot on the external display, reported with the window's own 1× factor.+ let dot = to_points((3900, 600), (72, 72), 1.0);+ assert_eq!(dot, Rect::new(3900, 600, 72, 72));+ assert_eq!(monitor_for(dot, &[built_in, external]), Some(external));+ assert_eq!(snap_to_edge(dot, &[built_in, external], 12), (3988, 600));+ // The same window on the built-in reports twice the pixels, but the same points.+ assert_eq!(to_points((2736, 1200), (144, 144), 2.0), Rect::new(1368, 600, 72, 72));+ }++ #[test]+ fn places_a_72_point_dot_12_points_from_the_edge_of_a_retina_display() {+ // 3840 × 2160 at 2× (1920 × 1080 pt) below a 25 pt menu bar, as tao reports its work area.+ let main = to_points((0, 50), (3840, 2110), 2.0);+ assert_eq!(main, Rect::new(0, 25, 1920, 1055));+ let (x, y) = initial_dot_position(None, (72, 72), &[main], Some(main), 12).unwrap();+ assert_eq!((x, y), (1836, 516));+ assert_eq!(main.right() - (x + 72), 12);+ // A saved spot is restored in points, on whichever monitor it lies.+ let built_in = to_points((3840, 0), (2560, 1600), 2.0);+ assert_eq!(initial_dot_position(Some((3116, 400)), (72, 72), &[main, built_in], Some(main), 12), Some((3116, 400)));+ }+#[test]fn panel_opens_toward_the_side_with_more_room() {assert_eq!(place_panel(dot(1852, 500), (420, 640), SCREEN, 8, 12), (1424, 208));diff --git a/apps/desktop/src-tauri/src/position.rs b/apps/desktop/src-tauri/src/position.rsindex 2aaf1fe..0a9c2d6 100644--- a/apps/desktop/src-tauri/src/position.rs+++ b/apps/desktop/src-tauri/src/position.rs@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};use std::io;use std::path::Path;-/// Top-left corner of the Dot window, in physical pixels.+/// Top-left corner of the Dot window, in logical points.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]pub struct DotPosition {pub x: i32,@@ -13,20 +13,21 @@ pub struct DotPosition {#[derive(Debug, Default, Serialize, Deserialize)]struct DesktopState {- dot: Option<DotPosition>,+ /// Older builds saved `dot` in physical pixels; that key is ignored.+ dot_points: Option<DotPosition>,}/// The saved position, or `None` when the file is missing or unreadable.pub fn load(path: &Path) -> Option<DotPosition> {let text = std::fs::read_to_string(path).ok()?;- serde_json::from_str::<DesktopState>(&text).ok()?.dot+ serde_json::from_str::<DesktopState>(&text).ok()?.dot_points}pub fn save(path: &Path, position: DotPosition) -> io::Result<()> {if let Some(dir) = path.parent() {std::fs::create_dir_all(dir)?;}- let state = DesktopState { dot: Some(position) };+ let state = DesktopState { dot_points: Some(position) };let json = serde_json::to_string_pretty(&state).map_err(io::Error::other)?;std::fs::write(path, json + "\n")}@@ -51,7 +52,15 @@ mod tests {save(&file, DotPosition { x: 1852, y: 12 }).unwrap();assert_eq!(load(&file), Some(DotPosition { x: 1852, y: 12 }));let json: serde_json::Value = serde_json::from_str(&fs::read_to_string(&file).unwrap()).unwrap();- assert_eq!(json["dot"]["x"], 1852);+ assert_eq!(json["dot_points"]["x"], 1852);+ }++ #[test]+ fn ignores_positions_saved_in_physical_pixels() {+ // Older builds saved `dot` in physical pixels; read as points it would be off screen.+ let file = scratch("legacy").join("desktop.json");+ fs::write(&file, r#"{ "dot": { "x": 3688, "y": 1036 } }"#).unwrap();+ assert_eq!(load(&file), None);}#[test]@@ -62,7 +71,7 @@ mod tests {#[test]fn corrupt_file_yields_none() {let dir = scratch("corrupt");- for (name, body) in [("garbage.json", "{ nope"), ("wrong.json", r#"{ "dot": { "x": "a" } }"#), ("empty.json", "{}")] {+ for (name, body) in [("garbage.json", "{ nope"), ("wrong.json", r#"{ "dot_points": { "x": "a" } }"#), ("empty.json", "{}")] {let file = dir.join(name);fs::write(&file, body).unwrap();assert_eq!(load(&file), None, "{name}");diff --git a/apps/desktop/src-tauri/src/shell.rs b/apps/desktop/src-tauri/src/shell.rsindex 9ef3a70..514cff8 100644--- a/apps/desktop/src-tauri/src/shell.rs+++ b/apps/desktop/src-tauri/src/shell.rs@@ -14,8 +14,8 @@ use tauri::menu::{CheckMenuItem, Menu, MenuItem, PredefinedMenuItem};use tauri::tray::{TrayIcon, TrayIconBuilder};use tauri::window::{Effect, EffectState, EffectsBuilder};use tauri::{- AppHandle, Emitter, Manager, PhysicalPosition, RunEvent, WebviewUrl, WebviewWindow, WebviewWindowBuilder,- WindowEvent,+ AppHandle, Emitter, LogicalPosition, LogicalSize, Manager, RunEvent, WebviewUrl, WebviewWindow,+ WebviewWindowBuilder, WindowEvent,};use tauri_plugin_autostart::{MacosLauncher, ManagerExt as _};use tauri_plugin_dialog::{DialogExt, MessageDialogKind};@@ -25,11 +25,13 @@ use tauri_plugin_opener::OpenerExt;const DOT: &str = "dot";const PANEL: &str = "panel";const TRAY: &str = "main";-/// The rose window, in logical pixels: the rose's aspect (860 × 1130 crop).-const DOT_SIZE: (f64, f64) = (64.0, 84.0);+/// The Dot window, in points: a 66 pt black disc with the rose, plus a 3 pt+/// ring for its shadow. About the screen area of the earlier 64 × 84 rose.+const DOT_SIZE: (f64, f64) = (72.0, 72.0);const PANEL_SIZE: (f64, f64) = (420.0, 640.0);-const EDGE_MARGIN: f64 = 12.0;-const PANEL_GAP: f64 = 8.0;+/// All placement runs in points (see `geometry`), so margins never depend on a scale factor.+const EDGE_MARGIN: i32 = 12;+const PANEL_GAP: i32 = 8;const DRAG_SETTLE: Duration = Duration::from_millis(300);const DAEMON_START_TIMEOUT: Duration = Duration::from_secs(20);@@ -92,26 +94,38 @@ fn set_dot_state(app: AppHandle, state: String) -> CommandResult {tray.set_icon_as_template(true).map_err(err)}+/// The window frame in points. Tao reports it in pixels of the window's current scale factor.fn rect_of(window: &WebviewWindow) -> CommandResult<Rect> {let position = window.outer_position().map_err(err)?;let size = window.outer_size().map_err(err)?;- Ok(Rect::new(position.x, position.y, size.width as i32, size.height as i32))+ let scale = window.scale_factor().map_err(err)?;+ Ok(geometry::to_points((position.x, position.y), (size.width, size.height), scale))+}++/// Work area (without menu bar and Dock) of a monitor in points, using that monitor's own scale factor.+fn work_area(monitor: &tauri::Monitor) -> Rect {+ let area = monitor.work_area();+ geometry::to_points(+ (area.position.x, area.position.y),+ (area.size.width, area.size.height),+ monitor.scale_factor(),+ )}-/// Work areas (without menu bar and Dock) of every monitor, in physical pixels.fn monitor_rects(window: &WebviewWindow) -> CommandResult<Vec<Rect>> {- let monitors = window.available_monitors().map_err(err)?;- Ok(monitors- .iter()- .map(|m| {- let area = m.work_area();- Rect::new(area.position.x, area.position.y, area.size.width as i32, area.size.height as i32)- })- .collect())+ Ok(window.available_monitors().map_err(err)?.iter().map(work_area).collect())+}++fn move_to(window: &WebviewWindow, (x, y): (i32, i32)) -> CommandResult {+ window.set_position(LogicalPosition::new(f64::from(x), f64::from(y))).map_err(err)}-fn scaled(window: &WebviewWindow, logical: f64) -> i32 {- (logical * window.scale_factor().unwrap_or(1.0)).round() as i32+/// Keeps the Dot at exactly `DOT_SIZE` points, in case macOS or a monitor change resized it.+fn keep_dot_size(dot: &WebviewWindow, current: Rect) -> CommandResult {+ if (current.width, current.height) == (DOT_SIZE.0 as i32, DOT_SIZE.1 as i32) {+ return Ok(());+ }+ dot.set_size(LogicalSize::new(DOT_SIZE.0, DOT_SIZE.1)).map_err(err)}fn place_panel_next_to_dot(app: &AppHandle) -> CommandResult {@@ -120,15 +134,9 @@ fn place_panel_next_to_dot(app: &AppHandle) -> CommandResult {let Some(monitor) = geometry::monitor_for(dot_rect, &monitor_rects(&dot)?) else {return Ok(());};- let size = panel.outer_size().map_err(err)?;- let (x, y) = geometry::place_panel(- dot_rect,- (size.width as i32, size.height as i32),- monitor,- scaled(&dot, PANEL_GAP),- scaled(&dot, EDGE_MARGIN),- );- panel.set_position(PhysicalPosition::new(x, y)).map_err(err)+ let size = rect_of(&panel)?;+ let position = geometry::place_panel(dot_rect, (size.width, size.height), monitor, PANEL_GAP, EDGE_MARGIN);+ move_to(&panel, position)}fn show_panel(app: &AppHandle) -> CommandResult {@@ -142,10 +150,12 @@ fn show_panel(app: &AppHandle) -> CommandResult {/// Snaps the Dot to the nearest edge and persists the position.fn snap_dot(app: &AppHandle) -> CommandResult {let dot = window(app, DOT)?;- let current = rect_of(&dot)?;- let (x, y) = geometry::snap_to_edge(current, &monitor_rects(&dot)?, scaled(&dot, EDGE_MARGIN));+ let mut current = rect_of(&dot)?;+ keep_dot_size(&dot, current)?;+ (current.width, current.height) = (DOT_SIZE.0 as i32, DOT_SIZE.1 as i32);+ let (x, y) = geometry::snap_to_edge(current, &monitor_rects(&dot)?, EDGE_MARGIN);if (x, y) != (current.x, current.y) {- dot.set_position(PhysicalPosition::new(x, y)).map_err(err)?;+ move_to(&dot, (x, y))?;}let shell = app.state::<Shell>();position::save(&shell.config.data_dir.join("desktop.json"), DotPosition { x, y }).map_err(err)?;@@ -203,19 +213,17 @@ fn build_windows(app: &AppHandle, config: &DesktopConfig) -> tauri::Result<()> {// Restore the saved position (re-snapped in case the monitors changed), or// default to the right edge of the primary monitor, vertically centered.+ // Everything is in points: before it is shown, the window may sit on a+ // monitor with another scale factor than the one it is moved to.let monitors = monitor_rects(&dot).unwrap_or_default();- // The real window size, so a tall rose snapped to the bottom edge stays fully on screen.- let fallback = (scaled(&dot, DOT_SIZE.0), scaled(&dot, DOT_SIZE.1));- let size = rect_of(&dot).map(|r| (r.width, r.height)).unwrap_or(fallback);- let primary = app.primary_monitor()?.map(|m| {- let area = m.work_area();- Rect::new(area.position.x, area.position.y, area.size.width as i32, area.size.height as i32)- });+ let size = (DOT_SIZE.0 as i32, DOT_SIZE.1 as i32);+ let primary = app.primary_monitor()?.as_ref().map(work_area);let saved = position::load(&config.data_dir.join("desktop.json")).map(|p| (p.x, p.y));- let target = geometry::initial_dot_position(saved, size, &monitors, primary, scaled(&dot, EDGE_MARGIN));- if let Some((x, y)) = target {- dot.set_position(PhysicalPosition::new(x, y))?;+ if let Some((x, y)) = geometry::initial_dot_position(saved, size, &monitors, primary, EDGE_MARGIN) {+ dot.set_position(LogicalPosition::new(f64::from(x), f64::from(y)))?;}+ // Set the size again once the window is in place, so it is exactly DOT_SIZE points there.+ dot.set_size(LogicalSize::new(DOT_SIZE.0, DOT_SIZE.1))?;dot.show()?;Ok(())}@@ -348,7 +356,8 @@ pub fn run() {let snap = app.state::<Shell>().snap.clone();window(&handle, DOT)?.on_window_event(move |event| {- if let WindowEvent::Moved(_) = event {+ // A move, or a new monitor scale, re-snaps the Dot and restores its size.+ if let WindowEvent::Moved(_) | WindowEvent::ScaleFactorChanged { .. } = event {let _ = snap.send(());}});diff --git a/packages/ui/src/components/DotSurface.tsx b/packages/ui/src/components/DotSurface.tsxindex b0f3a78..6715c63 100644--- a/packages/ui/src/components/DotSurface.tsx+++ b/packages/ui/src/components/DotSurface.tsx@@ -31,7 +31,7 @@ interface DotSurfaceProps {startDrag: () => void;}-/** The collapsed, always-on-top rose. A click opens the panel; a drag moves the window. */+/** The collapsed, always-on-top rose in its black circle. A click opens the panel; a drag moves the window. */export function DotSurface({ agentState, connected, toggle, startDrag }: DotSurfaceProps) {const press = useRef<{ x: number; y: number; dragging: boolean } | undefined>(undefined);const state = connected ? agentState : "restarting";@@ -65,7 +65,9 @@ export function DotSurface({ agentState, connected, toggle, startDrag }: DotSurf}}}>- <Rose mood={MOODS[state]} />+ <span className="dot-disc" aria-hidden="true">+ <Rose mood={MOODS[state]} />+ </span>{state === "needs_you" ? (<span className="dot-badge" aria-hidden="true">!diff --git a/packages/ui/src/rose/Rose.tsx b/packages/ui/src/rose/Rose.tsxindex 03940f1..5106574 100644--- a/packages/ui/src/rose/Rose.tsx+++ b/packages/ui/src/rose/Rose.tsx@@ -1,14 +1,22 @@import type { CSSProperties } from "react";-import { ROSE_SPARKLES, ROSE_STROKES, ROSE_VIEWBOX } from "./strokes.ts";+import { ROSE_SPARKLES, ROSE_STROKES } from "./strokes.ts";/** How the rose looks (design sheet `docs/brand/rose-design.html`). */export type RoseMood = "idle" | "thinking" | "working" | "needs" | "restarting" | "offline";/**- * Strokes that carry the traveling light. In the 64 px Dot one screen pixel is- * about 13 source pixels, so only the 60 longest strokes (50 source px and up,- * 57% of the drawing) are long enough to show a moving light; the rest would- * flicker as dots. The outline always draws all 178 strokes, which stay static.+ * The square crop that frames the rose in the Dot's circle: centered on the+ * strokes' smallest enclosing circle (center 610, 598; radius 493 source px)+ * with a small gap to the rim. In the 66 px disc one screen pixel is about 16+ * source pixels.+ */+export const ROSE_DISC_VIEWBOX = "90 78 1040 1040";++/**+ * Strokes that carry the traveling light. At the Dot's size only the 60+ * longest strokes (50 source px and up, 57% of the drawing) are long enough to+ * show a moving light; the rest would flicker as dots. The outline always+ * draws all 178 strokes, which stay static.*/export const DOT_LIGHT_STROKES = 60;@@ -34,13 +42,13 @@ const sparkles = ROSE_SPARKLES.map(([cx, cy, r], i) => (export function Rose({ mood }: { mood: RoseMood }) {return (<span className={`rose rose-${mood}`} aria-hidden="true">- <svg className="rose-base" viewBox={ROSE_VIEWBOX} aria-hidden="true" focusable="false">+ <svg className="rose-base" viewBox={ROSE_DISC_VIEWBOX} aria-hidden="true" focusable="false">{outline}</svg>- <svg className="rose-light" viewBox={ROSE_VIEWBOX} aria-hidden="true" focusable="false">+ <svg className="rose-light" viewBox={ROSE_DISC_VIEWBOX} aria-hidden="true" focusable="false">{lights}</svg>- <svg className="rose-sparkles" viewBox={ROSE_VIEWBOX} aria-hidden="true" focusable="false">+ <svg className="rose-sparkles" viewBox={ROSE_DISC_VIEWBOX} aria-hidden="true" focusable="false">{sparkles}</svg></span>diff --git a/packages/ui/src/styles.css b/packages/ui/src/styles.cssindex cef0b16..2a90896 100644--- a/packages/ui/src/styles.css+++ b/packages/ui/src/styles.css@@ -104,19 +104,20 @@ button.icon {outline-offset: 2px;}-/* ---------- Dot: the rose (docs/brand/rose-design.html) ---------- */+/* ---------- Dot: the rose in a black circle (docs/brand/rose-design.html) ---------- */+/* The window is this square (DOT_SIZE in shell.rs); outside the disc it stays transparent. */.dot {--neon: #ff2d7a;--neon-soft: rgba(255, 45, 122, 0.35);--core: #ffd6e8;position: relative;display: block;- width: 64px;- height: 84px;+ width: 72px;+ height: 72px;padding: 0;border: none;- border-radius: 14px;+ border-radius: 50%;background: none;user-select: none;-webkit-user-select: none;@@ -130,7 +131,48 @@ button.icon {outline-offset: -2px;}-/* No circle and no box: the strokes are the rose, and they carry the glow. */+/* The black disc, as on the app icon: a near-black radial fill with a faint pink rim.+ The 3 px inset leaves room for its outer shadow inside the window. The rim carries a+ subtle state cue; the glow and the traveling light stay on the rose's strokes. */+.dot-disc {+ --rim: rgba(255, 45, 122, 0.22);+ --rim-glow: rgba(255, 45, 122, 0);+ position: absolute;+ inset: 3px;+ border-radius: 50%;+ background: radial-gradient(circle at 50% 40%, #1a0a12, #050506 75%);+ box-shadow:+ 0 1px 2px rgba(0, 0, 0, 0.6),+ 0 0 1px rgba(0, 0, 0, 0.5),+ inset 0 1px 0 rgba(255, 255, 255, 0.07),+ inset 0 0 0 1px var(--rim),+ inset 0 0 6px var(--rim-glow);+ transition: box-shadow 400ms var(--ease);+}++.dot-thinking .dot-disc {+ --rim: rgba(255, 45, 122, 0.32);+}++.dot-working .dot-disc {+ --rim: rgba(255, 45, 122, 0.45);+ --rim-glow: rgba(255, 45, 122, 0.22);+}++.dot-needs_you .dot-disc {+ --rim: rgba(245, 165, 36, 0.55);+ --rim-glow: rgba(245, 165, 36, 0.2);+}++.dot-starting .dot-disc,+.dot-restarting .dot-disc {+ --rim: rgba(255, 255, 255, 0.1);+}++.dot-error .dot-disc {+ --rim: rgba(255, 255, 255, 0.06);+}+.rose {position: relative;display: block;@@ -271,10 +313,11 @@ button.icon {filter: none;}+/* On the circle's edge, at the top right. */.dot-badge {position: absolute;- top: 2px;- right: 2px;+ top: 4px;+ right: 4px;width: 16px;height: 16px;border-radius: 50%;@@ -284,11 +327,13 @@ button.icon {font-weight: 800;line-height: 16px;text-align: center;- box-shadow: 0 0 6px rgba(245, 165, 36, 0.7);+ box-shadow:+ 0 0 0 1.5px #050506,+ 0 0 4px rgba(245, 165, 36, 0.7);}/* Reduce motion: no traveling light (frozen dashes would look broken); the glow stays, stronger when busy.- Glow radii stay small because the window is only a few pixels larger than the rose. */+ Glow radii stay small so the glow stays inside the disc. */@media (prefers-reduced-motion: reduce) {.rose-light {display: none;diff --git a/packages/ui/test/dot.test.tsx b/packages/ui/test/dot.test.tsxindex ecb681e..3527949 100644--- a/packages/ui/test/dot.test.tsx+++ b/packages/ui/test/dot.test.tsx@@ -1,8 +1,10 @@+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";import type { AgentState } from "@gentle-dot/protocol";import { fireEvent, render, screen } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";import { DotSurface } from "../src/components/DotSurface.tsx";-import { DOT_LIGHT_STROKES } from "../src/rose/Rose.tsx";+import { DOT_LIGHT_STROKES, ROSE_DISC_VIEWBOX } from "../src/rose/Rose.tsx";import { ROSE_SPARKLES, ROSE_STROKES } from "../src/rose/strokes.ts";function setup(agentState: AgentState = "idle", connected = true) {@@ -40,20 +42,25 @@ describe("DotSurface", () => {const { dot } = setup("needs_you");expect(dot).toHaveAccessibleName("Gentle Dot: needs your answer");expect(dot).toHaveClass("dot-needs_you");- expect(screen.getByText("!")).toBeInTheDocument();+ // The badge sits on the circle's edge, outside the disc.+ expect(dot.querySelector(":scope > .dot-badge")).toHaveTextContent("!");});- it("is the rose itself: traced strokes, a light layer, and sparkles, with no orb", () => {+ it("is the glowing rose inside a black disc", () => {const { dot } = setup();- const rose = dot.querySelector(".rose");+ const rose = dot.querySelector(":scope > .dot-disc > .rose");expect(rose).not.toBeNull();+ expect(dot.querySelector(".dot-disc")).toHaveAttribute("aria-hidden", "true");expect(rose).toHaveAttribute("aria-hidden", "true");- expect(dot.querySelector(".dot-core, .dot-orbit")).toBeNull();- // Three stacked SVG layers; each carries its own glow (see Rose.tsx).- expect(- [...(rose?.querySelectorAll(":scope > svg") ?? [])].map((svg) => svg.getAttribute("class")),- ).toEqual(["rose-base", "rose-light", "rose-sparkles"]);+ // Three stacked SVG layers, each with its own glow (see Rose.tsx), framed for the disc.+ const layers = [...(rose?.querySelectorAll(":scope > svg") ?? [])];+ expect(layers.map((svg) => svg.getAttribute("class"))).toEqual([+ "rose-base",+ "rose-light",+ "rose-sparkles",+ ]);+ for (const svg of layers) expect(svg).toHaveAttribute("viewBox", ROSE_DISC_VIEWBOX);const base = [...(rose?.querySelectorAll(".rose-base path") ?? [])];const light = [...(rose?.querySelectorAll(".rose-light path") ?? [])];expect(base).toHaveLength(ROSE_STROKES.length);@@ -66,6 +73,35 @@ describe("DotSurface", () => {expect(rose?.querySelectorAll(".rose-sparkles circle")).toHaveLength(ROSE_SPARKLES.length);});+ it("frames the whole rose inside the circle", () => {+ const [x, y, width, height] = ROSE_DISC_VIEWBOX.split(" ").map(Number) as [+ number,+ number,+ number,+ number,+ ];+ expect(width).toBe(height);+ const [cx, cy, radius] = [x + width / 2, y + height / 2, width / 2];+ const points = ROSE_STROKES.flatMap(({ d }) =>+ [...d.matchAll(/(-?[\d.]+) (-?[\d.]+)/g)].map((m) => [Number(m[1]), Number(m[2]), 0]),+ );+ for (const [px, py, r] of [...points, ...ROSE_SPARKLES]) {+ expect(Math.hypot(px - cx, py - cy) + r).toBeLessThan(radius);+ }+ });++ it("keeps the Dot surface the same size as its window", () => {+ const read = (relative: string) =>+ readFileSync(fileURLToPath(new URL(relative, import.meta.url)), "utf8");+ const rule = read("../src/styles.css").match(/\n\.dot \{([^}]*)\}/)?.[1] ?? "";+ const window = read("../../../apps/desktop/src-tauri/src/shell.rs").match(+ /const DOT_SIZE: \(f64, f64\) = \(([\d.]+), ([\d.]+)\)/,+ );+ expect(window?.slice(1).map(Number)).toEqual([72, 72]);+ expect(rule).toMatch(/\twidth: 72px;/);+ expect(rule).toMatch(/\theight: 72px;/);+ });+it.each<[AgentState, string, string]>([["starting", "rose-restarting", "starting"],["idle", "rose-idle", "ready"],