mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
## Why Switching reports reset their scroll positions, and resizing could pull users back to a selection they had deliberately scrolled away from. Small terminals also need room for usage details, while larger terminals can show more of the chart. ## What changed - Retain independent scroll positions for each report, the dashboard, and help. Keep visible selections on screen during resizing while respecting manual scrolling. - Hide plots in small report areas, expand charts to use available height, and place breakdown tables beside plots in wide focused reports. - Highlight selected chat and plan rows with the shared picker style, preserving padding after wrapping. - Show dated plan periods in the dashboard and collapse expanded plan details before closing with `Esc`. ## Testing Add regression tests and snapshots for responsive layouts, reading-position restoration across tabs and help, selection visibility during resizing, and highlighted chat-row padding. GitOrigin-RevId: e18a472ff4356324fed71e496f47762a7ccf657d
49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
//! Charts and legends share the terminal's ANSI palette.
|
|
//! Secondary text blends probed defaults only when the terminal supports that color depth.
|
|
|
|
use crate::color::blend;
|
|
use crate::style::accent_style;
|
|
use crate::terminal_palette::StdoutColorLevel;
|
|
use crate::terminal_palette::best_color;
|
|
use crate::terminal_palette::default_bg;
|
|
use crate::terminal_palette::default_fg;
|
|
use crate::terminal_palette::effective_stdout_color_level;
|
|
use ratatui::style::Color;
|
|
use ratatui::style::Style;
|
|
use ratatui::text::Span;
|
|
|
|
pub(super) fn series_colors() -> [Color; 4] {
|
|
[Color::Cyan, Color::Magenta, Color::Green, Color::Reset]
|
|
}
|
|
|
|
pub(super) fn number(text: impl Into<String>) -> Span<'static> {
|
|
Span::styled(text.into(), accent_style())
|
|
}
|
|
|
|
/// Labels and instructions need more contrast than decorative rules or inactive values.
|
|
pub(super) fn secondary_style() -> Style {
|
|
if !matches!(
|
|
effective_stdout_color_level(),
|
|
StdoutColorLevel::TrueColor | StdoutColorLevel::Ansi256
|
|
) {
|
|
return Style::default().dim();
|
|
}
|
|
match (default_fg(), default_bg()) {
|
|
(Some(fg), Some(bg)) => {
|
|
Style::default().fg(best_color(blend(fg, bg, /*alpha*/ 0.70)))
|
|
}
|
|
_ => Style::default().dim(),
|
|
}
|
|
}
|
|
|
|
/// Paint one selectable row, including its padding, using the shared picker accent.
|
|
pub(super) fn select_row(line: &mut ratatui::text::Line<'static>, width: usize) {
|
|
let style = crate::bottom_pane::selection_style();
|
|
line.spans
|
|
.push(" ".repeat(width.saturating_sub(line.width())).into());
|
|
line.style = style;
|
|
for span in &mut line.spans {
|
|
span.style = style;
|
|
}
|
|
}
|