Files
codex/codex-rs/tui/src/app/pane_motion.rs
T
Felipe Coury 194f2662b8 Add a sidebar chooser and floating workspace shortcut panels (#59739)
## What changed

- Open a sidebar chooser when no side chat exists, with keyboard and mouse controls to start a new side chat while preserving the parent draft.
- Animate sidebar opening and closing, including reversing an unfinished transition, when animations are enabled.
- Show context-aware workspace shortcuts in a floating panel after a short delay, and render presets in the same overlay without moving the composer.
- Prevent chooser input from accepting an approval dialog before it has been painted.

## Testing

Add coverage for chooser activation and draft preservation, sidebar animation reversal, shortcut and preset snapshots, and approval input handling.

GitOrigin-RevId: 014112622a94798f4e611756c55112dfd8016051
2026-11-05 21:05:51 +00:00

40 lines
1.3 KiB
Rust

//! Slide the sidebar from its last painted width, independently of keyboard focus.
use std::time::Duration;
use tokio::time::Instant;
use crate::tui::FrameRequester;
use crate::tui::TARGET_FRAME_INTERVAL;
const SLIDE_DURATION: Duration = Duration::from_millis(180);
#[derive(Clone, Debug, Default)]
pub(super) struct PaneMotion {
fraction: f64,
target: f64,
slide: Option<(Instant, f64)>,
}
impl PaneMotion {
/// Without a frame requester, snap to the target immediately.
pub(super) fn advance(&mut self, open: bool, frames: Option<FrameRequester>) -> f64 {
let target = f64::from(open);
if self.target != target {
self.target = target;
self.slide = Some((Instant::now(), self.fraction));
}
if let (Some((start, from)), Some(frames)) = (self.slide, frames) {
let progress = start.elapsed().as_secs_f64() / SLIDE_DURATION.as_secs_f64();
if progress < 1.0 && from != target {
let eased = progress * progress * (3.0 - 2.0 * progress);
self.fraction = from + (target - from) * eased;
frames.schedule_frame_in(TARGET_FRAME_INTERVAL);
return self.fraction;
}
}
self.slide = None;
self.fraction = target;
target
}
}