diff --git a/crates/session-view/src/line_reveal.rs b/crates/session-view/src/line_reveal.rs index 8f9bef92e..db3d5f737 100644 --- a/crates/session-view/src/line_reveal.rs +++ b/crates/session-view/src/line_reveal.rs @@ -193,6 +193,53 @@ pub fn poll(s: &mut S, now: f64, tx: &mut Tx) -> bool { let stopped = s.is_session_stopped(&sid); let instant = reduced || (!live && stopped); let step_dt = drip_step(s.display_hz()); + // Fast read-only check: while the agent is thinking, running tools, or pausing between batches, + // every live text part is already caught up; bail before touching `line_hold_mut()` so + // `Tracked::DerefMut` doesn't invalidate the timeline region on every poll. + let mut needs_work = false; + let mut live_count = 0usize; + { + let hold = s.line_hold(); + s.with_transcript(&sid, |t| { + for m in t.messages.iter().rev().take_while(|m| !matches!(**m, opencode_kit::model::Message::User { .. })) { + let opencode_kit::model::Message::Assistant(a) = m else { continue }; + for (i, part) in a.parts.iter().enumerate() { + let opencode_kit::model::Part::Text { text } = part else { continue }; + if text.trim().is_empty() { + continue; + } + let existing = hold.drip.iter().find(|(k, _)| k.part == i && k.message == a.id && k.session == sid); + match existing { + None if live => { + needs_work = true; + return; + } + None => continue, + Some((_, d)) => { + live_count += 1; + let len = text.len(); + if !live + || instant + || len != d.last_len + || d.shown < len + || d.cursor < len as f64 + || matches!(d.phase, DripPhase::Done) + { + needs_work = true; + return; + } + } + } + } + } + }); + if !needs_work && hold.drip.len() != live_count { + needs_work = true; + } + } + if !needs_work { + return false; + } let mut hold = std::mem::take(s.line_hold_mut()); let mut changed = false; let mut next = f64::INFINITY; diff --git a/crates/session-view/src/timeline/rhythm.rs b/crates/session-view/src/timeline/rhythm.rs index e1d4eab7c..c45bc3cad 100644 --- a/crates/session-view/src/timeline/rhythm.rs +++ b/crates/session-view/src/timeline/rhythm.rs @@ -296,7 +296,10 @@ pub(super) fn space_at(t: &Transcript, out: &mut [RowSpec], at: std::ops::Range< let prompt = matches!(out[i].content, RowContent::User { .. } | RowContent::Pending { .. } | RowContent::UserImages { .. }); let after_active_tail = matches!(out[up].content, RowContent::TurnTail { .. }); match top_of(&mut out[i].content) { - Some(room) if prompt && after_active_tail => *room = 0.0, + // Keep TurnTail's own height untouched when a Pending steer lands under it, while + // giving the steer full `L` (32 pt) clearance below the status text (matching `Used N + // tools` -> steer so replacing Thinking with a tool row causes 0 pt vertical shift). + Some(room) if prompt && after_active_tail => *room = (L - crate::working::LANE_TEXT_BOTTOM).max(0.0).round(), Some(room) if prompt => out[up].under = std::mem::take(room).round(), Some(room) => *room = room.round(), None => {} @@ -316,9 +319,11 @@ pub(super) fn top_of(row: &mut RowContent) -> Option<&mut f32> { } } -/// Extra bottom tail room past the 36 pt Working lane: constant `0.0` everywhere so the -/// active tail lane never shrinks backwards by `L - S` when the first assistant line arrives -/// (the prompt bubble's own `meta-room` already gives `Working` full `L` clearance below it). -pub(super) fn tail_extra(_t: &Transcript, _rows: &[RowSpec]) -> f32 { - 0.0 +/// Extra top room inside the active `TurnTail` lane so `Working` / `Thinking` / `Waiting` +/// follows the same vertical rhythm as every other assistant activity row (`L` 32 pt below a +/// user prompt, `M` 20 pt below prose or activity) instead of crowding at `LANE_TEXT_TOP` (11 pt). +pub(super) fn tail_extra(t: &Transcript, rows: &[RowSpec]) -> f32 { + let Some(prev) = rows.iter().rev().find_map(|r| edges_of(t, &r.content)) else { return 0.0 }; + let tail = Edges { assistant_part: true, ..edges(Who::Agent, Item::Line, crate::working::LANE_TEXT_TOP) }; + (gap(prev, tail) - prev.bottom - tail.top).max(0.0).round() } diff --git a/crates/session-view/src/working.rs b/crates/session-view/src/working.rs index 39de73c2f..13149cb23 100644 --- a/crates/session-view/src/working.rs +++ b/crates/session-view/src/working.rs @@ -456,6 +456,8 @@ pub const H: f32 = 24.0; pub const LANE: f32 = LANE_PAD + H; /// The status line's height (`--line-height-compact`). pub const LINE: f32 = 16.0; +/// Room remaining below the 16 pt status line inside `LANE` (36 - 11 - 16 = 9 pt). +pub const LANE_TEXT_BOTTOM: f32 = LANE - LANE_TEXT_TOP - LINE; /// The lane's row (`timeline-status-lane`: flex, centred, 8 apart): the status line and what /// sits beside it, the background hint's 24 pt button centred on the line and reaching 4 past it. pub const ROW_TOP: f32 = LANE_TEXT_TOP - (H - LINE) / 2.0; diff --git a/features/files/src/poll.rs b/features/files/src/poll.rs index 30be332bd..6ea2e1fca 100644 --- a/features/files/src/poll.rs +++ b/features/files/src/poll.rs @@ -41,7 +41,6 @@ pub fn poll_files(host: &mut dyn FilesHost, tx: &mut Tx) -> bool { && let Some(ws) = host.files_mut().sessions.get_mut(&session_id) && ws.search.answered(&query, found) { - tx.instant(); changed = true; } // A picture's size is known once it decodes: its stage lays out again. @@ -359,7 +358,6 @@ fn land_read(host: &mut dyn FilesHost, landed: content::Landed, tx: &mut Tx) -> ); return false; } - tx.instant(); let swap = rune::time::Instant::now(); let failed_msg = match &body { content::Body::Failed(wire) => { diff --git a/features/panels/src/keys.rs b/features/panels/src/keys.rs index b4eb31260..ffac2e324 100644 --- a/features/panels/src/keys.rs +++ b/features/panels/src/keys.rs @@ -250,11 +250,13 @@ pub fn panels_key(host: &mut dyn PanelsHost, ev: &KeyEvent, tx: &mut Tx) -> bool reg.pane_active(pane, stored) }); if let Some(nt) = shown_new_tab(host, &sid, pane, pane_act.as_deref()).cloned() { - tx.instant(); release_pane_width_hold(host, pane); dismiss_side_new_tab(host, &nt.id); if !side_open(host) { + tx.animated(); host.side_mut().close_guard.step(CloseTabGuardEvent::Emptied); + } else { + tx.instant(); } return true; } diff --git a/features/panels/src/state/actions.rs b/features/panels/src/state/actions.rs index 8c53015aa..48640dc82 100644 --- a/features/panels/src/state/actions.rs +++ b/features/panels/src/state/actions.rs @@ -598,8 +598,9 @@ pub fn close_side_tab(host: &mut dyn PanelsHost, key: &str, tx: &mut Tx) { side.focus.blur(); } if strip_empty && !side_new && side_stored_open(host) { - // The side region slides shut on its spring; a side tab it closed stays on screen - // until it lands. + // The side region slides shut on its spring; restore animation in case the closing tab's + // provider requested `tx.instant()`, and keep the closed tab on screen until it lands. + tx.animated(); let at = host.clock(); let shared = host.shared_side_panel(); let effects = { diff --git a/features/panels/src/view/strip.rs b/features/panels/src/view/strip.rs index b3f6e9f9a..0cbf06762 100644 --- a/features/panels/src/view/strip.rs +++ b/features/panels/src/view/strip.rs @@ -569,10 +569,14 @@ fn on_mouse_dismiss_new_tab( pointer: bool, tx: &mut Tx, ) { - tx.instant(); let event = if pointer { WidthHoldEvent::MouseClose(meta.clone()) } else { WidthHoldEvent::Release }; host.side_mut().width_holds[pane as usize].step(event); dismiss_side_new_tab(host, nid); + if crate::side_open(host) { + tx.instant(); + } else { + tx.animated(); + } } fn on_open_new_tab(host: &mut dyn PanelsHost, pane: SessionPane, tx: &mut Tx) {