diff --git a/apps/desktop/src/plugin_host/runtime/trust.rs b/apps/desktop/src/plugin_host/runtime/trust.rs index 1ed9f12f8..090014659 100644 --- a/apps/desktop/src/plugin_host/runtime/trust.rs +++ b/apps/desktop/src/plugin_host/runtime/trust.rs @@ -3,12 +3,15 @@ //! SHA-256 is remembered, and a changed plugin asks again. Built-ins and `--plugin-dir` don't ask. //! What the user chose is the plugin's record in the app's database (`super::boot::save_record`). -use rune::{El, TextStyle, Tx, col, el, row, spacer, text}; +use rune::{El, Tx, row, spacer, text}; use crate::App; use crate::palette::Pal; use crate::plugin_host::{Life, Trust, TrustEvent, step_trust}; -use crate::view::{UI, UI_MED}; +use crate::view::UI; +use opencode_ui::widgets::{self, DialogKind, DialogSize, Fit, button}; +use rune_kit::ButtonVariant; +use opencode_ui::palette::kit; /// The plugin whose prompt shows now: the first waiting one the user hasn't put off. fn shown(app: &App) -> Option { @@ -19,22 +22,11 @@ pub fn dialog(s: &App, p: &Pal, cx: &rune::Cx) -> Vec { let Some(i) = shown(s) else { return Vec::new() }; let plugin = &s.plugins.list[i]; let (id, name) = (plugin.manifest.id.clone(), plugin.manifest.name.clone()); - let button = |key: &str, label: &str, ink: rune::Color, fill: Option| { - let mut b = row().key(key.to_owned()).role("button").label(label.to_owned()).h(28.0).px(12.0).radius(6.0).center().hover(p.hover); - if let Some(f) = fill { - b = b.fill(f).hover(f.alpha(0.9)); - } - b.child(text(label.to_owned()).font(UI_MED).color(ink)) - }; - let mut card = col() + let mut card = widgets::dialog_card(p, DialogKind::Form) .key("plugin-trust-card") .padding(20.0) .gap(6.0) - .radius(12.0) - .fill(p.bg_base) - .box_shadow(Pal::ring_out(p.ring)) - .shadow(8.0, 32.0, p.shadow_far) - .child(text(format!("Enable plugin \"{name}\"?")).font(TextStyle::new(15.0, 600.0).lh(24.0)).color(p.text)) + .child(text(format!("Enable plugin \"{name}\"?")).font(opencode_ui::dialog::TITLE).color(p.text)) .child(text(format!("{name} {} can read and change your files, run programs and reach the network. Only enable plugins you trust.", plugin.manifest.version)).font(UI).color(p.muted).wrap()); if let Some(d) = plugin.manifest.description.as_ref().filter(|d| !d.is_empty()) { card = card.child(text(d.clone()).font(UI).color(p.muted).wrap().mt(6.0)); @@ -51,19 +43,15 @@ pub fn dialog(s: &App, p: &Pal, cx: &rune::Cx) -> Vec { .gap(8.0) .mt(14.0) .child(spacer()) - .child(button("plugin-trust-later", "Not now", p.text, None).on_press_tx(move |s: &mut App, tx: &mut Tx| answer(s, &later, TrustEvent::Later, tx))) - .child(button("plugin-trust-enable", "Enable", p.on_fill, Some(p.bg_accent)).on_press_tx(move |s: &mut App, tx: &mut Tx| answer(s, &ok, TrustEvent::Accept, tx))), + .child(button("Not now", ButtonVariant::Ghost).on_press_tx(move |s: &mut App, tx: &mut Tx| answer(s, &later, TrustEvent::Later, tx)).build(kit(p)).key("plugin-trust-later").autofocus()) + .child(button("Enable", ButtonVariant::Contrast).on_press_tx(move |s: &mut App, tx: &mut Tx| answer(s, &ok, TrustEvent::Accept, tx)).build(kit(p)).key("plugin-trust-enable")), ); // No Desktop counterpart: a confirmation, so the normal size. - let card = crate::widgets::sized(card, crate::widgets::DialogSize::Normal, crate::widgets::Fit::Content, crate::widgets::dialog_window(cx, *s.zoom)); - vec![ - el().key("plugin-trust-scrim").absolute(0.0, 0.0).w_full().h_full().fill(p.dim), - el().key("plugin-trust-modal").absolute(0.0, 0.0).w_full().h_full().center().child(card).raise(), - ] + widgets::sized_modal("plugin-trust", p, DialogSize::Normal, Fit::Content, widgets::dialog_window(cx, *s.zoom), card) } fn answer(app: &mut App, id: &str, event: TrustEvent, tx: &mut Tx) { - tx.instant(); + tx.animated(); if let Some(i) = app.plugins.find(id) { step_trust(app, i, event); } diff --git a/apps/desktop/src/stories/shell/menu.rs b/apps/desktop/src/stories/shell/menu.rs index bbf14db2b..8a88c58d9 100644 --- a/apps/desktop/src/stories/shell/menu.rs +++ b/apps/desktop/src/stories/shell/menu.rs @@ -89,6 +89,16 @@ fn toast_start(s: &mut App, tx: &mut Play) { s.finish_stream(); crate::status_toast::dismiss(s); tx.instant(); + if *s.fixture_run.variant == 2 { + tx.after(0.5, |s, tx| { + tx.animated(); + crate::status_toast::show(s, crate::status_toast::Entry::new( + "This HTML file is outside this session's workspace and cannot open in the browser pane.", + None, true, + ), None); + }); + return; + } if *s.fixture_run.variant == 1 { tx.after(0.5, |s, _| { crate::status_toast::show(s, crate::status_toast::Entry::new("Export saved", Some("Ready to share".into()), false), Some(3.0)); @@ -103,5 +113,5 @@ fn toast_start(s: &mut App, tx: &mut Play) { rune_register::register!(crate::stories::STORY_LIST: Story = [ Story::session("Popover/Menus", KEYS).knobs(&[motion::GROUP]).variants(VARIANTS), - Story::session("Components/Toast", TOAST_KEYS).variants(&[("Single", 0), ("Expiry stack", 1)]), + Story::session("Components/Toast", TOAST_KEYS).variants(&[("Single", 0), ("Expiry stack", 1), ("Long warning", 2)]), ]); diff --git a/apps/desktop/src/surfaces/automations/delete_dialog.rs b/apps/desktop/src/surfaces/automations/delete_dialog.rs index 0ec659860..6d40c1d3f 100644 --- a/apps/desktop/src/surfaces/automations/delete_dialog.rs +++ b/apps/desktop/src/surfaces/automations/delete_dialog.rs @@ -1,9 +1,9 @@ //! Delete automation confirmation dialog (packages/app/src/automations/route.tsx:confirmDelete). use opencode_i18n::t; -use opencode_ui::palette::{Elevate as _, Pal, flat, kit}; +use opencode_ui::palette::{Pal, kit}; use opencode_ui::widgets::{BODY, DialogSize, Fit, button, dialog_window, sized_modal}; -use rune::{Color, Cx, El, TextStyle, Tx, col, row, spacer, text}; +use rune::{Cx, El, TextStyle, Tx, col, row, spacer, text}; use rune_kit::ButtonVariant; use crate::App; @@ -19,28 +19,21 @@ pub fn view(s: &App, p: &Pal, cx: &Cx) -> Vec { let (key, server, id, name) = (key.clone(), server.clone(), id.clone(), name.clone()); let k = kit(p); let cancel = button(t!("common.cancel"), ButtonVariant::Ghost) - .on_press_tx(|s: &mut App, tx: &mut Tx| { super::cancel_delete(s, tx); }) + .on_press_tx(|s: &mut App, tx: &mut Tx| { super::cancel_delete(s, tx); tx.animated(); }) .build(k) .key("auto-delete-cancel") .autofocus(); let delete = button(t!("automations.delete.button"), ButtonVariant::Danger) - .on_press_tx(move |s: &mut App, tx: &mut Tx| super::confirm_delete(s, &key, &server, &id, tx)) + .on_press_tx(move |s: &mut App, tx: &mut Tx| { super::confirm_delete(s, &key, &server, &id, tx); tx.animated(); }) .build(k) .key("auto-delete-confirm"); - let delete = if p.dark && p.theme == 0 { - delete.fill(flat(Color::WHITE.alpha(0.06), p.layer1)) - } else { - delete - }; - let card = col() + let delete = opencode_ui::widgets::danger_surface(p, delete); + let card = opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::Form) .key("auto-delete-card") .role("dialog") .label_static(t!("automations.delete.title")) - .radius(6.0) - .fill(p.layer1) - .elevate(p.overlay) .clip_soft(0.0) - .modal_tx(true, |s: &mut App, tx: &mut Tx| { super::cancel_delete(s, tx); }) + .modal_tx(true, |s: &mut App, tx: &mut Tx| { super::cancel_delete(s, tx); tx.animated(); }) .child( col() .key("auto-delete-header") diff --git a/apps/desktop/src/workspace/system/deep_links/dialog.rs b/apps/desktop/src/workspace/system/deep_links/dialog.rs index 8bd8c4ad8..1a66f6b68 100644 --- a/apps/desktop/src/workspace/system/deep_links/dialog.rs +++ b/apps/desktop/src/workspace/system/deep_links/dialog.rs @@ -2,8 +2,8 @@ //! (`packages/app/src/shell/deep-links/{deep-links.tsx,prompt-preview.ts}`, `opencode#65803`, `#67170`). use opencode_i18n::t; -use opencode_ui::palette::{Elevate as _, Pal, kit}; -use opencode_ui::widgets::{BODY, DialogSize, Fit, button, dialog_window, sized}; +use opencode_ui::palette::{Pal, kit}; +use opencode_ui::widgets::{BODY, DialogSize, Fit, button, dialog_window}; use rune::{Cx, Direction, El, Key, KeyEvent, TextStyle, Tx, col, el, row, spacer, text}; use rune_kit::ButtonVariant; @@ -21,7 +21,7 @@ pub(crate) fn asking(s: &App) -> bool { /// Accepts the active deep-link confirmation attempt. pub(crate) fn accept(s: &mut App, attempt: u64, tx: &mut Tx) { - tx.instant(); + tx.animated(); let ready = ready_servers(s); let effects = s .services @@ -36,7 +36,7 @@ pub(crate) fn accept(s: &mut App, attempt: u64, tx: &mut Tx) { /// Declines the active deep-link confirmation attempt. pub(crate) fn decline(s: &mut App, attempt: u64, tx: &mut Tx) { - tx.instant(); + tx.animated(); let effects = s.services.deep_links.step(DeepLinkEvent::Declined { attempt }, |_| false); let _ = run(s, effects, tx); if asking(s) { @@ -122,13 +122,10 @@ pub(crate) fn dialog(s: &App, p: &Pal, cx: &Cx) -> Vec { .py(2.0) .fill(p.text.alpha(0.08)) .child(text(dir).font(FOLDER_CODE).color(p.text).dir(Direction::Ltr).wrap()); - let card = col() + let card = opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::Form) .key("deep-link-card") .role("dialog") .label(title.clone()) - .radius(6.0) - .fill(p.layer1) - .elevate(p.overlay) .clip_soft(0.0) .modal_tx(true, move |s: &mut App, tx: &mut Tx| decline(s, attempt, tx)) .child( @@ -176,11 +173,7 @@ pub(crate) fn dialog(s: &App, p: &Pal, cx: &Cx) -> Vec { .child(text(t!("deepLink.open.warning")).font(BODY).color(p.muted).wrap().w_full()), ) .child(row().key("deep-link-footer").w_full().padding(16.0).gap(8.0).child(spacer()).child(cancel).child(open_btn)); - let card = sized(card, DialogSize::Normal, Fit::Content, dialog_window(cx, *s.zoom)); - vec![ - el().key("deep-link-scrim").absolute(0.0, 0.0).w_full().h_full().fill(p.scrim), - el().key("deep-link-modal").absolute(0.0, 0.0).w_full().h_full().center().child(card).raise(), - ] + opencode_ui::widgets::sized_modal("deep-link", p, DialogSize::Normal, Fit::Content, dialog_window(cx, *s.zoom), card) } fn folder_name(dir: &str) -> String { diff --git a/crates/opencode-ui/src/dialog.rs b/crates/opencode-ui/src/dialog.rs index 15862fedd..1f6710ab4 100644 --- a/crates/opencode-ui/src/dialog.rs +++ b/crates/opencode-ui/src/dialog.rs @@ -54,3 +54,17 @@ impl DialogSize { ((win_h - self.height(win_h)) / 2.0).max(0.0) } } + +/// Dialog presence: a small centred scale with its scrim. Rune reduces this to a short +/// opacity fade when Reduce Motion is enabled (no travel or scale). +pub fn transition() -> rune::Transition { + rune::Transition::scale(0.96).springs(rune::SpringPair::new(rune::Spring::new(0.2, 0.0), rune::Spring::new(0.15, 0.0))) +} + +/// The backdrop uses the card's timing without scaling the window-sized scrim. +pub fn scrim_transition() -> rune::Transition { + rune::Transition::opacity().springs(transition().springs) +} + +/// Shared dialog heading: the calibrated medium Inter face. +pub const TITLE: rune::TextStyle = rune::TextStyle::new(15.0, 530.0).lh(20.0).tracking(-0.13); diff --git a/crates/opencode-ui/src/toast/mod.rs b/crates/opencode-ui/src/toast/mod.rs index ba71c262b..a16a93659 100644 --- a/crates/opencode-ui/src/toast/mod.rs +++ b/crates/opencode-ui/src/toast/mod.rs @@ -1,6 +1,6 @@ //! Toast notifications at the window's bottom-right, matching OpenCode Desktop's `Toast.Region` -//! (`packages/ui/src/feedback/toast/toast.tsx`, `toast.css`), with instant entrance and a -//! downward exit on expiry. Explicit keyboard and button dismissals remain immediate. +//! (`packages/ui/src/feedback/toast/toast.tsx`, `toast.css`), with an upward entrance and a +//! downward fade on expiry or explicit close-button dismissal. Rune respects Reduce Motion. //! //! Toasts stack as Sonner stacks them (`rune_kit::ToastStack`): the newest in front, up to two //! more peeking behind it; hovering the stack spreads them out, and while hovered or while the diff --git a/crates/opencode-ui/src/toast/view.rs b/crates/opencode-ui/src/toast/view.rs index b319b363f..baa4a17eb 100644 --- a/crates/opencode-ui/src/toast/view.rs +++ b/crates/opencode-ui/src/toast/view.rs @@ -3,6 +3,7 @@ use rune::{Anim, Color, Edge, El, Icon, Shadow, Spring, SpringPair, TextStyle, Transition, Tx, col, el, icon, row, spacer, text}; use rune_kit::{ToastEntry, ToastEvent}; +use crate::focus::FocusExt as _; use crate::palette::{Elevate as _, Pal}; use super::state::{dismiss_id, stack_key, step}; @@ -13,10 +14,10 @@ const TITLE: TextStyle = TextStyle::new(13.0, 530.0).lh(20.0).tracking(-0.04); const DESC: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04); // `packages/ui/src/feedback/toast/toast.css` keeps removal and stack movement animated. -// Keep the instant entrance; a timed dismissal travels down on a short zero-bounce spring. -fn exit_transition() -> Transition { - Transition::asymmetric(Transition::none(), Transition::move_edge(Edge::Bottom)) - .springs(SpringPair { enter: Spring::NONE, exit: Spring::new(0.25, 0.0) }) +// Enter and leave from the lower edge; Rune reduces travel to a fade under Reduce Motion. +fn presence_transition() -> Transition { + Transition::move_edge(Edge::Bottom).combined(Transition::opacity()) + .springs(SpringPair { enter: Spring::new(0.3, 0.0), exit: Spring::new(0.25, 0.0) }) } /// Sonner's close glyph, which `toast.css` draws at 16 px: two strokes 6 to 18 across 24, 1.5 @@ -54,7 +55,7 @@ pub fn view(s: &S, p: &Pal) -> Option { let mut stack = el() .key(STACK) // When the last toast leaves, its parent carries the exit instead of the card. - .transition(exit_transition()) + .transition(presence_transition()) .role("region") .label("Notifications alt+T") .w(w) @@ -81,7 +82,7 @@ pub fn view(s: &S, p: &Pal) -> Option { let (pulse, scale_motion) = s.toast().pulse.of(e.id).unwrap_or((1.0, MOVE)); stack = stack.child( card.offset(0.0, -at.lift) - .transition(exit_transition()) + .transition(presence_transition()) .offset_motion(MOVE) .scale(at.scale * pulse) .scale_motion(scale_motion) @@ -165,13 +166,14 @@ fn card(s: &S, p: &Pal, entry: &Entry, content_sh .center() .hover(p.hover) .press(p.pressed) + .focus_inset(p) .hover_group() .hover_motion(INSTANT, INSTANT) .on_press_tx(move |s: &mut S, tx: &mut Tx| { - tx.instant(); dismiss_id(s, id); // `ToastOptions.onDismiss`: the person closed it. s.on_dismissed(id, tx); + tx.animated(); }) // `icon-muted` at rest, `icon-base` under the pointer. .child(icon(&CLOSE, 16.0).color(p.icon_muted)) @@ -185,7 +187,7 @@ fn card(s: &S, p: &Pal, entry: &Entry, content_sh // difference: official stacks every action under the content). let one_line = entry.description.is_none() && entry.quote.is_none() && entry.next.is_none() && entry.buttons.is_empty(); if one_line && action_btn.is_some() { - let title = text(entry.title.clone()).key("toast-title").font(TITLE).color(p.text).truncate().grow(1.0).shrink().min_w(0.0); + let title = text(entry.title.clone()).key("toast-title").font(TITLE).color(p.text).help_when_truncated(entry.title.clone()).truncate().grow(1.0).shrink().min_w(0.0); let body = row() .key("toast-head") .w_full() @@ -200,13 +202,14 @@ fn card(s: &S, p: &Pal, entry: &Entry, content_sh return frame::(p, entry, body).py(8.0).pl(14.0).pr(8.0); } + // Unlike toast.css's single-line title, a warning must keep its complete explanation. let mut content = col() .key("toast-content") .grow(1.0) .shrink() .min_w(0.0) .gap(4.0) - .child(text(entry.title.clone()).key("toast-title").font(TITLE).color(p.text).truncate().w_full()) + .child(text(entry.title.clone()).key("toast-title").font(TITLE).color(p.text).wrap().w_full()) .children(entry.description.as_ref().map(|desc| text(desc.clone()).key("toast-description").font(DESC).color(p.muted).wrap().w_full())) // The server's words, set apart by a rule as a quotation is, in the text colour: theirs. .children(entry.quote.as_ref().map(|q| { @@ -275,6 +278,7 @@ fn action_button(s: &S, p: &Pal, id: u64, action: &ToastAction { @@ -300,6 +304,7 @@ fn extra_button(p: &Pal, id: u64, i: usize, button: &ToastButton El { .label(label.to_owned()) .gap(8.0) .center_y() - .child(Loader::new().size(16.0).build(kit(p))) + .child(crate::style::busy_glyph(kit(p), 16.0)) .child(text(label.to_owned()).font(BODY).color(p.muted)) } @@ -125,27 +125,42 @@ pub fn sized_modal(key: &str, p: &Pal, size: DialogSize, fit: Fit, win: [f32; 2] modal(key, p, sized(card, size, fit, win), kept.then(|| size.top(win[1]))) } -/// A dialog's scrim and its centring layer (the dialog element's `.modal` / `.modal_tx` handles -/// outside presses). +/// Dialog content uses one corner geometry; searchable lists keep their base surface +/// (packages/ui/src/overlays/dialog/dialog.css). +#[derive(Clone, Copy)] +pub enum DialogKind { Form, List } + +pub fn dialog_card(p: &Pal, kind: DialogKind) -> El { + let fill = match kind { DialogKind::Form => p.layer1, DialogKind::List => p.bg_base }; + col().role("dialog").radius(12.0).fill(fill).elevate(p.overlay) + .motion(rune::Spring::NONE) +} + +/// A destructive button keeps semantic warning ink on a tinted surface in every theme. +/// Deliberately stronger than button.css's neutral danger fill, which loses its warning at rest. +pub fn danger_surface(p: &Pal, button: El) -> El { + button.fill(crate::palette::flat(p.danger_bg, p.layer1)) +} + +/// A dialog's scrim and centring layer; the card's modal callback handles outside presses. pub fn modal(key: &str, p: &Pal, dialog: El, top: Option) -> Vec { - let scrim = el().key(format!("{key}-scrim")).absolute(0.0, 0.0).w_full().h_full().fill(p.scrim).transition(Transition::none()); - let mut layer = col().key(format!("{key}-modal")).absolute(0.0, 0.0).w_full().h_full().items_center().transition(Transition::none()); - layer = match top { - Some(t) => layer.pt(t), - None => layer.center(), + let scrim = el().key(format!("{key}-scrim")).absolute(0.0, 0.0).w_full().h_full().fill(p.scrim).transition(crate::dialog::scrim_transition()).enter_in_instant(); + let layer = col().key(format!("{key}-modal")).w_full().items_center().transition(crate::dialog::transition()).enter_in_instant(); + // Presence belongs to the parent: Rune's rides_parent suppresses child presence tracks. + // Anchored layers hug the card so the scale origin stays at the dialog's centre. + let layer = match top { + Some(t) => layer.absolute(0.0, t), + None => layer.absolute(0.0, 0.0).h_full().center(), }; - vec![scrim, layer.child(dialog).raise()] + vec![scrim, layer.child(dialog.transition(Transition::none())).raise()] } -/// A status dot's colour (`.mcp-status-dot`, `.session-service-dot`): Desktop's v1 -/// `icon-success-base`, `icon-critical-base` and `icon-warning-base`, or a chosen theme's v2 -/// state colours; faint otherwise. +/// MCP and session service status colours, using the active theme's semantic tokens. pub fn status_ink(p: &Pal, status: &str) -> Color { - let v1 = |light: &str, dark: &str, or: Color| if p.theme == 0 { rune::color::hex(if p.dark { dark } else { light }).unwrap_or(or) } else { or }; match status { - "connected" | "active" => v1("#0abe00", "#089b00", p.success), - "failed" => v1("#fa3012", "#cb321c", p.danger), - "needs_auth" => p.v1_icon_warning, + "connected" | "active" => p.success, + "failed" => p.danger, + "needs_auth" => p.warning, _ => p.icon_faint, } } diff --git a/features/composer-input/src/attachments/toast.rs b/features/composer-input/src/attachments/toast.rs index 8ce38a9a5..6c8dc590f 100644 --- a/features/composer-input/src/attachments/toast.rs +++ b/features/composer-input/src/attachments/toast.rs @@ -7,6 +7,7 @@ use rune::{El, Spring, TextStyle, Transition, Tx, col, el, icon, row, text}; use rune_theme_opencode::icons as ic; use session_view::palette::{Elevate as _, Pal}; use session_view::style::INSTANT; +use opencode_ui::focus::FocusExt as _; use crate::attachments::AttachmentsHost; use crate::attachments::uploads::Upload; @@ -16,7 +17,7 @@ const NAME: TextStyle = TextStyle::new(13.0, 530.0).lh(20.0).tracking(-0.04); const PERCENT: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04).features("\"tnum\""); fn on_cancel_upload(host: &mut dyn AttachmentsHost, id: &str, tx: &mut Tx) { - tx.instant(); + tx.motion(Spring::new(0.25, 0.0)); crate::attachments::cancel_upload(host, id); } @@ -25,16 +26,19 @@ fn cancel_button_shell(p: &Pal, name: &str) -> El { .key("upload-row-cancel") .role("button") .label(opencode_i18n::t!("prompt.toast.uploading.cancelFile", filename = name.to_owned())) - .size(16.0, 16.0) + .size(20.0, 20.0) .radius(4.0) .center() // `cursor: pointer` (`attachments.css:85`), which Desktop's cursor reset does not name. .cursor(rune::Cursor::Pointer) .hover(p.hover) + .press(p.pressed) + .focus_inset(p) + .help(opencode_i18n::t!("prompt.toast.uploading.cancelFile", filename = name.to_owned())) .hover_group() .hover_motion(INSTANT, INSTANT) .child(icon(&ic::OUTLINE_XMARK, 12.0).color(p.icon_muted)) - .child(icon(&ic::OUTLINE_XMARK, 12.0).color(p.icon).absolute(2.0, 2.0).group_opacity(0.0, 1.0)) + .child(icon(&ic::OUTLINE_XMARK, 12.0).color(p.icon).absolute(4.0, 4.0).group_opacity(0.0, 1.0)) } /// `upload-row`: the name and percent over the bar and its cancel, 4 apart; 8 more above every diff --git a/features/composer-input/src/suggestions/popover.rs b/features/composer-input/src/suggestions/popover.rs index 07b334900..641320a4d 100644 --- a/features/composer-input/src/suggestions/popover.rs +++ b/features/composer-input/src/suggestions/popover.rs @@ -1,10 +1,9 @@ //! Shared composer suggestion popover chrome built over `session_view` (`composer_fill`, //! `search_field`, `scroller`) for the `/` commands list and Shift+↑ history list. -use rune::{Color, Cx, El, KeyEvent, TextEdit, TextStyle, Transition, Tx, col, row, text}; +use rune::{Cx, El, KeyEvent, TextEdit, TextStyle, Transition, Tx, col, row, text}; use serde_json::Value; -use session_view::composer::composer_fill; -use session_view::palette::{Elevate as _, Pal}; +use session_view::palette::Pal; use session_view::popover::search_field; use session_view::scroller::scroller; use session_view::style::UI; @@ -18,7 +17,7 @@ const WORDS: TextStyle = TextStyle::new(13.0, 440.0).lh(24.0); /// Desktop's composer suggestions (`composer/editor/editor.tsx:72-82`): 28 pt rows in 6 pt of /// padding, at most 320 pt tall less some of the timeline kept in view. const ROW_H: f32 = 28.0; -const PAD: f32 = 6.0; +const PAD: f32 = opencode_ui::popover::LIST.inset; const MAX_H: f32 = 320.0; /// How much of the next row shows under the last whole one. const PEEK: f32 = 18.0; @@ -155,13 +154,13 @@ fn build_row_shell(p: &Pal, r: PopoverRow, is_active: bool) -> El { .px(8.0) .gap(8.0) .center_y() - .radius(6.0) - .fill(if is_active { p.hover } else { Color::TRANSPARENT }) + .radius(opencode_ui::popover::LIST.row_radius) + .fill(opencode_ui::popover::lit(p, is_active)) .child(words) .children(trail) } -fn build_popup_frame(p: &Pal, spec: PopoverSpec, row_els: Vec) -> El { +fn build_popup_frame(p: &Pal, spec: PopoverSpec, row_els: Vec) -> El { let empty = row_els.is_empty(); let count = row_els.len(); let searching = spec.search.is_some(); @@ -176,18 +175,12 @@ fn build_popup_frame(p: &Pal, spec: PopoverSpec, row_els: Vec) -> El { let h = (search + count as f32 * ROW_H + 2.0 * PAD).min(max_height(spec.boundary.unwrap_or(2.0 * MAX_H), searching, false)); scroller(scroll).hidden(col().w_full().h(h).scroll_margin(PAD), list) }; - // `rounded-xl bg-v2-background-bg-base p-1.5 shadow-[var(--v2-elevation-raised)]`, raised to - // `--v2-background-bg-layer-01` in dark mode (`editor.css:84-92`): 10 pt corners and the - // raised ring and drops, no border of its own. - col() - .elevate(p.raised) - .key(spec.key) + // Composer lists share the search-list frame and floating elevation. + opencode_ui::popover::surface::(p, opencode_ui::popover::LIST, spec.key, spec.label) .role("listbox") .label(spec.label) .above("composer", 8.0) .w(spec.width) - .radius(10.0) - .fill(composer_fill(p)) .clip_soft(0.0) .transition(Transition::none()) // A press anywhere on it leaves the composer focused: a blur would close the popover @@ -215,5 +208,5 @@ pub fn popup(p: &Pal, spec: PopoverSpec, rows: Vec .on_press_tx(move |s: &mut H, tx: &mut Tx| on_popup_pick(s, &id_press, tx)) }) .collect(); - build_popup_frame(p, spec, row_els).on_press(|_: &mut H| {}) + build_popup_frame::(p, spec, row_els).on_press(|_: &mut H| {}) } diff --git a/features/connect/src/ui.rs b/features/connect/src/ui.rs index fd0fad246..5535dddab 100644 --- a/features/connect/src/ui.rs +++ b/features/connect/src/ui.rs @@ -1,142 +1,18 @@ -//! Shared non-generic dialog chrome, provider marks, and locale search folding used by the -//! Connect provider dialog and ChatGPT plan welcome dialog. - -use rune::{Color, Cx, El, Icon, TextStyle, Transition, col, el, icon, row, text}; -use rune_kit::{Badge, Button, ButtonVariant, Loader}; -use rune_theme_opencode::provider_icons; -use opencode_ui::dialog::DialogSize; -use opencode_ui::palette::{Elevate as _, Pal, kit}; +//! Connect's host adapter; shared controls and dialog chrome live in opencode-ui. +use rune::{Cx, El, row}; use crate::ConnectHost; +pub(crate) use opencode_ui::widgets::{BODY, BODY_MED, LABEL, DIALOG_CLOSE, button, badge, status_row, provider_mark, overlay, Fit, sized_modal}; -/// Desktop's body copy in its views: 13 on 20 at 440, tracking -0.04. -pub(crate) const BODY: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04); -/// 13 on 20 at 530. -pub(crate) const BODY_MED: TextStyle = TextStyle::new(13.0, 530.0).lh(20.0).tracking(-0.04); -/// 13 on 16 at 530 (`line-height-compact`). -pub(crate) const LABEL: TextStyle = TextStyle::new(13.0, 530.0).lh(16.0).tracking(-0.04); - -/// `opencode-logo.tsx`: OpenCode's mark, which Desktop draws for the `opencode` provider. -pub(crate) static OPENCODE_LOGO: Icon = Icon { - name: "opencode-logo", - view: 16.0, - body: r#""#, -}; - -/// The dialog's own close cross (`overlays/dialog/dialog.tsx`): a 1 pt stroke corner to corner. -pub(crate) static DIALOG_CLOSE: Icon = Icon { - name: "dialog-close", - view: 16.0, - body: r#""#, -}; - -/// `button-v2` at size normal: 28 tall, 11 in from each side, 6 pt corners, tabular numerals. -#[allow(deprecated)] -pub(crate) fn button(label: impl Into, variant: ButtonVariant) -> Button { - let label = label.into(); - Button::new(label.clone()) - .variant(variant) - .size(rune_kit::ButtonSize::Normal) - .label_with(move |font, ink| text(label).key("label").font(font.features("\"tnum\"")).color(ink)) -} - -pub(crate) fn badge(p: &Pal, label: impl Into) -> El { - Badge::new(label).build(kit(p)) -} - -/// Desktop's `Loader` beside muted words: a sign-in or a check under way. -pub(crate) fn status_row(p: &Pal, key: &str, label: &str) -> El { - row() - .key(key.to_owned()) - .role("status") - .label(label.to_owned()) - .gap(8.0) - .center_y() - .child(Loader::new().size(16.0).build(kit(p))) - .child(text(label.to_owned()).font(BODY).color(p.muted)) -} - -/// A provider's 16 pt mark (`ProviderModelIcon`): OpenCode's logo, the provider's own icon by -/// id (less a `console-` prefix), else Desktop's custom provider mark. -pub(crate) fn provider_mark(id: &str, color: Color) -> El { - if id == "opencode" { - return icon(&OPENCODE_LOGO, 16.0).color(color); - } - if id == "google-ai-plan" { - return icon(&opencode_ui::provider_mark::GOOGLE_AI_PLAN, 16.0).color(color); - } - let bare = id.strip_prefix("console-").unwrap_or(id); - let mark = [id, bare].into_iter().filter(|i| *i != "synthetic").find_map(provider_icons::named); - match mark { - Some(m) => icon(m, 16.0).color(color), - None => icon(&opencode_ui::provider_mark::CUSTOM, 16.0), - } -} - -/// `--v2-elevation-overlay` on a dialog surface. -pub(crate) fn overlay(p: &Pal, e: El) -> El { - e.elevate(p.overlay) -} - -/// The window a dialog clamps its size to, in zoomed points. pub(crate) fn dialog_window(s: &H, cx: &Cx) -> [f32; 2] { - let zoom = s.zoom().max(0.5); - cx.layout_size("zoom").unwrap_or([1280.0 / zoom, 820.0 / zoom]) + opencode_ui::widgets::dialog_window(cx, s.zoom()) } -/// Unified step action footer (`providers/connect/step-actions.tsx`, `#63829`): secondary actions -/// first, primary action furthest right. +/// Unified footer: primary action furthest right (providers/connect/step-actions.tsx). pub(crate) fn step_actions() -> El { row().w_full().justify_end().center_y().gap(8.0) } -/// How a dialog's height follows its content (``, `#64882`). -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(crate) enum Fit { - /// As tall as its content, up to the size's most (`fit`). - Content, -} - -/// `card` at preset `size` in a window `win`: its width, and the most it grows to. -pub(crate) fn sized(card: El, size: DialogSize, fit: Fit, win: [f32; 2]) -> El { - let [win_w, win_h] = win; - let card = card.w(size.width(win_w)); - match fit { - Fit::Content => card.max_h(size.max_height(win_h, false)), - } -} - -/// `card` at preset `size` in a window `win`, over its scrim (`modal`): centred, or with its top -/// edge kept where it fits its content and is large. -pub(crate) fn sized_modal(key: &str, p: &Pal, size: DialogSize, fit: Fit, win: [f32; 2], card: El) -> Vec { - let kept = fit == Fit::Content && size != DialogSize::Normal; - modal(key, p, sized(card, size, fit, win), kept.then(|| size.top(win[1]))) -} - -/// A dialog's scrim and its centring layer. -pub(crate) fn modal(key: &str, p: &Pal, dialog: El, top: Option) -> Vec { - let scrim = el() - .key(format!("{key}-scrim")) - .absolute(0.0, 0.0) - .w_full() - .h_full() - .fill(p.scrim) - .transition(Transition::none()); - let mut layer = col() - .key(format!("{key}-modal")) - .absolute(0.0, 0.0) - .w_full() - .h_full() - .items_center() - .transition(Transition::none()); - layer = match top { - Some(t) => layer.pt(t), - None => layer.center(), - }; - vec![scrim, layer.child(dialog).raise()] -} - -/// How searches fold in the interface's language: Turkish and Azerbaijani fold `I` to `ı`. pub(crate) fn search_fold() -> rune_kit::search::Fold { rune_kit::search::Fold::for_language(opencode_i18n::locale().tag()) } diff --git a/features/connect/src/view.rs b/features/connect/src/view.rs index 8439a6b90..0812a9cf6 100644 --- a/features/connect/src/view.rs +++ b/features/connect/src/view.rs @@ -137,9 +137,10 @@ fn pick(host: &mut dyn ConnectHost, id: &str, tx: &mut Tx) { crate::connect_event(host, Event::Selected { provider: id.to_owned(), from_picker: true, accounts }, tx); } -fn close_on_backdrop(host: &mut dyn ConnectHost, authorizing: bool) { +fn close_on_backdrop(host: &mut dyn ConnectHost, authorizing: bool, tx: &mut Tx) { if !authorizing { - crate::close(host, &mut Tx::default()); + crate::close(host, tx); + tx.animated(); } } @@ -209,17 +210,14 @@ pub fn dialog(s: &H, p: &Pal, win: [f32; 2]) -> Vec(s: &H, p: &Pal, win: [f32; 2]) -> Vec` (`providers/connect/dialog.tsx`, `#64882`): every step fits its // content within the large height, and the top edge stays put. @@ -236,14 +234,11 @@ pub fn dialog(s: &H, p: &Pal, win: [f32; 2]) -> Vec El { - ui::overlay(p, col()) + opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::List) .key("connect-dialog") .role("dialog") .label(label) - .radius(12.0) - .fill(p.bg_base) .clip_soft(0.0) - .transition(Transition::none()) .motion(Spring::NONE) .child(head) .child(content) @@ -264,7 +259,7 @@ fn build_focus_host(label: String, body: El) -> El { } fn close_button(p: &Pal) -> El { - close_button_shell(p).on_press_tx(|s: &mut H, tx: &mut Tx| crate::close(s, tx)) + close_button_shell(p).on_press_tx(|s: &mut H, tx: &mut Tx| { crate::close(s, tx); tx.animated(); }) } fn close_button_shell(p: &Pal) -> El { diff --git a/features/connect/src/welcome.rs b/features/connect/src/welcome.rs index 0a1f1eefc..d9ae6796f 100644 --- a/features/connect/src/welcome.rs +++ b/features/connect/src/welcome.rs @@ -2,7 +2,7 @@ //! after OpenAI connected through ChatGPT token sharing, a small card says the plan is in use. use opencode_i18n::t; -use rune::{Align, Cx, El, Key, KeyEvent, Link, LinkPaint, Spring, TextStyle, Transition, Tx, col, icon, text}; +use rune::{Align, Cx, El, Key, KeyEvent, Link, LinkPaint, Spring, TextStyle, Tx, icon, text}; #[allow(deprecated)] use rune_kit::{ButtonSize, ButtonVariant}; use rune_theme_opencode::provider_icons; @@ -31,8 +31,8 @@ pub fn close(host: &mut dyn ConnectHost, tx: &mut Tx) { if !host.connect().is_welcome_open() { return; } - tx.instant(); crate::apply_modal(host, ModalEvent::CloseWelcome, tx); + tx.animated(); } /// Esc and Enter close it, Enter as the focused Got it does. @@ -69,7 +69,7 @@ pub fn dialog(s: &H, p: &Pal, win: [f32; 2]) -> Vec` (`providers/connect/chatgpt-welcome.tsx`). ui::sized_modal("chatgpt-welcome", p, DialogSize::Normal, Fit::Content, win, card) } @@ -81,20 +81,17 @@ fn build_card(p: &Pal, confirm: El) -> El { .font(BODY) .color(p.muted) .link(Link::new(0..words.len(), USAGE_URL).role("link").label(words).hover(LinkPaint::new().color(p.text))) - // An `ExternalLink` with no cursor of its own: `a { cursor: default }` (`packages/ui/src/styles/base.css:84`). - .cursor(rune::Cursor::Default) + // External usage links expose a pointer (deliberate difference from base.css). + .cursor(rune::Cursor::Pointer) .mt(4.0); - ui::overlay(p, col()) + opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::Form) .key("chatgpt-welcome") .role("dialog") .label_static(t!("provider.connect.chatgptWelcome.title")) - .radius(12.0) - .fill(p.layer1) .items_center() .px(32.0) .pt(36.0) .pb(32.0) - .transition(Transition::none()) .motion(Spring::NONE) .children(provider_icons::named("openai").map(|m| icon(m, 48.0).color(p.icon))) .child(text(t!("provider.connect.chatgptWelcome.title")).font(TITLE).color(p.text).wrap().align(Align::Center).max_w(270.0).mt(24.0)) diff --git a/features/mcp/src/sign_in.rs b/features/mcp/src/sign_in.rs index 721d1432a..670d53922 100644 --- a/features/mcp/src/sign_in.rs +++ b/features/mcp/src/sign_in.rs @@ -8,7 +8,7 @@ use std::time::Duration; use opencode_i18n::t; use opencode_kit::integration::{Authorization, McpServer}; use rune::machine::{Attempt, Seq}; -use rune::{Cx, El, Key, KeyEvent, Spring, TextEdit, TextStyle, Transition, Tx, col, el, icon, row, text}; +use rune::{Cx, El, Key, KeyEvent, Spring, TextEdit, TextStyle, Tx, col, el, icon, row, text}; use rune_kit::{ButtonVariant, TextInput}; use rune_theme_opencode::icons as ic; use opencode_ui::dialog::DialogSize; @@ -307,6 +307,7 @@ fn run(host: &mut dyn McpHost, effects: Vec, tx: &mut Tx) { }, }), Effect::Close => { + tx.animated(); host.mcp_mut().sign_in = None; host.on_overlay_closed(SIGN_IN_OVERLAY_ID); host.auto_focus_composer(tx); @@ -320,7 +321,7 @@ fn run(host: &mut dyn McpHost, effects: Vec, tx: &mut Tx) { pub fn close(host: &mut dyn McpHost, tx: &mut Tx) { let effects = { let Some(x) = host.mcp_mut().sign_in.as_mut() else { return }; - tx.instant(); + tx.animated(); step(x, Event::Disposed) }; run(host, effects, tx); @@ -474,7 +475,7 @@ pub fn dialog(s: &H, p: &Pal, win: [f32; 2]) -> Vec { }); let card = build_card(x, p, Controls { close_btn, open_btn, retry_btn, paste_controls }) - .modal(true, |s: &mut H| close(s, &mut Tx::default())); + .modal_tx(true, |s: &mut H, tx| close(s, tx)); // `` (`providers/connect/mcp-sign-in.tsx`). ui::fixed_modal("mcp-sign-in", p, DialogSize::Normal, win, card) } @@ -547,7 +548,7 @@ fn build_card(x: &SignIn, p: &Pal, controls: Controls) -> El { let mut paste = col() .key("mcp-sign-in-form") .w_full() - .gap(20.0) + .gap(8.0) .child(col().w_full().gap(8.0).child(text(label).font(LABEL).color(p.text)).child(paste_controls.field)); if let Some(e) = paste_controls.error { paste = paste.child( @@ -557,21 +558,17 @@ fn build_card(x: &SignIn, p: &Pal, controls: Controls) -> El { .font(TextStyle::new(12.0, 440.0).lh(16.0)) .color(p.danger) .wrap() - .w_full() - .mt(-16.0), + .w_full(), ); } body = body.child(paste.child(row().child(paste_controls.submit_btn))); } - ui::overlay(p, col()) + opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::Form) .key("mcp-sign-in") .role("dialog") .label(title) - .radius(6.0) - .fill(p.layer1) .clip_soft(0.0) - .transition(Transition::none()) .motion(Spring::NONE) // `dialog-content`: past the dialog's height its content scrolls, the bar hidden. .child(opencode_ui::scroller::scroller("mcp-sign-in-content").hidden(col().w_full().shrink().min_h(0.0), col().w_full().child(header).child(body))) diff --git a/features/mcp/src/ui.rs b/features/mcp/src/ui.rs index b5238ae88..e3bc8164d 100644 --- a/features/mcp/src/ui.rs +++ b/features/mcp/src/ui.rs @@ -1,92 +1,17 @@ -//! Shared non-generic dialog chrome and status widgets used by the MCPs and MCP sign-in dialogs. - -use rune::{Color, Cx, El, Icon, TextStyle, Transition, col, el, row, text}; -use rune_kit::{Button, ButtonVariant, Loader}; -use opencode_ui::dialog::DialogSize; -use opencode_ui::palette::{Elevate as _, Pal, kit}; +//! MCP's host adapter; shared controls and dialog chrome live in opencode-ui. +use rune::{Cx, El}; +use opencode_ui::palette::Pal; +use opencode_ui::widgets::{DialogSize, Fit}; use crate::McpHost; +pub(crate) use opencode_ui::widgets::{BODY, LABEL, DIALOG_CLOSE, button, status_row, modal}; +pub use opencode_ui::widgets::{status_ink, status_dot}; +pub(crate) const TITLE: rune::TextStyle = opencode_ui::dialog::TITLE; -/// `dialog-title`: 15 on 20 at 530. -pub(crate) const TITLE: TextStyle = TextStyle::new(15.0, 530.0).lh(20.0).tracking(-0.13); -/// Desktop's body copy in its views: 13 on 20 at 440, tracking -0.04. -pub(crate) const BODY: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04); -/// 13 on 16 at 530 (`line-height-compact`). -pub(crate) const LABEL: TextStyle = TextStyle::new(13.0, 530.0).lh(16.0).tracking(-0.04); - -/// The dialog's own close cross (`overlays/dialog/dialog.tsx`): a 1 pt stroke corner to corner. -pub(crate) static DIALOG_CLOSE: Icon = Icon { - name: "dialog-close", - view: 16.0, - body: r#""#, -}; - -/// `button-v2` at size normal: 28 tall, 11 in from each side, 6 pt corners, tabular numerals. -#[allow(deprecated)] -pub(crate) fn button(label: impl Into, variant: ButtonVariant) -> Button { - let label = label.into(); - Button::new(label.clone()) - .variant(variant) - .size(rune_kit::ButtonSize::Normal) - .label_with(move |font, ink| text(label).key("label").font(font.features("\"tnum\"")).color(ink)) -} - -/// Desktop's `Loader` beside muted words: a sign-in or check under way. -pub(crate) fn status_row(p: &Pal, key: &str, label: &str) -> El { - row() - .key(key.to_owned()) - .role("status") - .label(label.to_owned()) - .gap(8.0) - .center_y() - .child(Loader::new().size(16.0).build(kit(p))) - .child(text(label.to_owned()).font(BODY).color(p.muted)) -} - -/// `--v2-elevation-overlay` on a dialog surface. -pub(crate) fn overlay(p: &Pal, e: El) -> El { - e.elevate(p.overlay) -} - -/// The window a dialog clamps its size to, in zoomed points. pub(crate) fn dialog_window(s: &H, cx: &Cx) -> [f32; 2] { - let zoom = s.zoom().max(0.5); - cx.layout_size("zoom").unwrap_or([1280.0 / zoom, 820.0 / zoom]) -} - -/// A dialog's scrim and centring layer. -pub(crate) fn modal(key: &str, p: &Pal, dialog: El, top: Option) -> Vec { - let scrim = el().key(format!("{key}-scrim")).absolute(0.0, 0.0).w_full().h_full().fill(p.scrim).transition(Transition::none()); - let mut layer = col().key(format!("{key}-modal")).absolute(0.0, 0.0).w_full().h_full().items_center().transition(Transition::none()); - layer = match top { - Some(t) => layer.pt(t), - None => layer.center(), - }; - vec![scrim, layer.child(dialog).raise()] + opencode_ui::widgets::dialog_window(cx, s.zoom()) } -/// Fixed-height modal sized from a [`DialogSize`] preset over its scrim. pub(crate) fn fixed_modal(key: &str, p: &Pal, size: DialogSize, win: [f32; 2], card: El) -> Vec { - modal(key, p, card.w(size.width(win[0])).h(size.height(win[1])), None) -} - -/// A status dot's colour (`.mcp-status-dot`): Desktop's v1 `icon-success-base`, -/// `icon-critical-base` and `icon-warning-base`, or a chosen theme's v2 state colours. -pub fn status_ink(p: &Pal, status: &str) -> Color { - let v1 = |light: &str, dark: &str, or: Color| if p.theme == 0 { rune::color::hex(if p.dark { dark } else { light }).unwrap_or(or) } else { or }; - match status { - "connected" | "active" => v1("#0abe00", "#089b00", p.success), - "failed" => v1("#fa3012", "#cb321c", p.danger), - "needs_auth" => p.v1_icon_warning, - _ => p.icon_faint, - } -} - -/// The MCP status dot (`.mcp-status-dot`): filled green, red or amber, a ring when disabled, -/// faint while connecting. -pub fn status_dot(p: &Pal, status: &str) -> El { - let ink = status_ink(p, status); - let dot = el().key("mcp-status-dot").size(6.0, 6.0).radius(3.0); - let dot = if status == "disabled" { dot.border(1.0, ink) } else { dot.fill(ink) }; - el().key("mcp-status").size(16.0, 16.0).center().child(dot) + opencode_ui::widgets::sized_modal(key, p, size, Fit::Fixed, win, card) } diff --git a/features/mcp/src/view.rs b/features/mcp/src/view.rs index f9b5318b1..e3fee2d76 100644 --- a/features/mcp/src/view.rs +++ b/features/mcp/src/view.rs @@ -88,7 +88,7 @@ pub fn dialog(s: &H, p: &Pal, win: [f32; 2], hover_none: b _ => list(s, p, open, win[0] < 640.0 || hover_none), }; let (card, top) = build_dialog_card(p, win, body); - let card = card.modal(true, |s: &mut H| crate::close_dialog(s, &mut Tx::default())); + let card = card.modal_tx(true, |s: &mut H, tx| { crate::close_dialog(s, tx); tx.animated(); }); ui::modal("mcp", p, card, Some(top)) } @@ -155,7 +155,7 @@ pub fn trailing(s: &H, p: &Pal, dir: &str, m: &McpServer) fn detail(s: &H, p: &Pal, dir: &str, name: &str, error: &str, copied: bool) -> El { let busy = crate::detail_busy(s, dir, name); let back = back_button_shell(p).on_press_tx(|s: &mut H, tx: &mut Tx| crate::close_detail_from_ui(s, tx)); - let close = close_button_shell(p).on_press_tx(|s: &mut H, tx: &mut Tx| crate::close_dialog(s, tx)); + let close = close_button_shell(p).on_press_tx(|s: &mut H, tx: &mut Tx| { crate::close_dialog(s, tx); tx.animated(); }); let details = opencode_i18n::t!("dialog.mcp.error.details", name = name, error = error); let (d1, n1, d2, n2) = (dir.to_owned(), name.to_owned(), dir.to_owned(), name.to_owned()); let error_text = error.to_owned(); @@ -188,16 +188,13 @@ struct DetailButtons { /// `` (`providers/connect/mcp-dialog.tsx`). fn build_dialog_card(p: &Pal, win: [f32; 2], body: El) -> (El, f32) { let size = DialogSize::Large; - let card = ui::overlay(p, col()) + let card = opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::List) .key("mcp-dialog") .role("dialog") .label_static(opencode_i18n::t!("dialog.mcp.title")) .w(size.width(win[0])) .max_h(size.height(win[1])) - .radius(12.0) - .fill(p.bg_base) .clip_soft(0.0) - .transition(Transition::none()) .motion(Spring::NONE) .child(body); (card, size.top(win[1])) @@ -211,7 +208,7 @@ fn search_input_shell(edit: &rune::TextEdit, p: &Pal) -> El { .shrink() .min_w(0.0) .color(p.text) - .placeholder(opencode_i18n::t!("dialog.mcp.search.placeholder"), p.text.alpha(p.text.a * 0.5)) + .placeholder(opencode_i18n::t!("dialog.mcp.search.placeholder"), p.faint) .caret(p.text, p.selection) .selection_style(p.field_selection) .label_static(opencode_i18n::t!("dialog.mcp.search.placeholder")) diff --git a/features/session-menu/src/view.rs b/features/session-menu/src/view.rs index 3a25ca1a3..f8052a6cb 100644 --- a/features/session-menu/src/view.rs +++ b/features/session-menu/src/view.rs @@ -3,11 +3,10 @@ use opencode_i18n::t; use opencode_ui::popup::{self, PopupHost}; -use opencode_ui::widgets::{BODY, DialogSize, Fit, button, dialog_window, sized}; -use rune::{Color, Cx, Direction, El, TextStyle, Tx, col, el, row, spacer, text}; +use opencode_ui::widgets::{BODY, DialogSize, Fit, button, dialog_window}; +use rune::{Cx, Direction, El, TextStyle, Tx, col, row, spacer, text}; use rune_kit::ButtonVariant; -use opencode_ui::palette::flat; -use opencode_ui::palette::{Elevate as _, Pal, kit}; +use opencode_ui::palette::{Pal, kit}; use crate::host::SessionMenuHost; use crate::{Line, Spot, Target}; @@ -71,33 +70,27 @@ pub fn confirm(s: &H, p: &Pal, cx: &Cx) -> Vec< // Delete closes the dialog at once (the delete waits for its undo toast), so its buttons are // never off waiting for the server, as Desktop's are. let cancel = button(t!("common.cancel"), ButtonVariant::Ghost) - .on_press_tx(|s: &mut H, tx: &mut Tx| crate::cancel_delete(s, tx)) + .on_press_tx(|s: &mut H, tx: &mut Tx| { crate::cancel_delete(s, tx); tx.animated(); }) .build(k) .key("delete-cancel") .autofocus(); - // `danger` (`button.css:102-106`): the neutral surface and its elevation, in the danger ink. - // Dark's neutral fill is `alpha-light-6`, which Chromium lays over the dialog's `layer-01`, - // where the theme's token is flattened over `bg-base`. Opaque, as the elevation's ring and - // drop would show through a translucent fill. + // The semantic danger surface remains visible at rest in dark mode. let delete = button(t!("session.delete.button"), ButtonVariant::Danger) - .on_press_tx(|s: &mut H, tx: &mut Tx| crate::delete_session(s, tx)) + .on_press_tx(|s: &mut H, tx: &mut Tx| { crate::delete_session(s, tx); tx.animated(); }) .build(k) .key("delete-confirm"); - let delete = if p.dark && p.theme == 0 { delete.fill(flat(Color::WHITE.alpha(0.06), p.layer1)) } else { delete }; - // `` (`shell/titlebar/project-session-row.tsx`): the normal size, 6 pt corners on `layer-01` with the + let delete = opencode_ui::widgets::danger_surface(p, delete); + // `` (`shell/titlebar/project-session-row.tsx`): the normal size, shared 12 pt corners on `layer-01` with the // overlay elevation; a 16 pt header with the title (15/20 at 530) 4 over the description // (13/20 at 440, muted), and a 16 pt footer, its buttons 8 apart at its end. - let card = col() + let card = opencode_ui::widgets::dialog_card(p, opencode_ui::widgets::DialogKind::Form) .key("delete-card") .role("dialog") .label_static(t!("session.delete.title")) - .radius(6.0) - .fill(p.layer1) - .elevate(p.overlay) .clip_soft(0.0) // Rune's modal: Tab stays inside, Escape and a press outside cancel, Cancel opens focused // (`autofocus` in `controller.tsx`) and closing hands focus back. - .modal_tx(true, |s: &mut H, tx: &mut Tx| crate::cancel_delete(s, tx)) + .modal_tx(true, |s: &mut H, tx: &mut Tx| { crate::cancel_delete(s, tx); tx.animated(); }) .child( col() .key("delete-header") @@ -108,11 +101,7 @@ pub fn confirm(s: &H, p: &Pal, cx: &Cx) -> Vec< .child(text(t!("session.delete.confirm", name = name)).font(BODY).color(p.muted).wrap().w_full()), ) .child(row().key("delete-footer").w_full().padding(16.0).gap(8.0).child(spacer()).child(cancel).child(delete)); - let card = sized(card, DialogSize::Normal, Fit::Content, dialog_window(cx, s.zoom())); - vec![ - el().key("delete-scrim").absolute(0.0, 0.0).w_full().h_full().fill(p.scrim), - el().key("delete-modal").absolute(0.0, 0.0).w_full().h_full().center().child(card).raise(), - ] + opencode_ui::widgets::sized_modal("delete", p, DialogSize::Normal, Fit::Content, dialog_window(cx, s.zoom()), card) } /// `lines` as the drawn menu draws them through [`SessionMenuHost::popup_surface`], item `hot` diff --git a/features/timeline-extras/src/todos.rs b/features/timeline-extras/src/todos.rs index ee448b68d..f4c558c00 100644 --- a/features/timeline-extras/src/todos.rs +++ b/features/timeline-extras/src/todos.rs @@ -12,7 +12,7 @@ use rune::{El, Icon, Shape, TextStyle, Tween, Tx, canvas, col, el, icon, row, te use rune_knobs::{Group, Knob, Knobs}; use serde_json::Value; use session_view::focus::FocusExt; -use session_view::palette::{Elevate as _, Pal}; +use session_view::palette::Pal; use session_view::style::{INSTANT, UI}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -370,7 +370,7 @@ pub fn panel(host: &H, p: &Pal, id: &str) -> Option // own, and changes at once; only a finishing todo's fill springs, on its own curves. let viewport = col().transition(rune::Transition::none()).w_full().max_h(MAX_H).scroll_edge_fade(12.0).scroll_margin(PAD).motion(rune::Spring::NONE); let rows = session_view::scroller::scroller("todo-scroll").bar(session_view::scroller::Bar::MenuScroll).build::(p, viewport, content.list); - Some(build_panel_frame(host.knobs(), p, content.width, content.label, rows).on_press(|_: &mut H| {})) + Some(build_panel_frame::(host.knobs(), p, content.width, content.label, rows).on_press(|_: &mut H| {})) } struct PanelContent { @@ -399,6 +399,8 @@ fn build_panel_content(host: &dyn TodosHost, p: &Pal, id: &str) -> Option Option El { - col().key("todo-panel").role("dialog").label(label).above("todo-pill", 8.0).w(width).radius(10.0) - .fill(p.layer1).elevate(p.floating).clip_soft(0.0) +fn build_panel_frame(knobs: &Knobs, p: &Pal, width: f32, label: String, rows: El) -> El { + session_view::popover::surface::(p, session_view::popover::LIST, "todo-panel", label) + .role("dialog").above("todo-pill", 8.0).w(width).clip_soft(0.0) .transition(session_view::popover::motion::transition(knobs, rune::Side::Top, rune::Align::Start)) .child(rows) } @@ -528,7 +530,7 @@ static CANCELLED: Icon = Icon { body: r#""#, }; const PILL_TEXT_MAX: f32 = 260.0; -const PAD: f32 = 4.0; +const PAD: f32 = session_view::popover::LIST.inset; const MAX_H: f32 = 232.0; const WIDEST: f32 = 400.0; const TALLEST: f32 = 2000.0; diff --git a/scripts/cursor-allow.txt b/scripts/cursor-allow.txt index 6da090af4..d46822036 100644 --- a/scripts/cursor-allow.txt +++ b/scripts/cursor-allow.txt @@ -64,7 +64,7 @@ apps/desktop/src/plugin_host/ui/nodes.rs | NotAllowed | 1 | a plugin's disabled # The arrow over what Rune would give the hand: a plain link in official has no cursor of its own crates/session-view/src/turn_errors.rs | Default | 1 | a limit notice's Switch model: a plain button, packages/session-ui/src/timeline-next/row.tsx:1536 crates/session-view/src/timeline/tail.rs | Help | 1 | a retry's countdown and message in the turn's tail, its message line: packages/session-ui/src/components/session-retry.tsx:75 cursor-help -features/connect/src/welcome.rs | Default | 1 | the usage link: an ExternalLink with no cursor rule, packages/app/src/providers/connect/chatgpt-welcome.tsx:24; base.css:84 +features/connect/src/welcome.rs | Pointer | 1 | navigable usage link, packages/app/src/providers/connect/chatgpt-welcome.tsx:24; intentional pointer affordance instead of base.css:84's default features/settings/src/pages/about/notices.rs | Default | 2 | a notice's name: an ExternalLink outside .settings-about-content, packages/app/src/settings/about/notices/dialog.tsx:34; base.css:84 features/settings/src/pages/providers.rs | Default | 1 | View all providers: Desktop's reset names .settings-providers-view-all (styles.css:15) @@ -73,7 +73,7 @@ crates/opencode-ui/src/style.rs | link | 1 | not a text link: the Markdown style crates/session-view/src/timeline/parts.rs | link | 1 | a link in a user message: packages/session-ui/src/components/message-part.css:200 [data-slot=user-message-link] pointer crates/session-view/src/tools/plain.rs | link | 1 | a URL in a tool's text: official's linked-text-link is a plain , the arrow (packages/ui/src/styles/base.css:84): link_cursor(Cursor::Default) follows it crates/session-view/src/turn_errors.rs | link | 1 | Switch model, with the arrow (see its Default above) -features/connect/src/welcome.rs | link | 1 | the usage link, with the arrow (see its Default above) +features/connect/src/welcome.rs | link | 1 | the usage link, with a pointer (see its Pointer above) features/settings/src/rows.rs | link | 1 | a.settings-link: packages/app/src/settings/settings.css:777 pointer features/settings/src/pages/about.rs | link | 3 | .settings-about-content a and .settings-about-link: packages/app/src/settings/settings.css:395 and :410 pointer features/settings/src/pages/about/notices.rs | link | 2 | a notice's name, with the arrow (see its Default above)