mirror of
https://github.com/openai/codex.git
synced 2026-11-19 23:05:23 +00:00
Simplify and improve many UI elements. * Remove all-around borders in most places. These interact badly with terminal resizing and look heavy. Prefer left-side-only borders. * Make the viewport adjust to the size of its contents. * <kbd>/</kbd> and <kbd>@</kbd> autocomplete boxes appear below the prompt, instead of above it. * Restyle the keyboard shortcut hints & move them to the left. * Restyle the approval dialog. * Use synchronized rendering to avoid flashing during rerenders. https://github.com/user-attachments/assets/96f044af-283b-411c-b7fc-5e6b8a433c20 <img width="1117" height="858" alt="Screenshot 2025-07-30 at 5 29 20 PM" src="https://github.com/user-attachments/assets/0cc0af77-8396-429b-b6ee-9feaaccdbee7" />
56 lines
1.7 KiB
Rust
56 lines
1.7 KiB
Rust
use crate::user_approval_widget::ApprovalRequest;
|
|
use crossterm::event::KeyEvent;
|
|
use ratatui::buffer::Buffer;
|
|
use ratatui::layout::Rect;
|
|
|
|
use super::BottomPane;
|
|
use super::CancellationEvent;
|
|
|
|
/// Type to use for a method that may require a redraw of the UI.
|
|
pub(crate) enum ConditionalUpdate {
|
|
NeedsRedraw,
|
|
NoRedraw,
|
|
}
|
|
|
|
/// Trait implemented by every view that can be shown in the bottom pane.
|
|
pub(crate) trait BottomPaneView<'a> {
|
|
/// Handle a key event while the view is active. A redraw is always
|
|
/// scheduled after this call.
|
|
fn handle_key_event(&mut self, _pane: &mut BottomPane<'a>, _key_event: KeyEvent) {}
|
|
|
|
/// Return `true` if the view has finished and should be removed.
|
|
fn is_complete(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
/// Handle Ctrl-C while this view is active.
|
|
fn on_ctrl_c(&mut self, _pane: &mut BottomPane<'a>) -> CancellationEvent {
|
|
CancellationEvent::Ignored
|
|
}
|
|
|
|
/// Return the desired height of the view.
|
|
fn desired_height(&self, width: u16) -> u16;
|
|
|
|
/// Render the view: this will be displayed in place of the composer.
|
|
fn render(&self, area: Rect, buf: &mut Buffer);
|
|
|
|
/// Update the status indicator text.
|
|
fn update_status_text(&mut self, _text: String) -> ConditionalUpdate {
|
|
ConditionalUpdate::NoRedraw
|
|
}
|
|
|
|
/// Called when task completes to check if the view should be hidden.
|
|
fn should_hide_when_task_is_done(&mut self) -> bool {
|
|
false
|
|
}
|
|
|
|
/// Try to handle approval request; return the original value if not
|
|
/// consumed.
|
|
fn try_consume_approval_request(
|
|
&mut self,
|
|
request: ApprovalRequest,
|
|
) -> Option<ApprovalRequest> {
|
|
Some(request)
|
|
}
|
|
}
|