mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
## What changed Prefix cloud thread labels with `☁︎` in resume and fork pickers, the agents overview and task details, task mention suggestions, side chat tabs and chooser, status lines, and terminal titles. Keep the marker separate from thread names, search text, and identity, and account for its width when truncating labels. Track cloud backend identity independently of live connections so thread labels retain their marker after a disconnect. ## Testing Extend rendering tests and snapshots to cover cloud and local labels, narrow layouts, side chat tabs and chooser, and terminal title fallbacks and truncation. GitOrigin-RevId: ea8189ebcc5e35d2d2ef95d6a4a87ca23b5e3b8f
57 lines
1.8 KiB
Rust
57 lines
1.8 KiB
Rust
//! Display a thread's backend marker without changing its name, search text, or identity.
|
|
|
|
use crate::line_truncation::span_width;
|
|
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
|
|
use crate::text_formatting::truncate_text;
|
|
use ratatui::style::Stylize;
|
|
use ratatui::text::Line;
|
|
use ratatui::text::Span;
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
pub(crate) enum ThreadLabelStyle {
|
|
#[default]
|
|
Plain,
|
|
Cloud,
|
|
}
|
|
|
|
impl ThreadLabelStyle {
|
|
pub(crate) fn from_is_cloud(is_cloud: bool) -> Self {
|
|
if is_cloud { Self::Cloud } else { Self::Plain }
|
|
}
|
|
|
|
fn prefix(self) -> &'static str {
|
|
match self {
|
|
Self::Plain => "",
|
|
// U+FE0E requests text presentation on terminals with emoji-capable fonts.
|
|
Self::Cloud => "☁\u{fe0e} ",
|
|
}
|
|
}
|
|
|
|
pub(crate) fn prefix_width(self) -> usize {
|
|
span_width(&Span::raw(self.prefix()))
|
|
}
|
|
|
|
pub(crate) fn render(self, line: Line<'static>, width: usize) -> Line<'static> {
|
|
let prefix_width = self.prefix_width();
|
|
if prefix_width == 0 || width <= prefix_width {
|
|
return truncate_line_with_ellipsis_if_overflow(line, width);
|
|
}
|
|
let mut line = truncate_line_with_ellipsis_if_overflow(line, width - prefix_width);
|
|
line.spans.insert(0, self.prefix().dim());
|
|
line
|
|
}
|
|
|
|
/// Keep the picker's existing plain-text truncation for undecorated labels.
|
|
pub(crate) fn render_text(self, title: &str, width: usize) -> String {
|
|
match self {
|
|
Self::Plain => truncate_text(title, width),
|
|
Self::Cloud => self.render(Line::from(title.to_owned()), width).to_string(),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn decorate(self, mut title: String) -> String {
|
|
title.insert_str(0, self.prefix());
|
|
title
|
|
}
|
|
}
|