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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions crates/session-view/src/activity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, 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);
16 changes: 11 additions & 5 deletions crates/session-view/src/composer/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -262,7 +264,7 @@ pub fn chips<S: ComposerHost>(s: &S, p: &Pal) -> Option<El> {
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);
Expand Down Expand Up @@ -364,13 +366,14 @@ pub fn chips<S: ComposerHost>(s: &S, p: &Pal) -> Option<El> {
}
// 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<Live<f32>>, 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()
})
Expand Down Expand Up @@ -418,7 +421,7 @@ pub fn remove_button<S: 'static>(
.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();
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down
50 changes: 27 additions & 23 deletions crates/session-view/src/composer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ 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 {
row()
.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)
Expand Down Expand Up @@ -606,23 +606,26 @@ pub fn composer_in<S: ComposerHost>(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")
Expand Down Expand Up @@ -688,11 +691,11 @@ pub fn composer_in<S: ComposerHost>(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)
Expand Down Expand Up @@ -732,6 +735,7 @@ pub fn composer_in<S: ComposerHost>(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))
}
}
}
6 changes: 3 additions & 3 deletions crates/session-view/src/dock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions crates/session-view/src/dock/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -276,7 +276,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
.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()
Expand All @@ -303,33 +303,33 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
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::<S>(p, col().w_full().max_h(INPUT_MAX_H).mt(8.0), list)
});
let patterns = (!resources.is_empty()).then(|| {
// 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::<S>(p, col().w_full().max_h(PATTERNS_MAX_H).scroll_edge_fade(16.0).mt(8.0).mb(16.0), list)
.build::<S>(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()
Expand Down Expand Up @@ -360,7 +360,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
.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)
Expand Down
16 changes: 8 additions & 8 deletions crates/session-view/src/dock/question/classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -142,11 +142,11 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
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)
Expand All @@ -160,7 +160,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {

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()
Expand All @@ -174,7 +174,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
// 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()
Expand Down
6 changes: 3 additions & 3 deletions crates/session-view/src/dock/question/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
.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)
Expand Down Expand Up @@ -344,7 +344,7 @@ pub fn face<S: DockHost>(s: &S, p: &Pal) -> Option<Vec<El>> {
.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())
Expand Down Expand Up @@ -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<S: DockHost>(p: &Pal, last: bool, label: &'static str, submit_keys: Vec<String>, 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;
}
Expand Down
Loading
Loading