From 04e5287953e52433e4a3421866402192b0c586aa Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 5 Dec 2026 22:03:59 -0800 Subject: [PATCH] fix(session-view): align composer spine, whisper-tint MCP chips, docks, shimmer, and execute tokens --- crates/session-view/src/activity/mod.rs | 52 +++++--- .../session-view/src/composer/attachments.rs | 16 ++- crates/session-view/src/composer/mod.rs | 50 ++++---- crates/session-view/src/dock/mod.rs | 6 +- crates/session-view/src/dock/permission.rs | 24 ++-- .../session-view/src/dock/question/classic.rs | 16 +-- .../src/dock/question/composer.rs | 6 +- crates/session-view/src/tools/codemode.rs | 111 ++++++++++-------- crates/session-view/src/tools/details.rs | 75 +++--------- crates/session-view/src/turns/labels.rs | 5 +- crates/session-view/src/user_parts.rs | 12 +- crates/session-view/src/working.rs | 37 +++--- features/dictation/src/view.rs | 2 +- 13 files changed, 203 insertions(+), 209 deletions(-) diff --git a/crates/session-view/src/activity/mod.rs b/crates/session-view/src/activity/mod.rs index 218068a3a..776bd7f55 100644 --- a/crates/session-view/src/activity/mod.rs +++ b/crates/session-view/src/activity/mod.rs @@ -8,31 +8,45 @@ pub mod events; pub mod label; pub mod rules; -use rune::{El, row, text}; +use rune::{Color, El, TextStyle, row, text}; use crate::palette::Pal; +use crate::style::{UI, align_baseline}; + +pub const BADGE_H: f32 = 18.0; +pub const BADGE_PX: f32 = 5.0; +pub const BADGE_RADIUS: f32 = 4.0; +const TAG: TextStyle = TextStyle::new(11.0, 530.0).lh(16.0).tracking(0.04); + +/// Soft borderless ~5.5% dark / ~4.8% light whisper surface tint derived from `p.text`. +pub fn whisper_tint(p: &Pal) -> Color { + p.text.alpha(if p.dark { 0.058 } else { 0.048 }) +} + +/// Shared borderless whisper-tint timeline micro-badge (`18 pt` height, `5 pt` inline pad, +/// `4 pt` radius, baseline-aligned onto `UI`), adding a high-contrast edge only when `p.forced`. +pub fn micro_badge(p: &Pal, key: impl Into, font: TextStyle, fill: Color, forced_ring: Color, child: El) -> El { + let mut b = row() + .key(key.into()) + .h(BADGE_H) + .px(BADGE_PX) + .center_y() + .radius(BADGE_RADIUS) + .fill(fill) + .child(child); + if p.forced { + b = b.box_shadow(Pal::ring_in(forced_ring)); + } + align_baseline(b, UI, font) +} /// Desktop's `Badge` after a row's words: "Failed", "Exit 1", "Stopped". `danger` in the -/// danger state's colours, else neutral. -/// `[data-component="tag"]` (`badge.css:1-39`): 16 tall, 4 in, 2 round, 0.5 border, 11 at 530. +/// danger state's colours, else neutral whisper tint. pub fn tag(p: &Pal, label: &str, danger: bool) -> El { - let (fill, border, ink) = if danger { + let (fill, ring, ink) = if danger { (p.danger_bg, p.danger_border, p.danger) } else { - (p.layer2, p.border, p.muted) + (whisper_tint(p), p.border, p.muted) }; - row() - .key(format!("tag-{label}")) - .h(16.0) - .px(4.0) - .center() - .radius(2.0) - .border(0.5, border) - .border_layout() - .fill(fill) - // `badge.css:15-17` (`11px / line-height: 1` inside 16 pt box): nudge +1 pt so Inter's - // 11 pt cap-height centers on the same pixel baseline as Chromium (`y+3..y+10`). - .child(text(label.to_owned()).font(TAG).color(ink).offset(0.0, 1.0)) + micro_badge(p, format!("tag-{label}"), TAG, fill, ring, text(label.to_owned()).font(TAG).color(ink)) } - -const TAG: rune::TextStyle = rune::TextStyle::new(11.0, 530.0).lh(11.0).tracking(0.05); diff --git a/crates/session-view/src/composer/attachments.rs b/crates/session-view/src/composer/attachments.rs index f07bf1dff..6c8a967bd 100644 --- a/crates/session-view/src/composer/attachments.rs +++ b/crates/session-view/src/composer/attachments.rs @@ -246,8 +246,10 @@ pub fn reconcile(echoes: &mut Vec<(String, String, String)>, t: &mut Transcript, }); } +/// Shared chip height across image thumbnails, file cards, context cards, and uploads. +const CHIP_H: f32 = 52.0; /// Image and loading footprint (OpenCode 26f2522e60, `packages/app/src/composer/editor/editor.tsx`). -const THUMB: (f32, f32) = (78.0, 52.0); +const THUMB: (f32, f32) = (78.0, CHIP_H); /// Renders the composer's attachment chips: quote cards, image thumbnails, `160px` file /// cards, and in-progress uploads, each with a round hover remove button. @@ -262,7 +264,7 @@ pub fn chips(s: &S, p: &Pal) -> Option { let active_att = s.composer_active_attachment(); let alt_held = s.composer_alt_held(); let focus_ring = rune::Shadow { spread: 2.0, color: p.v2.border_focus, ..rune::Shadow::default() }; - let mut r = row().key("attachments-strip").px(8.0).pt(8.0).pb(4.0).gap(8.0).children(quotes); + let mut r = row().key("attachments-strip").px(16.0).pt(14.0).pb(2.0).gap(8.0).children(quotes); for f in files { let id = identity(f); let att_key = opencode_kit::prompt::inline_attachment_key(f); @@ -364,13 +366,14 @@ pub fn chips(s: &S, p: &Pal) -> Option { } // One row that scrolls sideways with no bar (`editor.tsx:758-910`), and a 24 pt bg-base // fade on each side that shows while chips hide under it (`attachments.css`). + let bg = super::composer_fill(p); let fade = |key: &str, side: &'static std::thread::LocalKey>, angle: f32| { let (left, right) = if angle > 0.0 { (Some(0.0), None) } else { (None, Some(0.0)) }; side.with(|o| { el().key(key.to_owned()) .pin(left, Some(0.0), right, Some(0.0)) .w(24.0) - .linear_gradient(angle, [(0.0, p.bg_base), (1.0, p.bg_base.alpha(0.0))]) + .linear_gradient(angle, [(0.0, bg), (1.0, bg.alpha(0.0))]) .live_opacity(o) .inert() }) @@ -418,7 +421,7 @@ pub fn remove_button( .center() .focus_default(p) .fill(p.icon_muted) - .outline(1.0, 0.0, p.icon_contrast) + .box_shadow(Pal::ring_out(super::composer_fill(p))) .group_opacity(if crate::style::hover_none() { 1.0 } else { 0.0 }, 1.0) .on_press_tx(move |s: &mut S, tx: &mut Tx| { tx.instant(); @@ -434,6 +437,7 @@ pub fn card(p: &Pal, title: &str, subtitle: String) -> El { col() .key("card") .w(160.0) + .h(CHIP_H) .padding(8.0) .gap(6.0) .radius(6.0) @@ -457,6 +461,7 @@ pub fn upload_card(p: &Pal, title: &str, percent: u32) -> El { col() .key("card") .w(160.0) + .h(CHIP_H) .padding(8.0) .gap(6.0) .radius(6.0) @@ -505,10 +510,11 @@ pub fn context_card(p: &Pal, title: &str, icon: El, label: String) -> El { col() .key("card") .w(160.0) + .h(CHIP_H) .padding(8.0) .gap(6.0) .radius(6.0) - .fill(if p.dark { p.hover } else { p.bg_base }) + .fill(p.hover) .box_shadow(Pal::ring_in(p.border)) .child(text(title.to_owned()).font(CARD_TITLE).color(p.text).truncate_fade().w_full()) .child(row().h(16.0).gap(4.0).center_y().child(icon).child(text(label).font(CARD_SUBTITLE).color(p.muted).truncate_fade().shrink().min_w(0.0))) diff --git a/crates/session-view/src/composer/mod.rs b/crates/session-view/src/composer/mod.rs index e9ee61ec3..b4f8c96b6 100644 --- a/crates/session-view/src/composer/mod.rs +++ b/crates/session-view/src/composer/mod.rs @@ -109,8 +109,8 @@ pub fn ghost(p: &Pal, key: &str, label: &str, chevron: bool, color: Color) -> El } /// [`ghost`] around any label: `button-v2` ghost-muted at size normal (`button.css:41-44, -/// 247-283`), 28 tall with 6 pt corners and 11 in from its start. The chevron -/// (`editor.tsx:1108`, `-ms-0.5 -me-1` on the 6 pt gap) sits 4 after the label and 7 in +/// 247-283`), 28 tall with 6 pt corners and 8 in from its start so a leading toolbar label +/// shares the 16 pt composer left spine (`8 + 8`). The chevron sits 4 after the label and 6 in /// from the end, in `icon-icon-muted`, or `icon-icon-base` while its menu is `open`. Its /// keyboard ring sits 2 inside it, where the toolbar's clip can't cut it (`editor.css:70-73`). pub fn ghost_with(p: &Pal, key: &str, label: El, chevron: bool, open: bool) -> El { @@ -118,8 +118,8 @@ pub fn ghost_with(p: &Pal, key: &str, label: El, chevron: bool, open: bool) -> E .key(key) .role("button") .h(28.0) - .pl(11.0) - .pr(if chevron { 7.0 } else { 11.0 }) + .pl(8.0) + .pr(if chevron { 6.0 } else { 8.0 }) .gap(4.0) .center_y() .radius(6.0) @@ -606,23 +606,26 @@ pub fn composer_in(s: &S, p: &Pal, scope: &str) -> El { }; match face { Some(face) => box_el.children(face), - None => box_el - // Clicking empty space on the composer card (padding, gutter, toolbar spacer) puts - // pointer focus in the prompt without a keyboard ring (`field-focus.tsx` `pointer()`), - // instead of blurring it so typing enters via `type_to_compose` as a stray keyboard focus. - .preserve_focus_on_press(true) - .press_on_down() - .on_press_tx(|s: &mut S, tx: &mut Tx| { - if !s.composer_edit().focused { - let end = s.composer_edit().text.len(); - let e = s.composer_edit_mut(); - e.set_selection(end, end); - e.focused = true; - } - tx.focus("prompt", false); - }) + None => { // Shell mode sends no attachments, so it shows none (`editor.tsx:272`). - .children(if s.composer_shell_mode() { None } else { attachments::chips(s, p) }) + let chips = if s.composer_shell_mode() { None } else { attachments::chips(s, p) }; + let has_chips = chips.is_some(); + box_el + // Clicking empty space on the composer card (padding, gutter, toolbar spacer) puts + // pointer focus in the prompt without a keyboard ring (`field-focus.tsx` `pointer()`), + // instead of blurring it so typing enters via `type_to_compose` as a stray keyboard focus. + .preserve_focus_on_press(true) + .press_on_down() + .on_press_tx(|s: &mut S, tx: &mut Tx| { + if !s.composer_edit().focused { + let end = s.composer_edit().text.len(); + let e = s.composer_edit_mut(); + e.set_selection(end, end); + e.focused = true; + } + tx.focus("prompt", false); + }) + .children(chips) .child( col() .key("editor") @@ -688,11 +691,11 @@ pub fn composer_in(s: &S, p: &Pal, scope: &str) -> El { // so they follow its own direction and cover the full 44 pt hit box. .pl(16.0) .pr(12.0 - SCROLLBAR) - .pt(16.0) + .pt(if has_chips { 10.0 } else { 16.0 }) .pb(8.0) .color(p.text) .w_full() - .min_h(20.0 + 16.0 + 8.0) + .min_h(20.0 + if has_chips { 10.0 } else { 16.0 } + 8.0) .animate_edit_layout() .placeholder(placeholder_text, placeholder_color) .caret(p.text, p.selection).selection_style(p.field_selection) @@ -732,6 +735,7 @@ pub fn composer_in(s: &S, p: &Pal, scope: &str) -> El { // Desktop's follows the chat's width; the button's own swaps land at once. .children(submit.map(|b| el().key("submit-slot").size(28.0, 28.0).child(b))) )) - .children(s.composer_below_toolbar(p)), + .children(s.composer_below_toolbar(p)) + } } } diff --git a/crates/session-view/src/dock/mod.rs b/crates/session-view/src/dock/mod.rs index 088215a37..5d404c7fe 100644 --- a/crates/session-view/src/dock/mod.rs +++ b/crates/session-view/src/dock/mod.rs @@ -129,7 +129,7 @@ pub enum Variant { Contrast, } -/// `button-v2` at size large. +/// `button-v2` at normal dock scale (`28 pt` height, matching the composer toolbar). pub fn button(p: &Pal, key: &str, label: &str, variant: Variant, hint: Option<&str>, live: bool) -> El { let (fill, fg) = match variant { Variant::Ghost => (Color::TRANSPARENT, p.text), @@ -145,8 +145,8 @@ pub fn button(p: &Pal, key: &str, label: &str, variant: Variant, hint: Option<&s .key(key) .role("button") .label(label.to_owned()) - .h(32.0) - .px(15.0) + .h(28.0) + .px(12.0) .gap(6.0) .center_y() .radius(6.0) diff --git a/crates/session-view/src/dock/permission.rs b/crates/session-view/src/dock/permission.rs index a013779cb..1cffd5971 100644 --- a/crates/session-view/src/dock/permission.rs +++ b/crates/session-view/src/dock/permission.rs @@ -19,9 +19,9 @@ use rune_theme_opencode::icons as ic; use super::{DockHost, Variant, button, face_transition, morph}; use crate::palette::{Elevate as _, Pal}; -/// `permission-header-title`: 13 px medium on the base line height. -const TITLE: TextStyle = TextStyle::new(13.0, 500.0).lh(20.0); -const HINT: TextStyle = TextStyle::new(13.0, 400.0).lh(20.0); +/// `permission-header-title`: 13 px Inter optical 530/440 on the base line height. +const TITLE: TextStyle = TextStyle::new(13.0, 530.0).lh(20.0).tracking(-0.04); +const HINT: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04); /// Queue position (`1 of 3`): muted tabular digits so width stays steady as the queue drains. const COUNTER: TextStyle = TextStyle::new(12.0, 440.0).lh(20.0).features("\"tnum\""); /// `permission-action`, `permission-input code` and `permission-patterns code`. @@ -276,7 +276,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { .w_full() .gap(8.0) .center_y() - .child(el().key("permission-icon").size(ICON_W, 20.0).center().child(icon(&ic::WARNING, 16.0).color(p.v1_icon_warning))) + .child(el().key("permission-icon").size(ICON_W, 20.0).center().child(icon(&ic::WARNING, 16.0).color(p.warning))) .child(text(opencode_i18n::t!("notification.permission.title")).key("permission-title").font(TITLE).color(p.text).shrink()) .children(origin.map(|who| { row() @@ -303,7 +303,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { let input = (!input.is_empty()).then(|| { // A plain `overflow-y: auto` box's bar (`message-part.css:1583-1586`). let list = col().key("permission-input-list").w_full().gap(2.0).children(input.iter().enumerate().map(|(i, line)| { - text(line.clone()).key(format!("input-{i}")).font(CODE).color(p.v1_text_weak).wrap_anywhere() + text(line.clone()).key(format!("input-{i}")).font(CODE).color(p.muted).wrap_anywhere() })); crate::scroller::scroller("permission-input").build::(p, col().w_full().max_h(INPUT_MAX_H).mt(8.0), list) }); @@ -311,25 +311,25 @@ pub fn face(s: &S, p: &Pal) -> Option> { // The user approves every command in this list, so its scrollbar thumb stays visible without // hover whenever the list overflows (`message-part.css:1747-1766`, `opencode#68250`). let list = col().key("permission-pattern-list").w_full().gap(6.0).pt(1.0).pb(8.0).children(resources.iter().enumerate().map(|(i, r)| { - text(r.clone()).key(format!("pattern-{i}")).font(CODE).color(p.v1_text_base).wrap_anywhere() + text(r.clone()).key(format!("pattern-{i}")).font(CODE).color(p.text).wrap_anywhere() })); crate::scroller::scroller("permission-patterns") .always_visible() - .build::(p, col().w_full().max_h(PATTERNS_MAX_H).scroll_edge_fade(16.0).mt(8.0).mb(16.0), list) + .build::(p, col().w_full().max_h(PATTERNS_MAX_H).scroll_edge_fade(16.0).mt(8.0).mb(12.0), list) }); let body = col() .key("permission") .w_full() - .px(12.0) - .pt(12.0) - .gap(16.0) + .px(16.0) + .pt(14.0) + .gap(12.0) .child(header) // Keyed by request: the next one's words fade in over the last's instead of swapping. .child(col().key(format!("permission-{id}")).w_full().pl(INDENT).gap(4.0).transition(fade()).child(what).children(message).children(input).children(patterns)); let live = !s.dock_busy(&id); let answer = |key: &str, label: &str, variant: Variant, decision: &'static str| { let id = id.clone(); - let b = button(p, key, label, variant, None, live).h(28.0).px(12.0); + let b = button(p, key, label, variant, None, live); if live { b.on_press_tx(move |s: &mut S, tx: &mut Tx| decide(s, &id, decision, tx)) } else { b } }; let footer = row() @@ -360,7 +360,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { .focusable(true) .tab_index(-1) .w_full() - .radius(12.0) + .radius(crate::composer::RADIUS) .fill(crate::composer::composer_fill(p)) .box_shadow(Pal::ring_out(p.bg_base)) .elevate(p.raised) diff --git a/crates/session-view/src/dock/question/classic.rs b/crates/session-view/src/dock/question/classic.rs index c63b1247f..c54388c7a 100644 --- a/crates/session-view/src/dock/question/classic.rs +++ b/crates/session-view/src/dock/question/classic.rs @@ -32,8 +32,8 @@ pub(super) const INPUT: TextStyle = TextStyle::new(13.0, 440.0).lh(18.0); fn custom_label() -> &'static str { opencode_i18n::t!("ui.question.custom.answerPlaceholder") } -/// The footer tray's height: 16 pt over and 8 pt under the 32 pt buttons, inside its borders. -const TRAY_H: f32 = 57.0; +/// The footer tray's height: 16 pt over and 8 pt under the 28 pt buttons, inside its borders. +const TRAY_H: f32 = 53.0; /// How far the tray tucks up under the body (`margin-block-start: -9px`). const TUCK: f32 = 9.0; /// The gap the dock keeps from the top of the pane (`measure`'s `gap`), and its floor. @@ -142,11 +142,11 @@ pub fn face(s: &S, p: &Pal) -> Option> { let body = col() .key("question") .w_full() - .pt(8.0) - .px(12.0) + .pt(10.0) + .px(16.0) .pb(12.0) - .gap(16.0) - .radius(10.0) + .gap(12.0) + .radius(crate::composer::RADIUS) .fill(p.bg_base) .transition(fade()) .child(header) @@ -160,7 +160,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { let last = f.last(tab); // Both labels keep their room so the button doesn't change width between Next and Submit. - let advance_w = [opencode_i18n::t!("ui.common.next"), opencode_i18n::t!("ui.common.submit")].map(|l| rune::text::measure(l, &[], BUTTON, None).0).into_iter().fold(0.0, f32::max) + 30.0; + let advance_w = [opencode_i18n::t!("ui.common.next"), opencode_i18n::t!("ui.common.submit")].map(|l| rune::text::measure(l, &[], BUTTON, None).0).into_iter().fold(0.0, f32::max) + 24.0; let submit = super::submit_keys(s.dock_question_submit()); let back = crate::keymap::Bind::QuestionBack.keycaps(); let footer = row() @@ -174,7 +174,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { // whole device pixels and lays out as such (`border_layout`: 1 pt each side at 1x, 0.667 // at 1.5x). It sits under the body's bottom edge (`paint_order`), so the body's shadow // falls on it. - .corners([0.0, 0.0, 10.0, 10.0]) + .corners([0.0, 0.0, crate::composer::RADIUS, crate::composer::RADIUS]) .fill(p.layer1) .border_sides([0.5, 0.5, 0.5, 0.5], p.border) .border_layout() diff --git a/crates/session-view/src/dock/question/composer.rs b/crates/session-view/src/dock/question/composer.rs index b68365a70..ddc1d7573 100644 --- a/crates/session-view/src/dock/question/composer.rs +++ b/crates/session-view/src/dock/question/composer.rs @@ -206,7 +206,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { .pl(16.0) .pr(16.0) .gap(if first_has_desc { 4.0 } else { 2.0 }) - .radius(10.0) + .radius(crate::composer::RADIUS) .fill(p.bg_base) .transition(fade()) .child(header) @@ -344,7 +344,7 @@ pub fn face(s: &S, p: &Pal) -> Option> { .padding(8.0) .gap(4.0) .items_end() - .radius(12.0) + .radius(crate::composer::RADIUS) .fill(if p.dark { p.layer1 } else { p.bg_base }) .elevate(p.raised) .transition(fade()) @@ -439,7 +439,7 @@ fn option_mark(p: &Pal, multi: bool, picked: bool) -> El { /// `opencode#68047`): `Submit` variant on the last question, `Neutral` before it, normal 28 pt height. fn composer_advance_button(p: &Pal, last: bool, label: &'static str, submit_keys: Vec, live: bool) -> El { let variant = if last { Variant::Submit } else { Variant::Neutral }; - let b = button(p, "q-next", label, variant, None, live).h(28.0).px(12.0); + let b = button(p, "q-next", label, variant, None, live); if !live { return b; } diff --git a/crates/session-view/src/tools/codemode.rs b/crates/session-view/src/tools/codemode.rs index 8350f09e9..13845b171 100644 --- a/crates/session-view/src/tools/codemode.rs +++ b/crates/session-view/src/tools/codemode.rs @@ -20,50 +20,61 @@ use super::{Call, Ctx, Display, Press, Trigger, body, disclosure, field, file_na use crate::TimelineHost; use crate::focus::FocusExt; use crate::palette::Pal; -use crate::style::{HOVER_FADE, INSTANT, TOOL_CODE, UI, arrow, readable}; +use crate::activity::{BADGE_PX, micro_badge, whisper_tint}; +use crate::style::{HOVER_FADE, INSTANT, UI, arrow, readable}; use crate::turns::codemode::{ CODEMODE_LLM_TOOL, CODEMODE_SEARCH_TOOL, normalized_tool_name, repeat_count_of, script_runtime_error, split_tool_namespace, }; const CHIP_FONT: TextStyle = TextStyle::new(12.0, 440.0).mono().lh(16.0); -const BADGE_FONT: TextStyle = TextStyle::new(11.0, 530.0).mono().lh(11.0).tracking(0.05).features("\"tnum\""); -const PILL_FONT: TextStyle = TextStyle::new(11.0, 440.0).mono().lh(16.0); +const BADGE_FONT: TextStyle = TextStyle::new(11.0, 530.0).mono().lh(16.0).tracking(0.04).features("\"tnum\""); -/// Compact `×N` count badge for consecutive identical calls collapsed from a Code Mode loop -/// (`RepeatBadge`, `codemode-tools.tsx:12-22`). +/// Compact borderless whisper-tint `×N` count badge for consecutive identical calls collapsed +/// from a Code Mode loop (`RepeatBadge`, `codemode-tools.tsx:12-22`). pub fn repeat_badge(p: &Pal, count: Option) -> Option { let n = count.filter(|&n| n > 1)?; let label = opencode_i18n::t!("ui.timeline.codemode.repeatCount", count = n.to_string()); Some( - row() - .key("codemode-repeat-badge") - .role("status") - .label(label.clone()) - .h(16.0) - .px(4.0) - .center() - .radius(2.0) - .fill(p.layer2) - .border(0.5, p.border) - .child(text(label).font(BADGE_FONT).color(p.muted).a11y_hidden()), + micro_badge( + p, + "codemode-repeat-badge", + BADGE_FONT, + whisper_tint(p), + p.border, + text(label.clone()).font(BADGE_FONT).color(p.muted).a11y_hidden(), + ) + .role("status") + .label(label), ) } -/// Inline monospace chip showing a raw MCP/arbitrary tool namespace (`NamespaceChip`, -/// `codemode-tools.tsx:25-27`, `timeline-next.css:713-727`). +/// Collapsed activity summary server chip: borderless whisper-tint pill in proportional `UI` font +/// with `p.text` ink and an `"MCP tool"` hover tooltip. pub fn namespace_chip(p: &Pal, name: &str) -> El { - row() - .key(format!("ns-{name}")) - .px(5.0) - .h(18.0) - .center_y() - .radius(5.0) - .fill(p.layer2) - // Multiply existing border alpha by 0.7 (`color-mix(in srgb, border-base 70%, transparent)`), - // and lay out the 1 pt border outside the 5 pt horizontal padding (`timeline-next.css:713-726`). - .border(1.0, p.border.alpha(p.border.a * 0.7)) - .border_layout() - .child(text(name.to_owned()).font(CHIP_FONT).color(p.text)) + micro_badge( + p, + format!("ns-{name}"), + UI, + whisper_tint(p), + p.border, + text(name.to_owned()).font(UI).color(p.text), + ) + .help("MCP tool") + .help_above() +} + +/// Expanded `Called` row chip: borderless whisper-tint monospace pill styling `namespace` in +/// `p.muted`, `.` in `p.faint`, and `method` in `p.text`. +fn called_chip(p: &Pal, name: &str) -> El { + let mut lbl = text(name.to_owned()).dir(rune::Direction::Ltr).font(CHIP_FONT).color(p.text); + if let Some((ns, _)) = split_tool_namespace(name) { + let dot = ns.len(); + lbl = lbl.spans(vec![ + rune::Span::new(0, dot).color(p.muted), + rune::Span::new(dot, dot + 1).color(p.faint), + ]); + } + micro_badge(p, format!("ns-{name}"), CHIP_FONT, whisper_tint(p), p.border, lbl) } /// Unflattened `Script` row (`ScriptTool`, `timeline-next/tools/script.tsx`), used for 0-call @@ -167,14 +178,15 @@ pub fn mcp_expandable_in(input: &Value, tool_name: &str, repeat: Option, av return true; } let called_w = rune::text::measure(opencode_i18n::t!("ui.timeline.codemode.called"), &[], UI, None).0; + let pad = 2.0 * BADGE_PX; let chip_w = if split_tool_namespace(tool_name).is_some() { - rune::text::measure(tool_name, &[], CHIP_FONT, None).0 + 12.0 + 6.0 + rune::text::measure(tool_name, &[], CHIP_FONT, None).0 + pad + 6.0 } else { 0.0 }; let badge_w = repeat.filter(|&n| n > 1).map_or(0.0, |n| { let lbl = opencode_i18n::t!("ui.timeline.codemode.repeatCount", count = n.to_string()); - rune::text::measure(&lbl, &[], BADGE_FONT, None).0 + 10.0 + 6.0 + rune::text::measure(&lbl, &[], BADGE_FONT, None).0 + pad + 6.0 }); let mut inline = String::from("("); for (idx, (k, v)) in obj.iter().take(3).enumerate() { @@ -270,7 +282,7 @@ pub fn mcp_tool(s: &S, p: &Pal, cx: Ctx, c: &Call) -> El { }; let mut words = row().key("words").gap(6.0).center_y().shrink().min_w(0.0).child(title); if split_tool_namespace(c.name).is_some() { - words = words.child(crate::style::align_baseline(namespace_chip(p, c.name), UI, CHIP_FONT)); + words = words.child(called_chip(p, c.name)); } if !entries.is_empty() && !(expandable && d.open()) { // Build the entire `(k1: v1, k2: v2, ...)` preview as one styled text run so earlier @@ -384,37 +396,40 @@ pub fn mcp_tool(s: &S, p: &Pal, cx: Ctx, c: &Call) -> El { .ceil(); let mut grid = col().key("codemode-params-grid").w_full().gap(5.0); for (k, v) in &entries { + let mut key_el = text((*k).clone()).w(key_w).font(CHIP_FONT).color(p.muted); let val_el = if let Some(items) = is_primitive_array(v) { + key_el = key_el.pt(1.0); let mut pills = row().key("pills").flex_wrap().gap(4.0).grow(1.0).shrink().min_w(0.0); for item in items { let s = match item { Value::String(s) => s.clone(), other => other.to_string(), }; - pills = pills.child( - row() - .px(5.0) - .h(18.0) - .center_y() - .radius(4.0) - .fill(p.bg_base) - .border(0.5, p.border) - .child(text(s).font(PILL_FONT).color(p.text)), - ); + let mut pill = row() + .px(5.0) + .h(18.0) + .center_y() + .radius(4.0) + .fill(whisper_tint(p)) + .child(text(s).font(CHIP_FONT).color(p.text)); + if p.forced { + pill = pill.box_shadow(Pal::ring_in(p.border)); + } + pills = pills.child(pill); } pills } else if v.is_array() || v.is_object() { + key_el = key_el.pt(6.0); let pretty = serde_json::to_string_pretty(v).unwrap_or_default(); let vp = col().w_full().max_h(180.0); - let inner = col().w_full().px(8.0).py(6.0).child(readable(p, text(pretty).font(PILL_FONT).color(p.text).wrap())); + let inner = col().w_full().px(8.0).py(6.0).child(readable(p, text(pretty).font(CHIP_FONT).color(p.text).wrap())); col() .grow(1.0) .shrink() .min_w(0.0) - .mt(2.0) .radius(4.0) .fill(p.bg_base) - .border(0.5, p.border) + .box_shadow(Pal::ring_in(p.border)) .clip_rounded(4.0) .child(crate::scroller::scroller(format!("json-{k}")).hidden(vp, inner)) } else { @@ -425,14 +440,14 @@ pub fn mcp_tool(s: &S, p: &Pal, cx: Ctx, c: &Call) -> El { Value::String(s) => (s.clone(), p.text), other => (other.to_string(), p.text), }; - readable(p, text(s).font(TOOL_CODE.lh(16.0)).color(ink).wrap_anywhere()).grow(1.0).shrink().min_w(0.0) + readable(p, text(s).font(CHIP_FONT).color(ink).wrap_anywhere()).grow(1.0).shrink().min_w(0.0) }; grid = grid.child( row() .w_full() .gap(14.0) .items_start() - .child(text((*k).clone()).w(key_w).font(CHIP_FONT).color(p.muted)) + .child(key_el) .child(val_el), ); } diff --git a/crates/session-view/src/tools/details.rs b/crates/session-view/src/tools/details.rs index bf65c2945..3cff55898 100644 --- a/crates/session-view/src/tools/details.rs +++ b/crates/session-view/src/tools/details.rs @@ -73,63 +73,22 @@ struct SheetPal { impl SheetPal { fn new(p: &Pal) -> Self { - let hex = |s: &str, fb: Color| rune::color::hex(s).unwrap_or(fb); - let drop = |y: f32, blur: f32, spread: f32, color: Color| Shadow { y, blur, spread, color, ..Shadow::default() }; - if p.theme > 0 || p.forced { - let mixer = if p.dark { Color::WHITE } else { Color::BLACK }; - let bg = p.code_bg; - let gutter = crate::palette::over(bg, mixer, 0.035); - let gutter_rule = opencode_ui::palette::flat(if p.forced { p.border } else { p.border_muted }, gutter); - let err_bg = opencode_ui::palette::over(bg, p.danger, if p.dark { 0.10 } else { 0.06 }); - let err_gutter = opencode_ui::palette::over(err_bg, p.danger, if p.dark { 0.08 } else { 0.06 }); - let err_rule = p.danger_border.alpha(if p.forced { 0.80 } else { 0.40 }); - return Self { - scrim: p.scrim.alpha((p.scrim.a * 0.65).clamp(0.18, 0.45)), - bg, - gutter, - gutter_rule, - err_bg, - err_gutter, - err_gutter_rule: opencode_ui::palette::flat(err_rule, err_gutter), - elevation: p.overlay, - }; - } - if p.dark { - let (bg, gutter, err_bg) = (hex("#141416", p.code_bg), hex("#19191c", p.layer1), hex("#221213", p.danger_bg)); - let err_gutter = opencode_ui::palette::over(err_bg, hex("#b4282d", p.danger), 0.10); - Self { - scrim: Color::BLACK.alpha(0.38), - bg, - gutter, - gutter_rule: opencode_ui::palette::flat(p.border_muted, gutter), - err_bg, - err_gutter, - err_gutter_rule: opencode_ui::palette::flat(p.danger_border.alpha(0.38), err_gutter), - elevation: [ - drop(18.0, 40.0, 0.0, Color::BLACK.alpha(0.52)), - drop(4.0, 10.0, 0.0, Color::BLACK.alpha(0.38)), - drop(0.0, 0.0, 0.5, Color::WHITE.alpha(0.14)), - drop(-0.5, 0.0, 0.0, Color::WHITE.alpha(0.08)), - ], - } - } else { - let (bg, gutter, err_bg) = (hex("#ffffff", p.bg_base), hex("#f5f5f7", p.layer1), hex("#fdf3f2", p.danger_bg)); - let err_gutter = opencode_ui::palette::over(err_bg, hex("#b4282d", p.danger), 0.10); - Self { - scrim: Color::BLACK.alpha(0.20), - bg, - gutter, - gutter_rule: opencode_ui::palette::flat(p.border_muted, gutter), - err_bg, - err_gutter, - err_gutter_rule: opencode_ui::palette::flat(p.danger_border.alpha(0.55), err_gutter), - elevation: [ - drop(18.0, 38.0, 0.0, Color::BLACK.alpha(0.11)), - drop(4.0, 10.0, 0.0, Color::BLACK.alpha(0.07)), - drop(0.0, 0.0, 0.5, Color::BLACK.alpha(0.11)), - Shadow::default(), - ], - } + let mixer = if p.dark { Color::WHITE } else { Color::BLACK }; + let bg = p.code_bg; + let gutter = crate::palette::over(bg, mixer, if p.dark { 0.035 } else { 0.03 }); + let gutter_rule = opencode_ui::palette::flat(if p.forced { p.border } else { p.border_muted }, gutter); + let err_bg = opencode_ui::palette::over(bg, p.danger, if p.dark { 0.10 } else { 0.06 }); + let err_gutter = opencode_ui::palette::over(err_bg, p.danger, if p.dark { 0.08 } else { 0.06 }); + let err_rule = p.danger_border.alpha(if p.forced { 0.80 } else { 0.45 }); + Self { + scrim: p.scrim.alpha((p.scrim.a * 0.65).clamp(0.18, 0.45)), + bg, + gutter, + gutter_rule, + err_bg, + err_gutter, + err_gutter_rule: opencode_ui::palette::flat(err_rule, err_gutter), + elevation: p.overlay, } } } @@ -400,7 +359,7 @@ fn zone(s: &S, p: &Pal, sp: &SheetPal, spec: ZoneSpec<'_>, cont }; let overflows_y = spec.natural_h - spec.max_h > 0.5; - let copy_right = if overflows_y { BAR_GUTTER + 2.0 } else { 7.0 }; + let copy_right = BAR_GUTTER + 2.0; let bg_right = if overflows_y { -(copy_right - BAR_GUTTER) } else { -copy_right }; let copy_key = format!("copy-execute-{}-{}", spec.id, spec.part); diff --git a/crates/session-view/src/turns/labels.rs b/crates/session-view/src/turns/labels.rs index c22b011ce..e6ecfdd6c 100644 --- a/crates/session-view/src/turns/labels.rs +++ b/crates/session-view/src/turns/labels.rs @@ -112,11 +112,14 @@ fn render_car(s: &S, p: &Pal, group_key: &str, car: &Car, trail r = r.child( row() .key(format!("chip-{ns}")) - .pr(if i + 1 < car.chips.len() || !car.clauses.is_empty() { 6.0 } else { 0.0 }) + .pr(if i + 1 < car.chips.len() { 4.0 } else { 0.0 }) .center_y() .child(crate::tools::codemode::namespace_chip(p, ns)), ); } + if !car.chips.is_empty() && !car.clauses.is_empty() { + r = r.child(text(", ").key("chip-comma").pl(1.0).font(UI).color(p.muted)); + } for (idx, c) in car.clauses.iter().enumerate() { r = r.child(render_clause(s, p, group_key, c, idx > 0, seen_before && idx > 0)); } diff --git a/crates/session-view/src/user_parts.rs b/crates/session-view/src/user_parts.rs index 9659e449f..05c9fb758 100644 --- a/crates/session-view/src/user_parts.rs +++ b/crates/session-view/src/user_parts.rs @@ -211,11 +211,11 @@ fn note_card(p: &Pal, n: &opencode_kit::model::NoteComment, active: bool, wide: .padding(8.0) .gap(6.0) .radius(6.0) - .fill(if p.dark { p.hover } else { p.bg_base }) + .fill(if wide && !p.dark { p.bg_base } else { p.hover }) .box_shadow(Pal::ring_in(if active { p.q.border_strong } else { p.border })) .child(title) .child(subtitle); - let c = if wide { c.w_full() } else { c.w(160.0) }; + let c = if wide { c.w_full() } else { c.w(160.0).h(52.0) }; let tip = if !detail.is_empty() && detail != heading_raw { format!("{heading_raw}\n{detail}") } else { @@ -257,11 +257,11 @@ fn file_card(p: &Pal, f: &FileComment, active: bool, wide: bool) -> El { .padding(8.0) .gap(6.0) .radius(6.0) - .fill(if p.dark { p.hover } else { p.bg_base }) + .fill(if wide && !p.dark { p.bg_base } else { p.hover }) .box_shadow(Pal::ring_in(if active { p.q.border_strong } else { p.border })) .child(title) .child(subtitle); - let c = if wide { c.w_full() } else { c.w(160.0) }; + let c = if wide { c.w_full() } else { c.w(160.0).h(52.0) }; c.help(f.comment.clone()).help_above() } @@ -315,11 +315,11 @@ pub fn quote_card(p: &Pal, q: &Quote, hint: bool, active: bool, wide: bool) -> E .padding(8.0) .gap(6.0) .radius(6.0) - .fill(if p.dark { p.hover } else { p.bg_base }) + .fill(if wide && !p.dark { p.bg_base } else { p.hover }) .box_shadow(Pal::ring_in(if active { p.q.border_strong } else { p.border })) .child(title) .child(subtitle); - c = if wide { c.w_full() } else { c.w(160.0) }; + c = if wide { c.w_full() } else { c.w(160.0).h(52.0) }; if comment.is_some() && !active { c.help(tip) } else { c } } diff --git a/crates/session-view/src/working.rs b/crates/session-view/src/working.rs index 7bcd8a15b..9294c0789 100644 --- a/crates/session-view/src/working.rs +++ b/crates/session-view/src/working.rs @@ -23,7 +23,6 @@ mod heading; pub use fade::{Fade, Fades}; pub use heading::{STAGGER as HEADING_STAGGER, heading_row, heading_row_with, reasoning_heading}; -use rune::color::{hex, srgb_decode, srgb_encode}; use rune::{Color, Easing, El, LoopSpec, TextStyle, el, text}; use crate::TimelineHost; @@ -33,7 +32,7 @@ use crate::knobs::{ secs, }; use crate::palette::Pal; -use crate::style::UI; +use crate::style::{UI, UI_MED}; /// Explicit turn-end handoff state machine synchronizing `Working -> Copy` with the streaming /// reply row's `GrowTrack` visual landing (`El::on_growth_settled`), capped at 280 ms. @@ -603,12 +602,15 @@ fn arm(s: &S, clock: f64, tx: &mut rune::Tx) { /// its loops would keep waking frames. On the active session's last lane (`morph`) new words /// take its one slot once the old are out ([`WordMorph`]), so it changes width only out of sight. pub fn row(s: &S, p: &Pal, session: &str, live: bool, words: &'static str, drum_key: Option<&str>) -> El { + let reduced_live = live && s.reduced_motion(); + let font = if reduced_live { UI_MED } else { UI }; let Some(key) = drum_key else { - return rune::row().w(width(words)).h(LINE).center_y().child(label_str(s, p, session, live, true, words)); + let w = rune::text::measure(words, &[], font, None).0; + return rune::row().w(w).h(LINE).center_y().child(label_str(s, p, session, live, true, words)); }; // Only the live face sweeps: it keeps one node across new words, so the light carries on // over them. A face rolling out is a fresh node whose loops would only wait unseen. - opencode_ui::drum::Drum::new(format!("status/{key}"), words, UI, p.muted) + opencode_ui::drum::Drum::new(format!("status/{key}"), words, font, p.muted) .reduced(s.reduced_motion()) .face(&|w, is_live| label_str(s, p, session, live, is_live, w)) .build() @@ -645,8 +647,9 @@ pub fn width(label: &str) -> f32 { /// too, unless motion is reduced. fn label_str(s: &S, p: &Pal, session: &str, on: bool, sweep: bool, words: &str) -> El { let (weak, strong) = colors(p); - let ink = if on { weak } else { p.muted }; - let base = rune::row().key("label").w_full().h(LINE).child(text(words.to_owned()).key("a").font(UI).color(ink)); + let reduced_active = on && sweep && s.reduced_motion(); + let (font, ink) = if reduced_active { (UI_MED, strong) } else if on { (UI, weak) } else { (UI, p.muted) }; + let base = rune::row().key("label").w_full().h(LINE).child(text(words.to_owned()).key("a").font(font).color(ink)); if !on || !sweep || words.is_empty() || s.reduced_motion() { return base; } @@ -675,10 +678,11 @@ fn label_str(s: &S, p: &Pal, session: &str, on: bool, sweep: bo /// would park the light mid-word). pub fn shimmer(s: &S, p: &Pal, words: &str, font: TextStyle) -> El { let (weak, strong) = colors(p); - let base = text(words.to_owned()).key("label").font(font).color(weak); if s.reduced_motion() { - return rune::row().child(base); + let active_font = if font == UI { UI_MED } else { font }; + return rune::row().child(text(words.to_owned()).key("label").font(active_font).color(strong)); } + let base = text(words.to_owned()).key("label").font(font).color(weak); let lit = weak.mix(strong, s.knobs().get(&WORKING_INTENSITY)); let w = rune::text::measure(words, &[], font, None).0; sweep(Run { since: 0.0, now: 0.0 }, words, font, base, lit, band(s, w)) @@ -769,19 +773,8 @@ fn sheen(run: Run, words: &str, font: TextStyle, lit: Color, b: Band) -> El { el().key("sheen").absolute(0.0, 0.0).w(w).h_full().clip_fade(b.soft, 0.0, b.soft, 0.0).looping(spec(b.x0 / w, b.x1 / w)).child(copy) } -/// Desktop's `--text-weak` and `--text-strong` (white at 42.2% and 93.6% on dark), each solved -/// to the opaque colour a browser blends over the page in sRGB. +/// Semantic resting and peak shimmer inks (`p.muted` sweeping to `p.text`), passing WCAG AA in +/// both light and dark mode across every theme. pub fn colors(p: &Pal) -> (Color, Color) { - if p.theme > 0 { - return (p.muted, p.text); - } - if !p.dark { - return (hex("#8f8f8f").unwrap_or(p.muted), hex("#171717").unwrap_or(p.text)); - } - let bg = p.bg_base; - let over = |a: f32| { - let c = |b: f32| srgb_decode(srgb_encode(b) + (1.0 - srgb_encode(b)) * a); - Color { r: c(bg.r), g: c(bg.g), b: c(bg.b), a: 1.0 } - }; - (over(0.422), over(0.936)) + (p.muted, p.text) } diff --git a/features/dictation/src/view.rs b/features/dictation/src/view.rs index 219d9441b..abe0e892f 100644 --- a/features/dictation/src/view.rs +++ b/features/dictation/src/view.rs @@ -80,7 +80,7 @@ pub fn toolbar(host: &H, p: &Pal) -> Option { b = b.hover(p.hover).press(p.pressed).on_press_tx(|s: &mut H, tx: &mut Tx| toggle(s, tx)); } // Its slot rides the composer's edge on the panel's spring; the button's own swap lands at once. - Some(el().key("mic-slot").size(28.0, 28.0).child(b)) + Some(el().key("mic-slot").size(28.0, 28.0).mr(4.0).child(b)) } struct StatusView {