A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(gui): ease the pane drop preview between zones
RoversX53e48ddfbf7f
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 077569a2..15d9aa4a 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -1285,6 +1285,58 @@ pub(crate) struct PaneTabDropTarget {pub rect: RectF,}+/// The drop preview as it is currently drawn, easing toward the rectangle+/// the drag state asks for. Kept apart from `PaneTabDragState` so the hit+/// testing stays a pure function of the pointer while the picture lags a+/// little behind it: a zone change slides and reshapes the highlight instead+/// of blinking it from one half of the pane to the other.+#[derive(Clone, Copy, Debug)]+pub(crate) struct PaneDropPreviewAnim {+ pub rect: ::window::RectF,+ /// 0 = invisible, 1 = fully shown. Fades in when a target first appears+ /// and out when the pointer leaves every droppable spot.+ pub alpha: f32,+ pub last_tick: Instant,+}++impl PaneDropPreviewAnim {+ /// Time constant of the exponential ease: ~95% of the way in three of+ /// these, so a zone change settles in roughly 130 ms.+ const TAU: Duration = Duration::from_millis(45);++ /// Advance toward `target` (None = fade out in place). Returns whether+ /// anything is still moving, so the caller can ask for another frame.+ pub fn step(&mut self, target: Option<::window::RectF>, now: Instant) -> bool {+ // A frame that was starved (window hidden, heavy paint) must not+ // land as one huge jump either; clamp the step.+ let dt = now+ .saturating_duration_since(self.last_tick)+ .min(Duration::from_millis(100));+ self.last_tick = now;+ let k = 1.0 - (-(dt.as_secs_f32() / Self::TAU.as_secs_f32())).exp();+ let (want_rect, want_alpha) = match target {+ Some(rect) => (rect, 1.0),+ None => (self.rect, 0.0),+ };+ let lerp = |cur: f32, want: f32| cur + (want - cur) * k;+ let mut moving = false;+ let mut settle = |cur: &mut f32, want: f32, eps: f32| {+ if (want - *cur).abs() <= eps {+ *cur = want;+ } else {+ *cur = lerp(*cur, want);+ moving = true;+ }+ };+ settle(&mut self.rect.origin.x, want_rect.origin.x, 0.5);+ settle(&mut self.rect.origin.y, want_rect.origin.y, 0.5);+ settle(&mut self.rect.size.width, want_rect.size.width, 0.5);+ settle(&mut self.rect.size.height, want_rect.size.height, 0.5);+ settle(&mut self.alpha, want_alpha, 0.01);+ moving+ }+}+/// A level-2 pane tab being dragged toward another pane to move or split.#[derive(Clone, Debug)]pub(crate) struct PaneTabDragState {@@ -1494,6 +1546,51 @@ mod tooltip_tests {mod pane_drop_tests {use super::*;+ #[test]+ fn drop_preview_eases_toward_target_and_fades_out() {+ let t0 = Instant::now();+ let a = euclid::rect(0.0, 0.0, 100.0, 50.0);+ let b = euclid::rect(200.0, 0.0, 100.0, 200.0);+ let mut anim = PaneDropPreviewAnim {+ rect: a,+ alpha: 0.0,+ last_tick: t0,+ };+ // Fades in without moving while the target is where it started.+ assert!(anim.step(Some(a), t0 + Duration::from_millis(16)));+ assert!(anim.alpha > 0.0 && anim.alpha < 1.0);+ assert_eq!(anim.rect, a);++ // A zone change slides and reshapes rather than jumping.+ let mut now = t0 + Duration::from_millis(32);+ assert!(anim.step(Some(b), now));+ assert!(anim.rect.origin.x > a.origin.x && anim.rect.origin.x < b.origin.x);+ assert!(anim.rect.size.height > a.size.height && anim.rect.size.height < b.size.height);+ // ...and settles within a few hundred milliseconds.+ let mut frames = 0;+ while anim.step(Some(b), now) {+ now += Duration::from_millis(16);+ frames += 1;+ assert!(frames < 60, "never settled: {anim:?}");+ }+ assert_eq!(anim.rect, b);+ assert_eq!(anim.alpha, 1.0);++ // Losing the target fades out in place; a stalled frame is clamped so+ // it cannot finish the fade in one jump.+ assert!(anim.step(None, now + Duration::from_secs(5)));+ assert!(anim.alpha > 0.0 && anim.alpha < 1.0);+ assert_eq!(anim.rect, b);+ now += Duration::from_secs(5);+ frames = 0;+ while anim.step(None, now) {+ now += Duration::from_millis(16);+ frames += 1;+ assert!(frames < 60, "never faded: {anim:?}");+ }+ assert_eq!(anim.alpha, 0.0);+ }+#[test]fn drop_zone_center_box_and_edges() {assert_eq!(pane_drop_zone(0.5, 0.5), PaneDropZone::Center);@@ -2491,6 +2588,8 @@ pub struct TermWindow {right_sidebar_file_drag: Option<FileDragState>,/// In-flight drag of a level-2 pane tab toward a move/split drop.pane_tab_drag: Option<PaneTabDragState>,+ /// Eased picture of `pane_tab_drag`'s drop target; see PaneDropPreviewAnim.+ pane_drop_preview: Option<PaneDropPreviewAnim>,/// In-flight reorder drag of a left-sidebar Project or thread row.sidebar_row_drag: Option<SidebarRowDragState>,/// Content views (e.g. SSH hosts) shown as synthetic tabs.@@ -4013,6 +4112,7 @@ impl TermWindow {dragging: None,right_sidebar_file_drag: None,pane_tab_drag: None,+ pane_drop_preview: None,sidebar_row_drag: None,content_views: vec![],active_content_view_id: None,diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex ae70da12..a79a55bd 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -3017,16 +3017,54 @@ impl crate::TermWindow {fn paint_pane_tab_drag_overlay(&mut self) -> anyhow::Result<()> {let Some(state) = self.pane_tab_drag.as_ref() else {+ // The drag ended (dropped or cancelled): the layout underneath+ // has already changed, so a lingering highlight would point at+ // nothing. Drop the picture rather than fade it.+ self.pane_drop_preview = None;return Ok(());};if !state.active {+ self.pane_drop_preview = None;return Ok(());}let label = state.title.clone();let anchor = state.current;let target_rect = state.target.as_ref().map(|target| target.rect);- if let Some(rect) = target_rect {+ // Ease the drawn highlight toward the hit-tested target. Driven here+ // and not from the mouse handler because paint_impl clears+ // has_animation on entry, so only a deadline registered during paint+ // survives to schedule the next frame.+ let now = Instant::now();+ let shown = match (self.pane_drop_preview.as_mut(), target_rect) {+ (None, None) => None,+ (None, Some(rect)) => {+ // First target of this drag: fade in where it is.+ let mut anim = crate::termwindow::PaneDropPreviewAnim {+ rect,+ alpha: 0.0,+ last_tick: now,+ };+ let moving = anim.step(target_rect, now);+ self.pane_drop_preview = Some(anim);+ Some((anim.rect, anim.alpha, moving))+ }+ (Some(anim), _) => {+ let moving = anim.step(target_rect, now);+ let shown = (anim.rect, anim.alpha, moving);+ if target_rect.is_none() && !moving {+ // Faded out completely; forget it so the next target+ // fades in fresh instead of sliding from a stale spot.+ self.pane_drop_preview = None;+ }+ Some(shown)+ }+ };++ if let Some((rect, alpha, moving)) = shown {+ if moving {+ self.update_next_frame_time(Some(now + Duration::from_millis(16)));+ }// Explicit accent blue: the palette's selected_bg is gray in// dark mode, but the drop preview should read as blue in both.let accent = match crate::native_settings::effective_appearance() {@@ -3037,8 +3075,8 @@ impl crate::TermWindow {LinearRgba::with_srgba(10, 132, 255, 255)}};- let fill = accent.mul_alpha(0.28);- let border = accent.mul_alpha(0.8);+ let fill = accent.mul_alpha(0.28 * alpha);+ let border = accent.mul_alpha(0.8 * alpha);let gl_state = self.render_state.as_ref().unwrap();let layer = gl_state