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
11 changes: 6 additions & 5 deletions apps/desktop/src/shell/navigation/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ fn render_draft_row(p: &Pal, d: &DraftRow, pos: usize, size: usize) -> El {
)
}

/// The sidebar's marks (`session_busy`, `status_dot`), so switching layouts keeps them.
fn status_mark(p: &Pal, st: Status) -> Option<El> {
use session_view::style::{DOT, Dot, session_busy, status_dot};
match st {
// `ActivityRing`'s 14 (`navigation/row.tsx`).
Status::Working => Some(session_view::style::activity_ring_sized(p, 14.0)),
Status::Approval | Status::Question => Some(el().size(7.0, 7.0).radius(3.5).fill(p.v1_icon_warning)),
Status::Failed => Some(el().size(7.0, 7.0).radius(3.5).fill(p.danger)),
Status::Unread => Some(el().size(7.0, 7.0).radius(3.5).fill(p.bg_accent)),
Status::Working => Some(session_busy(p)),
Status::Approval | Status::Question => Some(status_dot(p, Dot::Attention, DOT)),
Status::Failed => Some(status_dot(p, Dot::Failed, DOT)),
Status::Unread => Some(status_dot(p, Dot::Unread, DOT)),
Status::Idle => None,
}
}
Expand Down
16 changes: 12 additions & 4 deletions apps/desktop/src/shell/tabs/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,18 @@ pub fn new_group(s: &mut App, r: PinRef) {
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum HiddenMark {
Attention,
Failed,
Unread,
}

/// What a collapsed pin group's hidden sessions need (`hiddenMark`, `pinned-area.tsx`).
/// What a collapsed pin group's hidden sessions need (`hiddenMark`, `pinned-area.tsx`): the most
/// urgent of them, Attention over Failed over Unread. The current session and muted ones' unread
/// or failed runs don't count.
pub fn hidden_mark(s: &App, group: &PinGroup) -> Option<HiddenMark> {
if !state(s).doc.collapsed.get(&group.id).copied().unwrap_or(false) {
return None;
}
let mut unread = false;
let (mut failed, mut unread) = (false, false);
for r in &group.sessions {
if is_current(s, r) {
continue;
Expand All @@ -554,11 +557,16 @@ pub fn hidden_mark(s: &App, group: &PinGroup) -> Option<HiddenMark> {
let status = status_of(s, r);
match status {
Some(crate::TabStatus::Attention) => return Some(HiddenMark::Attention),
Some(crate::TabStatus::Unread | crate::TabStatus::Failed) if !muted => unread = true,
Some(crate::TabStatus::Failed) if !muted => failed = true,
Some(crate::TabStatus::Unread) if !muted => unread = true,
_ => {}
}
}
unread.then_some(HiddenMark::Unread)
if failed {
Some(HiddenMark::Failed)
} else {
unread.then_some(HiddenMark::Unread)
}
}

pub fn status_of(s: &App, r: &PinRef) -> Option<crate::TabStatus> {
Expand Down
13 changes: 7 additions & 6 deletions apps/desktop/src/shell/view/inbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,15 @@ fn card(s: &App, p: &Pal, e: &Entry<'_>, in_shelf: bool, group: Group, card_epoc
let mut end = row().key("end").gap(6.0).center_y();
match e.status {
InboxStatus::Ready => {}
InboxStatus::Working => end = end.child(activity_ring(p)),
InboxStatus::Working => end = end.child(session_view::style::session_busy(p)),
status => {
let fill = match status {
InboxStatus::Approval | InboxStatus::Input => p.warning,
InboxStatus::Failed => p.danger,
_ => p.bg_accent,
use session_view::style::{DOT, Dot, status_dot};
let dot = match status {
InboxStatus::Approval | InboxStatus::Input => Dot::Attention,
InboxStatus::Failed => Dot::Failed,
_ => Dot::Unread,
};
end = end.child(el().key("dot").size(7.0, 7.0).radius(3.5).fill(fill));
end = end.child(el().key("dot").child(status_dot(p, dot, DOT)));
}
}
let key = e.key();
Expand Down
9 changes: 5 additions & 4 deletions apps/desktop/src/shell/view/sidebar/auto_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ fn header(s: &App, p: &Pal, g: &Group, first: bool) -> El {
None => icon(&ic::SERVER, 14.0).color(p.icon_muted),
};
let tag = g.server.as_ref().filter(|_| g.spans_servers).and_then(crate::servers::runtime::tag);
let dot = |color: Color| el().key("mark").size(6.0, 6.0).radius(3.0).fill(color).a11y_hidden();
use session_view::style::{DOT, Dot, session_busy, status_dot};
let dot = |d: Dot| el().key("mark").child(status_dot(p, d, DOT));
let mark = auto_groups::mark(s, g).map(|m| match m {
Mark::Busy => activity_ring(p).key("ring"),
Mark::Attention => dot(p.warning),
Mark::Unread => dot(p.bg_accent),
Mark::Busy => session_busy(p),
Mark::Attention => dot(Dot::Attention),
Mark::Unread => dot(Dot::Unread),
});
let key = g.key.clone();
row()
Expand Down
53 changes: 28 additions & 25 deletions apps/desktop/src/shell/view/sidebar/pinned_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::popup::{self, Item, Menu, MenuButton as _};
use crate::session_menu::{Spot, Target, preferences};
use crate::tabs::pins::{self, HiddenMark, PinColor, PinGroup, PinItem, PinRef};
use opencode_i18n::t;
use session_view::style::{DOT, DOT_BADGE, Dot, dot_color, session_busy, status_dot};

/// `sessions-stack` (`packages/ui/src/icons/catalog.ts:393`): Home's glyph in every layout
/// (`packages/app/src/shell/titlebar/titlebar.tsx:427,438`, `opencode#66594`).
Expand Down Expand Up @@ -57,17 +58,13 @@ fn group_square(c: PinColor, dark: bool) -> El {
}

fn hidden_dot(p: &Pal, mark: HiddenMark, vertical: bool) -> El {
let color = match mark {
HiddenMark::Attention => p.warning,
HiddenMark::Unread => p.accent,
let dot = match mark {
HiddenMark::Attention => Dot::Attention,
HiddenMark::Failed => Dot::Failed,
HiddenMark::Unread => Dot::Unread,
};
let end = if vertical { 0.0 } else { -3.0 };
el().key("group-mark")
.pin(None, Some(-3.0), Some(end), None)
.size(6.0, 6.0)
.radius(3.0)
.fill(color)
.a11y_hidden()
el().key("group-mark").pin(None, Some(-3.0), Some(end), None).child(status_dot(p, dot, DOT_BADGE))
}

/// Consolidated side tabs: pinned area above, divider, then unpinned open tabs, in their groups
Expand Down Expand Up @@ -210,10 +207,11 @@ fn vertical_session(s: &App, p: &Pal, r: &PinRef, nav_order: &[String], show_hin
let marked = s.kernel.slots.get(&crate::session_menu::MENUS).on.as_ref() == Some(&target);
let avatar = crate::icons::tab_badge(s, p, d.project, &d.title, d.shortcut, show_hints);
let mark = match d.status {
Some(TabItemStatus::Busy) => Some(session_view::style::tab_busy_glyph(crate::palette::kit(p), 14.0)),
Some(TabItemStatus::Busy) => Some(session_busy(p)),
_ if d.muted => Some(super::pins::muted_mark(p)),
Some(TabItemStatus::Attention) => Some(el().key("attention").size(7.0, 7.0).radius(3.5).fill(p.warning).a11y_hidden()),
Some(TabItemStatus::Unread | TabItemStatus::Failed) if !d.active => Some(el().key("unread").size(7.0, 7.0).radius(3.5).fill(p.accent).a11y_hidden()),
Some(TabItemStatus::Attention) => Some(status_dot(p, Dot::Attention, DOT)),
Some(TabItemStatus::Unread) if !d.active => Some(status_dot(p, Dot::Unread, DOT)),
Some(TabItemStatus::Failed) if !d.active => Some(status_dot(p, Dot::Failed, DOT)),
_ => None,
};
let ink = if d.active || d.status.is_some() { p.text } else { p.muted };
Expand Down Expand Up @@ -261,18 +259,19 @@ fn horizontal_session(s: &App, p: &Pal, r: &PinRef, nav_order: &[String], show_h
let target = Target::on(&r.server, &r.session_id, Spot::Row);
let marked = s.kernel.slots.get(&crate::session_menu::MENUS).on.as_ref() == Some(&target);
let avatar = if d.status == Some(TabItemStatus::Busy) && !show_hints {
session_view::style::tab_busy_glyph(crate::palette::kit(p), 14.0)
session_busy(p)
} else {
crate::icons::tab_badge(s, p, d.project, &d.title, d.shortcut, show_hints)
};
let dot = match d.status {
Some(TabItemStatus::Attention) => Some(p.warning),
Some(TabItemStatus::Unread | TabItemStatus::Failed) if !d.active && !d.muted => Some(p.accent),
Some(TabItemStatus::Attention) => Some(Dot::Attention),
Some(TabItemStatus::Unread) if !d.active && !d.muted => Some(Dot::Unread),
Some(TabItemStatus::Failed) if !d.active && !d.muted => Some(Dot::Failed),
_ => None,
};
let mut lead = el().size(16.0, 16.0).center().child(avatar);
if let Some(color) = dot {
lead = lead.child(el().key("dot").pin(None, Some(-2.0), Some(-2.0), None).size(6.0, 6.0).radius(3.0).fill(color).a11y_hidden());
if let Some(dot) = dot {
lead = lead.child(el().key("dot").pin(None, Some(-2.0), Some(-2.0), None).size(DOT_BADGE, DOT_BADGE).radius(DOT_BADGE / 2.0).fill(dot_color(p, dot)).a11y_hidden());
}
let pin_click = r.clone();
let pin_ctx = r.clone();
Expand Down Expand Up @@ -305,24 +304,26 @@ fn horizontal_session(s: &App, p: &Pal, r: &PinRef, nav_order: &[String], show_h
/// default ease).
const CHEVRON: Curve = Curve::tween(0.15, Easing::cubic(0.4, 0.0, 0.2, 1.0));

/// A header's chevron that shows with the pointer over the header's row or with the keyboard's
/// focus on its toggle (the ancestor keyed `toggle`), fading over 150 ms, and always where the
/// pointer cannot hover (`pinned-area.tsx:376`, `recent-sessions.tsx:1222-1225`: `opacity-0
/// transition-[transform,opacity] group-hover/row:opacity-100
/// group-focus-visible/toggle:opacity-100 [@media(hover:none)]:opacity-100`, opencode#66265).
/// It turns over the same 150 ms.
/// A header's chevron. Open, it shows with the pointer over the header's row or with the
/// keyboard's focus on its toggle (the ancestor keyed `toggle`), fading over 150 ms
/// (`pinned-area.tsx:376`, opencode#66265). Folded, it stays at rest, turned to point at the
/// hidden rows, so a folded group reads as one that opens (as a folded tab group's does,
/// `tab_groups.rs`). It always shows where the pointer cannot hover, and turns over 150 ms.
pub(super) fn group_chevron(p: &Pal, open: bool, toggle: &str) -> El {
let chevron = icon(&ic::FILL_TRIANGLE_DOWN, 14.0)
.color(p.icon_muted)
.rotate(if open { 0.0 } else { -std::f32::consts::FRAC_PI_2 })
.mirror_in_rtl()
.rotate_motion(CHEVRON);
if session_view::style::hover_none() {
if session_view::style::hover_none() || !open {
return chevron;
}
chevron.group_opacity(0.0, 1.0).group_focus_within(toggle.to_owned()).group_motion(CHEVRON, CHEVRON)
}

/// A folded group's session count, faint after its name (as a folded tab group's, `tab_groups.rs`).
const COUNT: TextStyle = TextStyle::new(11.0, 440.0).lh(16.0).features("\"tnum\"");

fn vertical_group(s: &App, p: &Pal, g: &PinGroup, nav_order: &[String], show_hints: bool) -> El {
let open = !pins::state(s).doc.collapsed.get(&g.id).copied().unwrap_or(false);
let mark = pins::hidden_mark(s, g);
Expand All @@ -335,6 +336,7 @@ fn vertical_group(s: &App, p: &Pal, g: &PinGroup, nav_order: &[String], show_hin
.children(mark.map(|m| hidden_dot(p, m, true)));

let label_el = text(g.name.clone()).font(UI_MED).color(p.text).shrink().min_w(0.0).truncate().dir(rune::Direction::Auto);
let count = (!open && !g.sessions.is_empty()).then(|| text(g.sessions.len().to_string()).key("count").font(COUNT).color(p.faint));

let toggle_id = g.id.clone();
let ctx_id = g.id.clone();
Expand All @@ -348,7 +350,7 @@ fn vertical_group(s: &App, p: &Pal, g: &PinGroup, nav_order: &[String], show_hin
let trigger = row()
.key(toggle_key.clone())
.role("button")
.label(g.name.clone())
.label(if open || g.sessions.is_empty() { g.name.clone() } else { format!("{} ({})", g.name, g.sessions.len()) })
.expanded(open)
.grow(1.0)
.shrink()
Expand All @@ -375,6 +377,7 @@ fn vertical_group(s: &App, p: &Pal, g: &PinGroup, nav_order: &[String], show_hin
.child(el().key("hover").pin(Some(0.0), Some(0.0), Some(0.0), Some(0.0)).radius(6.0).fill(p.hover).group_opacity(0.0, 1.0).a11y_hidden())
.child(marker)
.child(label_el)
.children(count)
.child(group_chevron(p, open, &toggle_key));

// The menu button shows with the pointer over the row or with focus on itself
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/shell/view/sidebar/recent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ fn group_header(s: &App, p: &Pal, group_key: &str, g: &GroupHeader) -> El {
btn = btn.child(text(n.to_string()).font(UI_SMALL).color(p.faint));
}
if let Some(m) = mark {
let dot_color = if m == RecentStatus::Attention { p.warning } else { p.accent };
btn = btn.child(el().key("group-dot").size(6.0, 6.0).radius(3.0).fill(dot_color).a11y_hidden());
let dot = if m == RecentStatus::Attention { session_view::style::Dot::Attention } else { session_view::style::Dot::Unread };
btn = btn.child(el().key("group-dot").child(session_view::style::status_dot(p, dot, session_view::style::DOT)));
}
// Under Consolidated the chevron shows with the pointer over the header or the keyboard's
// focus on the header's button, on a 150 ms fade (`recent-sessions.tsx:1222-1225`,
Expand Down
19 changes: 8 additions & 11 deletions apps/desktop/src/shell/view/sidebar/rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use super::*;
use crate::session_menu::{Spot, Target};
use opencode_i18n::t;
use session_view::style::{DOT, Dot, session_busy, status_dot};

/// A collapsible section's title (`text-[12px] font-medium`) and a group's (`text-[13px]`, 440).
const SECTION: TextStyle = TextStyle::new(12.0, 530.0).lh(16.0);
const GROUP: TextStyle = TextStyle::new(13.0, 440.0).lh(16.0).tracking(-0.04);
/// The Sessions, Pinned and Recent headers (`text-[13px] leading-4 font-medium`).
pub(super) const HEADER: TextStyle = TextStyle::new(13.0, 530.0).lh(16.0).tracking(-0.04);
/// A row's faint trailing label and a collapsed group's count (`text-[11px]`).
const LABEL: TextStyle = TextStyle::new(11.0, 400.0).lh(16.0);
const LABEL: TextStyle = TextStyle::new(11.0, 440.0).lh(16.0);
/// A ghost-muted Button's label.
const BUTTON: TextStyle = TextStyle::new(13.0, 440.0).lh(20.0).tracking(-0.04);

Expand All @@ -31,14 +32,15 @@ pub(super) struct SessionRow<'a> {
}

/// `ProjectSessionRow`: 28 tall, 32 in (14 more per step), its title in the text colour while
/// current and faint otherwise, a ring while it works or a dot while unread; its menu on a
/// right-click. A press opens it.
/// current and faint otherwise, the busy glyph while it works or a status dot while unread or
/// failed; its menu on a right-click. A press opens it.
pub(super) fn session_row(s: &App, p: &Pal, key: String, r: SessionRow) -> El {
let id = r.session.id.clone();
let mark = match s.tab_status(&id) {
Some(crate::TabStatus::Busy) => Some(activity_ring(p).key("ring")),
Some(crate::TabStatus::Busy) => Some(session_busy(p)),
_ if crate::session_menu::preferences::muted(r.server, &id) => Some(super::pins::muted_mark(p)),
Some(crate::TabStatus::Unread | crate::TabStatus::Failed) if !r.active => Some(el().key("unread").size(6.0, 6.0).radius(3.0).fill(p.text)),
Some(crate::TabStatus::Unread) if !r.active => Some(status_dot(p, Dot::Unread, DOT)),
Some(crate::TabStatus::Failed) if !r.active => Some(status_dot(p, Dot::Failed, DOT)),
_ => None,
};
let start = 32.0 + 14.0 * r.depth as f32;
Expand Down Expand Up @@ -304,12 +306,7 @@ pub(super) fn recent_tab_row(
r = r.child(lead).child(title_el);
}
if !editing && let Some(st) = row_data.mark {
let glyph = match st {
TabItemStatus::Busy => session_view::style::tab_busy_glyph(crate::palette::kit(p), 14.0),
TabItemStatus::Attention => el().size(7.0, 7.0).radius(3.5).fill(p.warning),
TabItemStatus::Failed => el().size(7.0, 7.0).radius(3.5).fill(p.danger),
TabItemStatus::Unread => el().size(7.0, 7.0).radius(3.5).fill(p.bg_accent),
};
let glyph = super::sections::status_mark(p, st);
r = r.child(row().key("status").pin(None, Some((h - 20.0) * 0.5), Some(4.0), None).size(20.0, 20.0).center().a11y_hidden().child(glyph));
}
if !editing {
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/shell/view/sidebar/sections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ mod menu;
mod row;
mod story;

/// A status's mark in a side row's slot, shared by every sidebar row.
pub(super) use row::status_mark;

use super::*;
use crate::tabs::sections::{self as sec, Entry, LIVE};
use opencode_i18n::t;
Expand Down
14 changes: 7 additions & 7 deletions apps/desktop/src/shell/view/sidebar/sections/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub(super) fn in_slot(what: El) -> El {
row().key("mark").absolute(0.0, 0.0).size(SLOT, SLOT).center().a11y_hidden().child(what)
}

/// What a status draws in the slot: the busy glyph, or a 7 pt dot.
pub(super) fn status_mark(p: &Pal, status: TabItemStatus) -> El {
let dot = |key: &'static str, c: Color| el().key(key).size(7.0, 7.0).radius(3.5).fill(c).a11y_hidden();
/// What a status draws in a row's slot: the busy glyph, or a status dot.
pub(crate) fn status_mark(p: &Pal, status: TabItemStatus) -> El {
use session_view::style::{DOT, Dot, session_busy, status_dot};
match status {
TabItemStatus::Busy => session_view::style::tab_busy_glyph(crate::palette::kit(p), 14.0),
TabItemStatus::Attention => dot("attention", p.warning),
TabItemStatus::Unread => dot("unread", p.bg_accent),
TabItemStatus::Failed => dot("failed", p.danger),
TabItemStatus::Busy => session_busy(p),
TabItemStatus::Attention => status_dot(p, Dot::Attention, DOT),
TabItemStatus::Unread => status_dot(p, Dot::Unread, DOT),
TabItemStatus::Failed => status_dot(p, Dot::Failed, DOT),
}
}

Expand Down
6 changes: 2 additions & 4 deletions apps/desktop/src/shell/view/sidebar/tab_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,8 @@ fn tab_row(s: &App, p: &Pal, g: &Group, t: &crate::tabs::Tab, tab_index: usize,
None => text(face.title.clone()).font(UI).color(if active || mark.is_some() { p.text } else { p.muted }).grow(1.0).shrink().min_w(0.0).truncate_fade().dir(rune::Direction::Auto),
};
let status_el = match mark {
Some(TabItemStatus::Busy) => Some(session_view::style::tab_busy_glyph(crate::palette::kit(p), 14.0)),
Some(TabItemStatus::Attention) => Some(el().key("attention").size(7.0, 7.0).radius(3.5).fill(p.warning).a11y_hidden()),
Some(TabItemStatus::Unread) if !active => Some(el().key("unread").size(7.0, 7.0).radius(3.5).fill(p.accent).a11y_hidden()),
Some(TabItemStatus::Failed) if !active => Some(el().key("failed").size(7.0, 7.0).radius(3.5).fill(p.danger).a11y_hidden()),
Some(m @ (TabItemStatus::Busy | TabItemStatus::Attention)) => Some(super::sections::status_mark(p, m)),
Some(m @ (TabItemStatus::Unread | TabItemStatus::Failed)) if !active => Some(super::sections::status_mark(p, m)),
_ => None,
};
let close_uid = uid.clone();
Expand Down
Loading
Loading