mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add consistent theme-based thread colors across the TUI (#44857)
## What changed Assign thread colors deterministically from the full thread ID and the active syntax theme's accents. Use the same color for thread names and titles in the status line, status previews, agents overview, and resume/fork pickers, independent of renaming or list order. Preserve thread colors when picker rows are selected and honor `tui.status_line_use_colors`. Load the configured theme before startup pickers render and refresh the cached palette when the theme changes. Fall back to the terminal's default color when no accents are available. ## Testing Add unit and snapshot tests for palette extraction and refresh, default accent coverage, selected titles in both picker layouts, color suppression, and preview/footer consistency during automatic naming. GitOrigin-RevId: 2b83a66bb3e80d4a1daea48ab9a86dbf2b525eef
This commit is contained in:
1 parent
654b0a77d0
commit
0818b6550b
17 files changed
+398
-19
No files matched your search
@@ -364,6 +364,7 @@ impl ChatWidget {
|
||||
.map(|value| (item, value))
|
||||
}),
|
||||
);
|
||||
preview_data.thread_id = self.thread_id;
|
||||
|
||||
if self.rate_limit_snapshots_by_limit_id.contains_key("codex") {
|
||||
for item in [
|
||||
|
||||
@@ -218,6 +218,7 @@ impl ChatWidget {
|
||||
self.set_status_line(status_line_from_segments(
|
||||
segments,
|
||||
self.local_settings.tui.status_line_use_colors,
|
||||
self.thread_id,
|
||||
));
|
||||
let hyperlink_url = selections
|
||||
.status_line_items
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/status_surface_previews.rs
|
||||
expression: "snapshot.join(\"\\n\")"
|
||||
---
|
||||
pending=false colors=true: Line::from_iter([Span::from("Named task").fg(Color::Rgb(242, 205, 205)), Span::from(" · ").dim(), Span::from("Named task").fg(Color::Rgb(242, 205, 205))])
|
||||
pending=false colors=false: Line::from_iter([Span::from("Named task").dim(), Span::from(" · ").dim(), Span::from("Named task").dim()])
|
||||
pending=true colors=true: Line::from_iter([Span::from("Named task ⠋").fg(Color::Rgb(242, 205, 205)), Span::from(" · ").dim(), Span::from("Named task ⠋").fg(Color::Rgb(242, 205, 205))])
|
||||
pending=true colors=false: Line::from_iter([Span::from("Named task ⠋").dim(), Span::from(" · ").dim(), Span::from("Named task ⠋").dim()])
|
||||
@@ -12,6 +12,35 @@ fn line_text(line: Line<'static>) -> String {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_color_preview_matches_footer_while_auto_naming() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let id = ThreadId::from_u128(/*value*/ 42);
|
||||
chat.thread_id = Some(id);
|
||||
chat.local_settings.tui.animations = false;
|
||||
chat.thread_name = Some("Named task".into());
|
||||
let items = [StatusLineItem::ThreadName, StatusLineItem::ThreadTitle];
|
||||
let mut snapshot = Vec::new();
|
||||
for pending in [false, true] {
|
||||
chat.set_thread_title_generation_pending(pending);
|
||||
let preview = chat.status_surface_preview_data();
|
||||
for use_colors in [true, false] {
|
||||
let line = preview.status_line_for_items(items, use_colors).unwrap();
|
||||
let footer = crate::bottom_pane::status_line_from_segments(
|
||||
items
|
||||
.into_iter()
|
||||
.map(|item| (item, chat.status_line_value_for_item(item).unwrap())),
|
||||
use_colors,
|
||||
Some(id),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(line, footer);
|
||||
snapshot.push(format!("pending={pending} colors={use_colors}: {line:?}"));
|
||||
}
|
||||
}
|
||||
insta::assert_snapshot!(snapshot.join("\n"));
|
||||
}
|
||||
|
||||
fn status_preview_line_option(chat: &mut ChatWidget, items: &[StatusLineItem]) -> Option<String> {
|
||||
let preview_data = chat.status_surface_preview_data();
|
||||
preview_data
|
||||
|
||||
Reference in new issue
Block a user