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
6 changes: 4 additions & 2 deletions apps/desktop/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ pub fn build() -> Kernel<App> {
crate::diagram::view(s, p, cx)
})
.above("overlay.attachments.viewer")
.with_key(crate::diagram::key),
.with_key(crate::diagram::key)
.after_key("overlay.tool_details"),
);
b.register_overlay(
OverlayRegistration::<App>::new("overlay.tool_details")
.with_render(crate::overlays::layer::MEDIA_LIGHTBOX, |s, cx| {
let p = crate::palette::pal(s.dark(cx));
session_view::tools::details_overlay(s, p, cx)
})
.above("overlay.diagram"),
.above("overlay.diagram")
.with_key(session_view::tools::details_key),
);
b.register_overlay(
OverlayRegistration::<App>::new("overlay.tab_preview")
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/session/composer/add_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl App {
let file = ContextFile { path, start, end };
// One card per file and range (`contextItemKey`).
if !self.composer_ext.attach.context.contains(&file) {
tx.follow_edge();
self.composer_ext.attach.context.push(file);
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/session/composer/win_clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub(crate) fn poll(s: &mut App, tx: &mut Tx) -> bool {
if let Some(png) = png {
if attachments::attach_pasted_image(s, "image/png", "png", png) {
tx.instant();
tx.follow_edge();
changed = true;
}
} else if let Some(fb) = fallback {
Expand Down
7 changes: 5 additions & 2 deletions apps/desktop/src/session/inbox/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ impl App {
self.admit_with(&id, prompt, if queue { Delivery::Queue } else { Delivery::Steer }, queue_first);
if queue {
// Sent in place, the reader stays where they are.
if session_view::TimelineHost::smooth_timeline(self) && !stay_in_place {
tx.follow_edge();
if session_view::TimelineHost::smooth_timeline(self) {
tx.animated();
if !stay_in_place {
tx.follow_edge();
}
}
tx.motion(opencode_ui::roll::SLIDE);
tx.launch(from.as_str(), format!("queued-{local}"));
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/src/session/inbox/send_failed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ impl SendFailedHost for App {
crate::quote::send_result(self, id, result);
}

fn is_session_busy(&self, session: &str) -> bool {
self.busy(session)
}

fn is_queue_busy(&self, session: &str) -> bool {
self.kernel.slots.get(&crate::queue::QUEUE_OPS).get(session).is_some_and(crate::queue::machine::Queue::busy)
}
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/shell/commands/type_to_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn paste(s: &mut App, content: &ClipboardContent, draft: Option<String>, require
}
if attachments::paste_immediate(s, content) {
tx.instant();
tx.follow_edge();
return;
}
let fallback = FallbackText::from_content(content);
Expand Down Expand Up @@ -187,6 +188,7 @@ fn read_named_image(
if let Some(bytes) = data.filter(|b| attachments::valid_image_bytes(mime, b)) {
if attachments::attach_pasted_image(s, mime, ext, bytes) {
tx.instant();
tx.follow_edge();
}
return;
}
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/shell/view/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ impl ComposerHost for App {
self.kernel.slots.get(&crate::suggestions::SUGGEST).state.held_height()
}
fn composer_on_change(&mut self, tx: &mut Tx) {
tx.follow_edge();
crate::dictation::dismiss_error(self);
crate::plugin_host::services::composer_state::on_composer_edit(self);
crate::tab_hints::cancel(self, tx);
Expand Down
29 changes: 24 additions & 5 deletions crates/opencode-ui/src/scroller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ pub struct Scroller {
stable: bool,
always: bool,
both_axes: bool,
h_track_offset: (f32, f32),
}

/// A vertical scroll container keyed `key`, with `scrollbar.css`'s bar unless [`Scroller::bar`]
/// says otherwise.
pub fn scroller(key: impl Into<String>) -> Scroller {
Scroller { key: Rc::from(key.into()), spec: ScrollSpec { stick_bottom: false }, bar: Bar::Native, stable: false, always: false, both_axes: false }
Scroller { key: Rc::from(key.into()), spec: ScrollSpec { stick_bottom: false }, bar: Bar::Native, stable: false, always: false, both_axes: false, h_track_offset: (0.0, 0.0) }
}

impl Scroller {
Expand Down Expand Up @@ -169,6 +170,13 @@ impl Scroller {
self
}

/// Offsets the horizontal scroll bar's track inward from `(start, end)` (for example past a
/// sticky left line-number gutter so the thumb stays inside the scrolling code column).
pub fn horizontal_track_offset(mut self, start: f32, end: f32) -> Self {
self.h_track_offset = (start, end);
self
}

/// Desktop's counterpart has `bar`, not `scrollbar.css`'s.
pub fn bar(mut self, bar: Bar) -> Self {
self.bar = bar;
Expand All @@ -188,18 +196,24 @@ impl Scroller {
pub fn build<S: 'static>(self, p: &Pal, viewport: El, content: El) -> El {
let viewport = viewport.key(self.key.to_string()).scroll(self.spec);
let viewport = if self.both_axes { viewport.scroll_xy() } else { viewport };
let (h_start, h_end) = self.h_track_offset;
let attach = |el: El, style: ScrollBarStyle| {
let style = if self.always { style.always_visible() } else { style };
if self.both_axes {
el.scroll_bars_xy_styled(style, style.horizontal())
let h_style = if h_start != 0.0 || h_end != 0.0 {
style.horizontal().track_offset(h_start, h_end)
} else {
style.horizontal()
};
el.scroll_bars_xy_styled(style, h_style)
} else {
el.scroll_bar_styled(style)
}
};
match self.bar {
Bar::Native => {
let bar = if self.always { native_bar(p).always_visible() } else { native_bar(p) };
native::<S>(bar, self.key, self.stable, self.both_axes, viewport, content)
native::<S>(bar, self.h_track_offset, self.key, self.stable, self.both_axes, viewport, content)
}
Bar::ScrollView => attach(viewport.child(content), ScrollBarStyle::scroll_view(kit(p))),
Bar::MenuScroll => attach(viewport.child(content), ScrollBarStyle::menu_scroll(p.border_muted, p.q.border_strong)),
Expand All @@ -218,10 +232,15 @@ fn tree_bar(fg: Color, bg: Color) -> ScrollBarStyle {

/// `scrollbar.css`'s bar: the content's 8 point gutter while it overflows, measured from both
/// heights, and the bar in it. Only a change in whether it overflows runs the view again.
fn native<S: 'static>(bar: ScrollBarStyle, key: Rc<str>, stable: bool, both_axes: bool, viewport: El, content: El) -> El {
fn native<S: 'static>(bar: ScrollBarStyle, (h_start, h_end): (f32, f32), key: Rc<str>, stable: bool, both_axes: bool, viewport: El, content: El) -> El {
let attach = |el: El| {
if both_axes {
el.scroll_bars_xy_styled(bar, bar.horizontal())
let h_bar = if h_start != 0.0 || h_end != 0.0 {
bar.horizontal().track_offset(h_start, h_end)
} else {
bar.horizontal()
};
el.scroll_bars_xy_styled(bar, h_bar)
} else {
el.scroll_bar_styled(bar)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/session-view/src/composer/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub fn paste<S: ComposerHost>(s: &mut S, content: &ClipboardContent, tx: &mut Tx
return false;
}
if paste_immediate(s, content) {
tx.follow_edge();
return true;
}
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -205,6 +206,7 @@ pub fn paste<S: ComposerHost>(s: &mut S, content: &ClipboardContent, tx: &mut Tx
if let Some(bytes) = data.filter(|b| valid_image_bytes(mime, b)) {
if attach_pasted_image(s, mime, ext, bytes) {
tx.instant();
tx.follow_edge();
}
} else if let Some(fb) = fallback {
fb.apply(s, tx);
Expand Down Expand Up @@ -422,6 +424,7 @@ pub fn remove_button<S: 'static>(
.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();
tx.follow_edge();
on(s);
})
.child(icon(&ic::XMARK_SMALL, 12.0).color(p.icon_contrast))
Expand Down
26 changes: 17 additions & 9 deletions crates/session-view/src/composer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ pub const SHELL_PROMPT: TextStyle = TextStyle::new(13.0, 440.0).mono().lh(20.0).
/// the timeline cuts to its end, where the message already stands.
pub fn land<S: TimelineHost>(s: &mut S, session: &str, local: &str, from: &str, tx: &mut Tx) {
if s.ends().at_end(session) {
tx.motion(opencode_ui::roll::SLIDE);
tx.follow_edge();
if s.smooth_timeline() {
if s.smooth_timeline() && !s.reduced_motion() {
// Clear any earlier `tx.instant()` (e.g. closing an open suggestion/history popover)
// and opt poll-driven sends (dictation, held-submit) into `SLIDE` motion.
tx.animated();
tx.unclipped_flights();
}
tx.motion(opencode_ui::roll::SLIDE);
tx.follow_edge();
let gate = s.working_state().fades.launch(local);
tx.launch_gated(from, format!("u-{local}/bubble"), gate);
} else {
Expand All @@ -54,11 +57,12 @@ pub fn land<S: TimelineHost>(s: &mut S, session: &str, local: &str, from: &str,
/// Like [`land`], but keeps a scrolled-up timeline where it is instead of jumping to the end.
pub fn land_in_place<S: TimelineHost>(s: &mut S, session: &str, local: &str, from: &str, tx: &mut Tx) {
if s.ends().at_end(session) {
tx.motion(opencode_ui::roll::SLIDE);
tx.follow_edge();
if s.smooth_timeline() {
if s.smooth_timeline() && !s.reduced_motion() {
tx.animated();
tx.unclipped_flights();
}
tx.motion(opencode_ui::roll::SLIDE);
tx.follow_edge();
let gate = s.working_state().fades.launch(local);
tx.launch_gated(from, format!("u-{local}/bubble"), gate);
}
Expand Down Expand Up @@ -357,7 +361,9 @@ pub trait ComposerHost: TimelineHost {
fn composer_held_height(&self) -> Option<f32> {
None
}
fn composer_on_change(&mut self, _tx: &mut Tx) {}
fn composer_on_change(&mut self, tx: &mut Tx) {
tx.follow_edge();
}
fn composer_set_hovered(&mut self, _hovered: bool) {}
fn composer_on_key(&mut self, _ev: &KeyEvent, _tx: &mut Tx) -> bool {
false
Expand Down Expand Up @@ -586,9 +592,11 @@ pub fn composer_in<S: ComposerHost>(s: &S, p: &Pal, scope: &str) -> El {
.min_h(if docked && s.composer_shell_mode() { 44.0 } else { 88.0 })
// `rounded-xl` (`editor.tsx:254`): the app's `--radius-xl` is 0.625rem (`theme.css:50`).
.corners([RADIUS; 4])
.on_hover_change(|s: &mut S, inside, tx: &mut Tx| {
// Never call window-wide `tx.instant()` here: when a multi-line composer shrinks on
// submit out from under a still pointer, `on_hover_change(false)` would wipe scroll
// `Slack` and snap the in-flight `SLIDE` launch; `effort-slot` already sets `INSTANT`.
.on_hover_change(|s: &mut S, inside, _: &mut Tx| {
s.composer_set_hovered(inside);
tx.instant();
});
// A face with surfaces of its own keeps its shadows: no card under it and no clip over it.
// Otherwise `--v2-elevation-raised` (`editor.tsx:248-251`): two drops, a 0.5 pt ring and
Expand Down
14 changes: 7 additions & 7 deletions crates/session-view/src/disclosure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ pub fn anchor<S: TimelineHost>(s: &mut S, tx: &mut Tx, opening: bool, row: &str,
/// as it always does.
pub fn anchor_grow<S: TimelineHost>(s: &mut S, tx: &mut Tx, opening: bool, row: &str, header: &str) {
let id = s.active_session_id().map(str::to_owned);
let at_end = id.as_deref().is_some_and(|id| s.ends().at_end(id));
if at_end && !opening {
if id.as_deref().is_some_and(|id| s.ends().at_end(id)) {
if opening {
// Hold `row`'s top across the fold; if growing pushes the transcript's end below the
// viewport, Rune's `keep_on_screen` detaches `stick_bottom` and emits `AtBottom(false)`.
// If it still fits at the end, `Ends` stays `Following` in sync with `at_bottom`.
tx.keep_on_screen(row.to_owned());
}
return;
}
if at_end {
// Leave the end before the fold grows: Rune rides a fold pinned to its end from its
// bottom, which is what scrolls the prompt's start away.
let _ = s.ends_mut().step(id.as_deref(), crate::follow::Event::AtEnd(false));
}
if let Some(crate::follow::Effect::Keep(key)) = s.ends_mut().step(id.as_deref(), crate::follow::Event::Disclosure { opening, row, header }) {
tx.keep_on_screen(key);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/session-view/src/genui/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ impl<S: TimelineHost> PartsResolver for Resolver<'_, S> {
return col().w_full().child(markdown_styled::<S, _>(p, src, self.fade, false, markdown_style(p, color, self.width).body_font(font), marks, Vec::new(), None, &[], None, None));
}
let hl = marks.into_iter().filter_map(|(i, m, on)| Some(text_mark(p, m.first()?.clone(), i, on)));
readable(p, text(src.to_owned()).font(font).color(color).wrap().reveal(self.fade).text_highlights(hl))
let t = text(src.to_owned()).font(font).color(color).wrap().text_highlights(hl);
readable(p, if self.fade > 0.0 { t.reveal(self.fade) } else { t })
}
}

Expand Down
11 changes: 7 additions & 4 deletions crates/session-view/src/genui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,27 @@ pub fn reply<S: TimelineHost>(s: &S, p: &Pal, row_key: &str, src: &str, fade: f3
Seg::Md(r) => {
let marks = hits_in(hits, &r).into_iter().map(|(i, m, on)| (m, markdown_mark(p, i, on))).collect();
let seg_scope = format!("{row_key}-md-{}", r.start);
let el = crate::style::markdown_styled_wrap::<S, _>(p, &src[r.clone()], fade, streaming && i + 1 == count, markdown_style(p, p.text, width), marks, crate::copied::current(s), Some(crate::images::md_media(s)), chips, None, links.clone(), crate::style::CodeWrap::of(s, &seg_scope));
let seg_live = streaming && i + 1 == count;
let seg_fade = if !streaming || seg_live { fade } else { 0.0 };
let el = crate::style::markdown_styled_wrap::<S, _>(p, &src[r.clone()], seg_fade, seg_live, markdown_style(p, p.text, width), marks, crate::copied::current(s), Some(crate::images::md_media(s)), chips, None, links.clone(), crate::style::CodeWrap::of(s, &seg_scope));
// The first run is the root and keeps its blocks' keys from before any fence.
let el = if i == 0 { el } else { el.key(format!("md-{}", r.start)) };
(el, md_edges(&src[r]))
}
Seg::Ui { at, src_at, line, nodes, code, open } => {
let marks: Vec<inline::Mark> = hits_in(hits, &at).into_iter().map(|(i, m, on)| (i, shift(m, at.start), on)).collect();
let lines: Vec<(usize, u64)> = nodes_lines(&nodes);
let ver = (lines, src_at, width.to_bits(), fade.to_bits(), p.dark, (p.theme, p.generation), &marks);
let ui_fade = if !streaming || (open && i + 1 == count) { fade } else { 0.0 };
let ver = (lines, src_at, width.to_bits(), ui_fade.to_bits(), p.dark, (p.theme, p.generation), &marks);
let version = {
use std::hash::{Hash, Hasher};
let mut h = std::hash::DefaultHasher::new();
ver.hash(&mut h);
h.finish()
};
let outline = rune::memo(format!("outline-{line}"), ver, || inline::outline::<S>(p, src, src_at, &nodes, width, fade, marks.clone()));
let outline = rune::memo(format!("outline-{line}"), ver, || inline::outline::<S>(p, src, src_at, &nodes, width, ui_fade, marks.clone()));
// The plugin that renders `ui` blocks places the outline (`ui.genUi`), or keeps the code.
let outline = s.code_block(p, "ui", &format!("outline-{line}"), &src[code], streaming && open, version, outline).unwrap_or_else(|| markdown_styled::<S, _>(p, &src[at.clone()], fade, false, markdown_style(p, p.text, width), Vec::<(Vec<Range<usize>>, rune_kit::Highlight)>::new(), crate::copied::current(s), None, chips, None, links.clone()));
let outline = s.code_block(p, "ui", &format!("outline-{line}"), &src[code], streaming && open, version, outline).unwrap_or_else(|| markdown_styled::<S, _>(p, &src[at.clone()], ui_fade, false, markdown_style(p, p.text, width), Vec::<(Vec<Range<usize>>, rune_kit::Highlight)>::new(), crate::copied::current(s), None, chips, None, links.clone()));
// A pane that gains a sibling while it streams springs to its new width.
(col().key(format!("ui-{line}")).w_full().animate_layout().child(outline), UI_EDGES)
}
Expand Down
Loading
Loading