diff --git a/apps/maple-agent/app/locales/de/app.ftl b/apps/maple-agent/app/locales/de/app.ftl index 3d38f3e8b..fc7f2049f 100644 --- a/apps/maple-agent/app/locales/de/app.ftl +++ b/apps/maple-agent/app/locales/de/app.ftl @@ -1652,6 +1652,11 @@ chat-connecting = Verbindung wird hergestellt… chat-offline = Offline chat-project-options = Projektoptionen chat-task-options = Aufgabenoptionen +chat-task-running = Läuft +chat-task-needs-you = Wartet auf deine Antwort +chat-task-failed = Letzter Lauf fehlgeschlagen +chat-task-finished-unseen = Fertig, noch nicht geöffnet +chat-task-status-details = { $status }. { $details } chat-more = Mehr chat-rename = Umbenennen chat-unpin = Anheftung lösen diff --git a/apps/maple-agent/app/locales/en/app.ftl b/apps/maple-agent/app/locales/en/app.ftl index 5cdced0e0..84e7d79af 100644 --- a/apps/maple-agent/app/locales/en/app.ftl +++ b/apps/maple-agent/app/locales/en/app.ftl @@ -1652,6 +1652,12 @@ chat-connecting = Connecting… chat-offline = Offline chat-project-options = Project options chat-task-options = Task options +chat-task-running = Running +chat-task-needs-you = Waiting for your answer +chat-task-failed = Last run failed +chat-task-finished-unseen = Finished, not opened yet +# $status is one of the task status labels above; $details is the task's project and computer names, not translated. +chat-task-status-details = { $status }. { $details } chat-more = More chat-rename = Rename chat-unpin = Unpin diff --git a/apps/maple-agent/app/locales/es/app.ftl b/apps/maple-agent/app/locales/es/app.ftl index d1ed75bfe..b7069016e 100644 --- a/apps/maple-agent/app/locales/es/app.ftl +++ b/apps/maple-agent/app/locales/es/app.ftl @@ -1537,6 +1537,11 @@ chat-connecting = Conectando… chat-offline = Sin conexión chat-project-options = Opciones de proyecto chat-task-options = Opciones de tarea +chat-task-running = En curso +chat-task-needs-you = Esperando tu respuesta +chat-task-failed = La última ejecución falló +chat-task-finished-unseen = Terminó, aún sin abrir +chat-task-status-details = { $status }. { $details } chat-more = Más chat-rename = Cambiar nombre chat-unpin = Desfijar diff --git a/apps/maple-agent/app/locales/ko/app.ftl b/apps/maple-agent/app/locales/ko/app.ftl index bffa581fe..27e9dc52b 100644 --- a/apps/maple-agent/app/locales/ko/app.ftl +++ b/apps/maple-agent/app/locales/ko/app.ftl @@ -1598,6 +1598,11 @@ chat-connecting = 연결하는 중… chat-offline = 오프라인 chat-project-options = 프로젝트 옵션 chat-task-options = 작업 옵션 +chat-task-running = 실행 중 +chat-task-needs-you = 답변을 기다리는 중 +chat-task-failed = 마지막 실행 실패 +chat-task-finished-unseen = 완료됨, 아직 열지 않음 +chat-task-status-details = { $status }. { $details } chat-more = 더 보기 chat-rename = 이름 변경 chat-unpin = 고정 해제 diff --git a/apps/maple-agent/app/src/ui/chat/sidebar.rs b/apps/maple-agent/app/src/ui/chat/sidebar.rs index 1a2919305..09f4a2865 100644 --- a/apps/maple-agent/app/src/ui/chat/sidebar.rs +++ b/apps/maple-agent/app/src/ui/chat/sidebar.rs @@ -78,7 +78,6 @@ pub(crate) struct BrowseState { use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use std::time::Duration; use gpui::{ AnyElement, AppContext, Context, Div, Entity, EventEmitter, Focusable, SharedString, @@ -95,6 +94,7 @@ use crate::backend::AgentBackend; use crate::settings::{SidebarGroup, SidebarItemKey, SidebarOrder, SidebarSort, SidebarView}; use crate::ui::i18n::{MessageCache, UiText, tr, tr_args}; use crate::ui::icons::{icon, wordmark}; +use crate::ui::morph_text::morph_text; use crate::ui::motion; use crate::ui::popup::{Menu, MenuItem, Placement, Popup}; use crate::ui::text_input::TextInput; @@ -4000,6 +4000,7 @@ impl Sidebar { &root.row_group, "square-pen", tr("chat-new-task"), + false, ) .aria_label(root.new_task_label.clone()) .tooltip(widgets::tooltip(root.new_task_label.clone(), None)) @@ -4164,10 +4165,15 @@ impl Sidebar { cx: &mut Context, ) -> Div { let (pinned, rung) = state; + // The menu opens below the row and takes the pointer's hover with + // it; the strip keeps its fill so the open button still covers the + // title, as a project header's does. + let open = self.popup.is_open(&target.popup_key()); let rename = target.clone(); let advance = target.clone(); let step = rung.step(); hover_actions(&row.group, hover_bg) + .when(open, |strip| strip.bg(gpui::rgb(hover_bg))) .pl_0() .when(pinned, |overlay| overlay.right(px(26.))) .when(!pinned, |overlay| overlay.right_0().rounded_r(ROW_RADIUS)) @@ -4179,6 +4185,7 @@ impl Sidebar { .bottom_0() .right_full() .w(ROW_FADE) + .when(open, |fade| fade.bg(row_fade_background(hover_bg))) .group_hover(row.group.clone(), |style| { style.bg(row_fade_background(hover_bg)) }), @@ -4261,7 +4268,12 @@ impl Sidebar { } else { theme::bg_sidebar_row_hover() }; - let row_bg = if is_selected { + // An open menu holds the row in its hover fill, as a project + // header's does, so the action strip over it never shows as a patch. + let menu_open = self.popup.is_open(&SidebarPopup::Task(row.id.clone())); + let row_bg = if menu_open { + hover_bg + } else if is_selected { theme::bg_sidebar_row_selected() } else { theme::bg_sidebar() @@ -4277,7 +4289,10 @@ impl Sidebar { .role(gpui::Role::ListBoxOption) .accessibility_id(row.id.to_string()) .aria_label(row.title.clone()) - .aria_description(row.metadata.clone()) + .when_some( + self.activity_description(activity, &row.metadata), + |row, text| row.aria_description(text), + ) .aria_selected(is_selected) .when(application_selected, |row| row.aria_active_descendant()) .group(row.group.clone()) @@ -4297,6 +4312,7 @@ impl Sidebar { // no hover actions over it, so the edit is plain to see. .hover_bg(gpui::rgb(hover_bg)) .when(renaming || self.dragging, |row| row.highlighted(false)) + .when(menu_open, |row| row.highlighted(true)) .when(!renaming && !self.dragging, |row| { row.hover(|style| style.cursor_pointer()) }) @@ -4312,9 +4328,12 @@ impl Sidebar { .flex_col() .map(|column| match rename_field { Some(field) => column.child(field), - None => { - column.child(row_line(row.title.clone(), hover_group, row_bg, hover_bg)) - } + None => column.child(row_line( + task_title(&row.title, activity == Some(SessionActivity::Running)), + hover_group, + row_bg, + hover_bg, + )), }) .when(self.show_task_metadata(is_pinned, archived), |column| { column.child( @@ -4342,8 +4361,9 @@ impl Sidebar { .items_center() .justify_center() .rounded(theme::RADIUS_SM) - .hover_bg(gpui::rgb(theme::bg_sidebar_row_selected())) + .hover_bg(theme::overlay_hover()) .hover(|style| style.cursor_pointer()) + .active(|style| style.bg(theme::overlay_press())) .tooltip(widgets::tooltip(tr("chat-unpin"), None)) .on_click(cx.listener(move |this, _event, _window, cx| { cx.stop_propagation(); @@ -4493,7 +4513,7 @@ fn one_line(text: &str) -> SharedString { /// Fade a line into its row background; renames and drags omit the hover group. fn row_line( - text: SharedString, + text: impl IntoElement, hover_group: Option<&SharedString>, row_bg: u32, hover_bg: u32, @@ -4529,23 +4549,46 @@ fn row_fade_background(color: u32) -> gpui::Background { ) } -/// One breath of the running ring's dot. -const RUNNING_BREATH: Duration = Duration::from_millis(1600); - -/// A coral dot while a question waits, a ring with a breathing dot while -/// the task runs, an alert once a run failed unseen, and a green dot once -/// one completed unseen. The two dots differ by color; the ring and the -/// alert differ by shape. The ring runs on the shared low-rate clock, so -/// any number of running rows cost one repaint per interval; `spinner_id` -/// is prebuilt so render allocates nothing. Every state sits centered in -/// one box the size of the largest, so the center stays put as states -/// change, and one state cross-fades into the next over -/// [`motion::TOGGLE`]. The box is keyed by `spinner_id`, which names the -/// task, so an indicator that first appears (a list that loads, a row that -/// scrolls in) shows its state at once. +/// The running shine's half-width, as a share of the title, and the share of +/// [`motion::RUNNING_SHINE`] it rests between passes. +const TITLE_SHINE_REACH: f32 = 0.55; +const TITLE_SHINE_REST: f32 = 0.3; + +/// A task's title. While the task runs on dark, a soft brighter band +/// crosses the words, then rests; the words keep the row's own ink, so +/// a running title reads as plainly as any other. Light has no ink +/// brighter than its text, so there the title holds still and the +/// breathing dot carries the state alone. The band holds still when +/// loops do, under reduced motion and in a background window. +fn task_title(title: &SharedString, running: bool) -> AnyElement { + if !running || theme::is_light() { + return title.clone().into_any_element(); + } + // A renamed or newly titled task swaps its words at once: a letter + // morph would break the title's shaping mid-run for nothing. + morph_text("task-title", title.clone()) + .instant(true) + .shine( + motion::RUNNING_SHINE, + gpui::rgb(theme::sidebar_running_shine()), + ) + .shine_band(TITLE_SHINE_REACH, TITLE_SHINE_REST) + .into_any_element() +} + +/// A grey dot that breathes while the task runs, an amber reply bubble +/// while a question waits (the colour of a pending state, apart from the +/// failed alert's red), an alert once a run failed unseen, and a green dot +/// once one completed unseen. The marks that ask for you are line icons +/// and the passive ones are dots, so they differ by shape and not by +/// colour alone. Every state sits centered in one box the size of the +/// largest, so the title's width stays put as states change, and one +/// state cross-fades into the next over [`motion::TOGGLE`]. The box is +/// keyed by `spinner_id`, which names the task, so an indicator that +/// first appears (a list that loads, a row that scrolls in) shows its +/// state at once. fn activity_indicator(spinner_id: &SharedString, activity: SessionActivity) -> AnyElement { - let layer = |name: &'static str, state: SessionActivity| { - let spinner_id = spinner_id.clone(); + let layer = |name: &'static str, state: SessionActivity, glyph: fn() -> AnyElement| { motion::animated( name, if activity == state { 1. } else { 0. }, @@ -4554,13 +4597,6 @@ fn activity_indicator(spinner_id: &SharedString, activity: SessionActivity) -> A if shown <= 0. { return div().into_any_element(); } - let dot = |color: u32| { - div() - .size(px(8.)) - .rounded_full() - .bg(gpui::rgb(color)) - .into_any_element() - }; div() .absolute() .inset_0() @@ -4568,53 +4604,83 @@ fn activity_indicator(spinner_id: &SharedString, activity: SessionActivity) -> A .items_center() .justify_center() .opacity(shown) - .child(match state { - SessionActivity::NeedsYou => dot(theme::accent()), - SessionActivity::Running => running_ring(spinner_id.clone()), - SessionActivity::Failed => { - icon("circle-alert", px(13.), theme::status_error()).into_any_element() - } - SessionActivity::CompletedUnread => dot(theme::status_success()), - }) + .child(glyph()) .into_any_element() }, ) }; + fn running() -> AnyElement { + motion::ticker("running-breath", motion::RUNNING_BREATH, |phase| { + let grey = gpui::rgb(theme::sidebar_running()); + // Phase 0 is the full dot, so a paused loop rests on it. + let breath = motion::pulse(phase, 0.25, 0., 1.); + div() + .size(px(8.)) + .rounded_full() + .bg(grey.alpha(0.5 + 0.5 * breath)) + .shadow(vec![ + gpui::BoxShadow::new(px(0.), px(0.), grey.alpha(0.3 * breath).into()) + .blur_radius(px(4.)), + ]) + .into_any_element() + }) + .into_any_element() + } div() .id(spinner_id.clone()) .relative() .size(px(13.)) .flex_none() - .child(layer("needs-you", SessionActivity::NeedsYou)) - .child(layer("running", SessionActivity::Running)) - .child(layer("failed", SessionActivity::Failed)) - .child(layer("completed", SessionActivity::CompletedUnread)) + .child(layer("running", SessionActivity::Running, running)) + .child(layer("needs-you", SessionActivity::NeedsYou, || { + icon("message-square", px(13.), theme::status_warning()).into_any_element() + })) + .child(layer("failed", SessionActivity::Failed, || { + icon("circle-alert", px(13.), theme::status_error()).into_any_element() + })) + .child(layer("completed", SessionActivity::CompletedUnread, || { + div() + .size(px(8.)) + .rounded_full() + .bg(gpui::rgb(theme::sidebar_finished())) + .into_any_element() + })) .into_any_element() } -/// The running state: a coral ring whose center dot fades in and out. A -/// fade reads as smooth at the shared clock's low frame rate, where a -/// turning arc steps visibly. -fn running_ring(id: SharedString) -> AnyElement { - motion::ticker(id, RUNNING_BREATH, |phase| { - div() - .size(px(12.)) - .flex() - .items_center() - .justify_center() - .rounded_full() - .border_1() - .border_color(gpui::rgb(theme::accent())) - .child( - div() - .size(px(6.)) - .rounded_full() - .bg(gpui::rgb(theme::accent())) - .opacity(motion::pulse(phase, 0., 0.3, 1.)), +impl Sidebar { + /// A task row's accessibility description: its status, which the + /// indicator and the title's shine only show, ahead of its project + /// details. Nothing when there is neither. Rows render on every shine + /// frame, so a cache hit borrows the details and allocates nothing. + pub(super) fn activity_description( + &self, + activity: Option, + details: &SharedString, + ) -> Option { + let Some(activity) = activity else { + return (!details.is_empty()).then(|| details.clone()); + }; + let key = match activity { + SessionActivity::Running => "chat-task-running", + SessionActivity::NeedsYou => "chat-task-needs-you", + SessionActivity::Failed => "chat-task-failed", + SessionActivity::CompletedUnread => "chat-task-finished-unseen", + }; + if details.is_empty() { + return Some(tr(key)); + } + Some(self.messages.computed(key, details, || { + let status = tr(key); + tr_args( + "chat-task-status-details", + [ + ("status", status.as_ref().into()), + ("details", details.as_ref().into()), + ], ) - .into_any_element() - }) - .into_any_element() + })) + } } /// The strip over a row's end that holds its hover buttons, with the @@ -4640,7 +4706,7 @@ pub(super) fn row_action( on_click: impl Fn(&gpui::ClickEvent, &mut Window, &mut gpui::App) + 'static, ) -> crate::ui::motion::HoverBackground { let label = label.into(); - row_button(id, group, icon_name, label.clone()) + row_button(id, group, icon_name, label.clone(), false) .tooltip(widgets::tooltip(label, None)) .on_click(on_click) } @@ -4654,11 +4720,7 @@ fn row_menu_button( open: bool, ) -> crate::ui::motion::HoverBackground { let label = label.into(); - row_button(id, group, "ellipsis", label).when(open, |button| { - button - .opacity(1.) - .bg(gpui::rgb(theme::bg_sidebar_row_selected())) - }) + row_button(id, group, "ellipsis", label, open).when(open, |button| button.opacity(1.)) } /// An icon button of the Projects header. It stays pressed, without its @@ -4692,11 +4754,16 @@ fn header_button( } /// The small icon button a sidebar row shows while it is hovered. +/// `pressed` holds it in its press fill, under the pointer too, while its +/// menu is open. Its fills are overlays, not solid colours: the row +/// beneath may be resting, hovered, selected or both, and a hover and a +/// press must read past each of them. fn row_button( id: SharedString, group: &SharedString, icon_name: &'static str, label: impl Into, + pressed: bool, ) -> crate::ui::motion::HoverBackground { let label = label.into(); div() @@ -4712,9 +4779,14 @@ fn row_button( .rounded(theme::RADIUS_SM) .opacity(0.) .group_hover(group.clone(), |style| style.opacity(1.)) - .hover_bg(gpui::rgb(theme::bg_sidebar_row_selected())) + .when(pressed, |button| button.bg(theme::overlay_press())) + .hover_bg(if pressed { + theme::overlay_press() + } else { + theme::overlay_hover() + }) .hover(|style| style.cursor_pointer()) - .active(|style| style.bg(gpui::rgb(theme::border()))) + .active(|style| style.bg(theme::overlay_press())) .child(icon(icon_name, px(14.), theme::text_secondary())) } diff --git a/apps/maple-agent/app/src/ui/chat/sidebar_computers.rs b/apps/maple-agent/app/src/ui/chat/sidebar_computers.rs index 16d31669d..d5f32ef3a 100644 --- a/apps/maple-agent/app/src/ui/chat/sidebar_computers.rs +++ b/apps/maple-agent/app/src/ui/chat/sidebar_computers.rs @@ -2446,7 +2446,13 @@ impl Sidebar { let rename_field = self.other_task_rename_field(&task.target, cx); let renaming = rename_field.is_some(); let pin_target = TaskTarget::Other(task.target.clone()); - let row_bg = if selected { + // An open menu holds the row in its hover fill. + let menu_open = self + .popup + .is_open(&SidebarPopup::OtherTask(task.target.clone())); + let row_bg = if menu_open { + hover_bg + } else if selected { theme::bg_sidebar_row_hover() } else { theme::bg_sidebar() @@ -2459,6 +2465,10 @@ impl Sidebar { .group(task.id.clone()) .role(gpui::Role::ListBoxOption) .aria_label(task.title.clone()) + .when_some( + self.activity_description(task.activity, &task.metadata), + |row, text| row.aria_description(text), + ) .aria_selected(false) .mx_2() .my(px(1.)) @@ -2477,6 +2487,7 @@ impl Sidebar { }) .hover_bg(gpui::rgb(hover_bg)) .when(dragging || renaming, |row| row.highlighted(false)) + .when(menu_open, |row| row.highlighted(true)) .when(!(dragging || renaming), |row| { row.hover(|style| style.cursor_pointer()) }) @@ -2492,7 +2503,10 @@ impl Sidebar { .map(|column| match rename_field { Some(field) => column.child(field), None => column.child(row_line( - task.title.clone(), + task_title( + &task.title, + task.activity == Some(SessionActivity::Running), + ), hover_group, row_bg, hover_bg, @@ -2516,6 +2530,7 @@ impl Sidebar { &task.row.group, "pin", tr("chat-unpin-task"), + false, ) .opacity(1.) .tooltip(widgets::tooltip(tr("chat-unpin"), None)) diff --git a/apps/maple-agent/app/src/ui/morph_text.rs b/apps/maple-agent/app/src/ui/morph_text.rs index dc7b43ff5..fd3cef56d 100644 --- a/apps/maple-agent/app/src/ui/morph_text.rs +++ b/apps/maple-agent/app/src/ui/morph_text.rs @@ -7,6 +7,9 @@ //! One shaping per change and one tiny shaped run per letter per frame, //! only while a morph runs; at rest it paints a single line and asks for no //! frames. Reduced motion swaps the text at once. +//! +//! Text that reports work in progress can also carry a shine: a band of a +//! second colour that crosses the words on the shared loop clock. use std::time::{Duration, Instant}; @@ -25,6 +28,26 @@ pub struct MorphText { text: SharedString, color: Option, instant: bool, + shine: Option<(Duration, Hsla)>, + shine_band: ShineBand, +} + +/// How wide the shine's band is and how long it rests between passes. +#[derive(Clone, Copy)] +struct ShineBand { + /// The band's half-width, as a fraction of the line. + reach: f32, + /// The share of each cycle the band spends off the line. + rest: f32, +} + +impl Default for ShineBand { + fn default() -> Self { + Self { + reach: 0.3, + rest: 0., + } + } } /// Morphing text in the surrounding text style; `id` keeps its state @@ -35,6 +58,8 @@ pub fn morph_text(id: impl Into, text: impl Into) -> Mo text: text.into(), color: None, instant: false, + shine: None, + shine_band: ShineBand::default(), } } @@ -53,6 +78,39 @@ impl MorphText { self.instant = instant; self } + + /// Sweep a band of `color` across the words once every `cycle`. It + /// holds still when loops do: under reduced motion, and in a window + /// that is not active. + pub fn shine(mut self, cycle: Duration, color: impl Into) -> Self { + self.shine = Some((cycle, color.into())); + self + } + + /// Shape the shine: a band `reach` of the line wide on each side of + /// its centre, crossing in the first `1 - rest` of each cycle and + /// resting off the line for the remainder. Without it the band is 0.3 + /// of the line wide and crosses without a rest. + pub fn shine_band(mut self, reach: f32, rest: f32) -> Self { + self.shine_band = ShineBand { + reach: reach.max(0.01), + rest: rest.clamp(0., 0.95), + }; + self + } +} + +/// How much of the shine a letter `at` of the way along the line takes +/// when the cycle is `phase` of the way through. +fn shine_level(at: f32, phase: f32, band: ShineBand) -> f32 { + let pass = phase / (1. - band.rest); + if pass >= 1. { + return 0.; + } + // The band enters and leaves past the ends of the line, so it is + // off the line at both ends of its pass and a rest adds no snap. + let head = -band.reach + pass * (1. + 2. * band.reach); + crate::ui::motion::smoothstep((1. - (at - head).abs() / band.reach).max(0.)) } /// One letter and where it sits from the line's start. @@ -295,32 +353,54 @@ impl Element for MorphText { let font_size = style.font_size.to_pixels(rem); let line_height = style.line_height_in_pixels(rem); let fallback = style.color; + // Where the band is this frame, while loops run. + let shine = self + .shine + .filter(|_| !crate::ui::motion::loops_paused(window, cx)) + .map(|(cycle, color)| (crate::ui::motion::phase(cycle), color)); + let band = self.shine_band; + // While the band rests off the line the text paints as one plain + // run; the loop clock keeps ticking so the next pass still starts. + let passing = shine.filter(|(phase, _)| *phase < 1. - band.rest); let animating = window.with_element_state::(id, |state, window| { let state = state.unwrap_or_default(); let progress = state.progress(Instant::now()); let eased = progress.map(ease); let color = state.visual_color(eased, fallback); + // A letter `x` along the line takes the shine where the band is. + let tint = |x: Pixels| match passing { + Some((phase, shine)) if state.width > px(0.) => { + mix(color, shine, shine_level(x / state.width, phase, band)) + } + _ => color, + }; + let draw = |window: &mut Window, + cx: &mut App, + text: &SharedString, + runs: &[gpui::TextRun], + x, + y| { + window + .text_system() + .shape_line(text.clone(), font_size, runs, None) + .paint( + point(bounds.left() + x, bounds.top() + y), + line_height, + TextAlign::Left, + None, + window, + cx, + ) + .ok(); + }; let paint = |window: &mut Window, cx: &mut App, text: &SharedString, x, y, alpha: f32| { if alpha <= 0. { return; } let mut run = style.to_run(text.len()); - run.color = color.opacity(alpha); - let shaped = - window - .text_system() - .shape_line(text.clone(), font_size, &[run], None); - shaped - .paint( - point(bounds.left() + x, bounds.top() + y), - line_height, - TextAlign::Left, - None, - window, - cx, - ) - .ok(); + run.color = tint(x).opacity(alpha); + draw(window, cx, text, &[run], x, y); }; match (progress, &state.morph) { (Some(t), Some(morph)) if t < 1. => { @@ -349,6 +429,41 @@ impl Element for MorphText { } (true, state) } + _ if passing.is_some() => { + // The resting line's one layout, each glyph painted in + // its own tint. A text run per colour would split the + // shaping wherever the colour changes, so letters lose + // their kerning, and shift, as the band passes. + let layout = window.text_system().layout_line( + &state.text, + font_size, + &[style.to_run(state.text.len())], + None, + ); + let padding_top = (line_height - layout.ascent - layout.descent) / 2.; + let baseline = point(bounds.left(), bounds.top() + padding_top + layout.ascent); + for run in &layout.runs { + for glyph in &run.glyphs { + let origin = baseline + glyph.position; + if glyph.is_emoji { + window + .paint_emoji(origin, run.font_id, glyph.id, font_size) + .ok(); + } else { + window + .paint_glyph( + origin, + run.font_id, + glyph.id, + font_size, + tint(glyph.position.x), + ) + .ok(); + } + } + } + (false, state) + } _ => { paint(window, cx, &state.text, px(0.), px(0.), 1.); (false, state) @@ -357,6 +472,8 @@ impl Element for MorphText { }); if animating { window.request_animation_frame(); + } else if shine.is_some() { + crate::ui::motion::schedule_loop_frame(window, cx); } } } @@ -390,4 +507,24 @@ mod tests { ); assert!(common_letters(&letters("Low"), &letters("Off")).is_empty()); } + + #[test] + fn a_resting_band_leaves_the_line_and_returns_without_a_snap() { + let band = ShineBand { + reach: 0.55, + rest: 0.3, + }; + // Off the whole line from the end of the pass through the rest, + // and at the start of the next pass, so the loop point is dark. + for at in [0., 0.5, 1.] { + assert_eq!(shine_level(at, 0., band), 0.); + assert_eq!(shine_level(at, 0.7, band), 0.); + assert_eq!(shine_level(at, 0.85, band), 0.); + assert!(shine_level(at, 0.6999, band) < 0.01); + } + // Halfway through the pass the band sits on the middle of the line. + assert!((shine_level(0.5, 0.35, band) - 1.).abs() < 1e-4); + // Without a rest the default band never pauses. + assert!(shine_level(1., 0.95, ShineBand::default()) > 0.); + } } diff --git a/apps/maple-agent/app/src/ui/motion.rs b/apps/maple-agent/app/src/ui/motion.rs index a0288b0f9..5fa96379a 100644 --- a/apps/maple-agent/app/src/ui/motion.rs +++ b/apps/maple-agent/app/src/ui/motion.rs @@ -34,6 +34,13 @@ use gpui::{ /// second still read as motion at a fraction of the display rate. pub const LOOP_FPS: u32 = 15; +/// One breath of a running task's grey dot in the sidebar: calm, so a +/// sidebar of running tasks does not flicker. +pub const RUNNING_BREATH: Duration = Duration::from_millis(2400); +/// One cycle of the band across a running task's title: a pass, then a +/// rest, two breaths of [`RUNNING_BREATH`] so the dot and band keep step. +pub const RUNNING_SHINE: Duration = Duration::from_millis(4800); + /// One kind of motion. Everything of that kind takes its timing from the /// token, so editing a token here retunes every animation that uses it. /// diff --git a/apps/maple-agent/app/src/ui/theme.rs b/apps/maple-agent/app/src/ui/theme.rs index 322254b83..194fce12c 100644 --- a/apps/maple-agent/app/src/ui/theme.rs +++ b/apps/maple-agent/app/src/ui/theme.rs @@ -250,6 +250,15 @@ tokens! { bg_sidebar_row_hover: 0x32323a, 0xe8e8ed; bg_sidebar_row_selected: 0x3a3a44, 0xd1d2dc; bg_sidebar_row_selected_hover: 0x43434e, 0xc5c6d1; + /// A running task's breathing dot: Pebble 300 on dark, Pebble 500 on + /// light, where a lighter grey vanished on the selected row. + sidebar_running: 0xbabccb, 0x8c8d96; + /// The band that crosses a running task's title on dark (Pebble 50). + /// Light does not shine: it has no ink brighter than its text. + sidebar_running_shine: 0xf7f7f9, 0x171717; + /// The dot of a task that finished while unseen: a clearer success + /// green than `status_success`'s olive, which read as dull at 8 px. + sidebar_finished: 0x4fc298, 0x18a44e; /// Display headings (Array face): pebble-300 on dark, pebble-800 on /// light, as the brand kit sets its section titles. @@ -300,6 +309,17 @@ pub fn overlay_hover() -> gpui::Hsla { } } +/// Translucent fill for a pressed control over any surface: one step past +/// [`overlay_hover`], so a press always reads darker (lighter on dark) +/// than the hover and the row beneath, whatever that row's own state. +pub fn overlay_press() -> gpui::Hsla { + if is_light() { + gpui::hsla(0., 0., 0., 0.11) + } else { + gpui::hsla(0., 0., 1., 0.14) + } +} + /// Alternate-row tint in markdown tables: a whisper of the hover overlay, /// so a long table reads row by row without stripes competing with the /// text. diff --git a/apps/maple-agent/app/translation-revisions/de.txt b/apps/maple-agent/app/translation-revisions/de.txt index fbc2d9b84..0f5431112 100644 --- a/apps/maple-agent/app/translation-revisions/de.txt +++ b/apps/maple-agent/app/translation-revisions/de.txt @@ -369,7 +369,12 @@ chat-subscribe-history-failed efcbfea0fd223b98 chat-task 18e7eadd2d1ee4dd chat-task-cancelled 3b640b3cda8db4fe chat-task-creating 73485b54c5bfed5b +chat-task-failed 30dcf87a991d6938 +chat-task-finished-unseen 5a6b5ec6b84a1cc0 +chat-task-needs-you f4d20e20814b295d chat-task-options 77f2f2d494397278 +chat-task-running 1652a6ab704d99c1 +chat-task-status-details 6cd6bbbd0091eb32 chat-tasks 2e8ded459c3711e1 chat-thinking 7218df9687f2fbed chat-thinking-choose-model 44c32f022b0e6942 diff --git a/apps/maple-agent/app/translation-revisions/es.txt b/apps/maple-agent/app/translation-revisions/es.txt index fbc2d9b84..0f5431112 100644 --- a/apps/maple-agent/app/translation-revisions/es.txt +++ b/apps/maple-agent/app/translation-revisions/es.txt @@ -369,7 +369,12 @@ chat-subscribe-history-failed efcbfea0fd223b98 chat-task 18e7eadd2d1ee4dd chat-task-cancelled 3b640b3cda8db4fe chat-task-creating 73485b54c5bfed5b +chat-task-failed 30dcf87a991d6938 +chat-task-finished-unseen 5a6b5ec6b84a1cc0 +chat-task-needs-you f4d20e20814b295d chat-task-options 77f2f2d494397278 +chat-task-running 1652a6ab704d99c1 +chat-task-status-details 6cd6bbbd0091eb32 chat-tasks 2e8ded459c3711e1 chat-thinking 7218df9687f2fbed chat-thinking-choose-model 44c32f022b0e6942 diff --git a/apps/maple-agent/app/translation-revisions/ko.txt b/apps/maple-agent/app/translation-revisions/ko.txt index fbc2d9b84..0f5431112 100644 --- a/apps/maple-agent/app/translation-revisions/ko.txt +++ b/apps/maple-agent/app/translation-revisions/ko.txt @@ -369,7 +369,12 @@ chat-subscribe-history-failed efcbfea0fd223b98 chat-task 18e7eadd2d1ee4dd chat-task-cancelled 3b640b3cda8db4fe chat-task-creating 73485b54c5bfed5b +chat-task-failed 30dcf87a991d6938 +chat-task-finished-unseen 5a6b5ec6b84a1cc0 +chat-task-needs-you f4d20e20814b295d chat-task-options 77f2f2d494397278 +chat-task-running 1652a6ab704d99c1 +chat-task-status-details 6cd6bbbd0091eb32 chat-tasks 2e8ded459c3711e1 chat-thinking 7218df9687f2fbed chat-thinking-choose-model 44c32f022b0e6942 diff --git a/apps/maple-agent/docs/brand.md b/apps/maple-agent/docs/brand.md index bf3602174..507c45927 100644 --- a/apps/maple-agent/docs/brand.md +++ b/apps/maple-agent/docs/brand.md @@ -191,6 +191,8 @@ the dark background. | `status_success` | `#7b8f4a` | `#8fa35a` | success | | `status_warning` | `#b45309` Amber 700 | `#d4a35a` | warning; the kit's `#d4a35a` is 2.3:1 on white | | `status_error` | `#d05e41` | `#e07052` | error | +| `sidebar_running`, `sidebar_running_shine` | `#8c8d96` Pebble 500 / no shine | `#babccb` Pebble 300 / `#f7f7f9` | a running task's breathing dot, and the band across its title on dark | +| `sidebar_finished` | `#18a44e` | `#4fc298` | the dot of a task that finished unseen | | `display_text` | `#474854` Pebble 800 | `#babccb` Pebble 300 | Array titles; large type can sit dimmer than body | The 60 / 30 / 10 rule maps to: workspace and transcript on `bg_app`; diff --git a/apps/maple-agent/docs/motion.md b/apps/maple-agent/docs/motion.md index 3f5a6fdcf..bb5267dfb 100644 --- a/apps/maple-agent/docs/motion.md +++ b/apps/maple-agent/docs/motion.md @@ -71,8 +71,10 @@ of `app/src/ui/effort_slider.rs` and `app/src/ui/chat/effort.rs`, and they stay out of the tokens on purpose: nothing else should move like it. Press feedback is immediate (`.active()`), and focus rings appear at once. -Looping indicators (spinners, the waiting dots, the running ring) use the -shared 15 fps `ticker` clock and pause in background windows. +Looping indicators (spinners, the waiting dots, a running task's breathing +dot and title shine) use the shared 15 fps `ticker` clock and pause in +background windows and under reduced motion, resting on a full dot and a +plain title. ## Where motion applies @@ -101,6 +103,7 @@ shared 15 fps `ticker` clock and pause in background windows. | Disclosure chevrons | rotate 90°, `TOGGLE` | same, reversed | | Sidebar collapse | width eases, `PANEL` | same, reversed | | Task status in the sidebar, project folders | indicators and folder icons cross-fade, `TOGGLE` | same | +| A running task in the sidebar | grey dot breathes, `RUNNING_BREATH` (2.4 s); on dark a soft band crosses the title, then rests, `RUNNING_SHINE` (4.8 s) | stops at once when the run ends | Loading spinners for work that usually finishes quickly (opening a task) appear only after 300 ms, so fast loads never flash a spinner.