Add an experimental UI tree renderer for the status line (#57970)

## What changed

- Add the disabled-by-default `tui_extensions_statusline` feature to render configured status items and their picker preview through a shared UI tree renderer.
- Support text, HTTP(S) links, rows, spacers, dividers, and gaps with rendering budgets, text sanitization, and width-aware truncation that keeps the ellipsis outside hyperlinks.
- Use plain text for the extension status line and hide the picker's theme color toggle while preserving the saved color preference.

## Testing

Add coverage for tree serialization and URL validation, Unicode widths, hyperlink clipping, picker previews, color preference preservation, and token usage updates across renderer switches.

GitOrigin-RevId: a6b87c2b1096765d61296d73e142834fcd53ceee
This commit is contained in:
Joe Savona
2026-10-29 03:07:15 +00:00
committed by copyberry
parent 6c776cfc8c
commit 797bab4746
22 changed files with 670 additions and 86 deletions
@@ -5,6 +5,7 @@
//! history-facing `/status` surface.
use super::*;
use crate::bottom_pane::footer_content::FooterContent;
use crate::status::thread_cost_micros;
impl ChatWidget {
@@ -83,9 +84,8 @@ impl ChatWidget {
}
/// Sets the currently rendered footer status-line value.
pub(crate) fn set_status_line(&mut self, status_line: Option<HyperlinkLine>) {
self.bottom_pane
.set_status_line(status_line.map(Into::into));
pub(crate) fn set_status_line(&mut self, status_line: Option<FooterContent>) {
self.bottom_pane.set_status_line(status_line);
}
/// Forwards the contextual active-agent label into the bottom-pane footer pipeline.
@@ -368,6 +368,8 @@ impl ChatWidget {
}),
);
preview_data.thread_id = self.thread_id;
preview_data.renderer = self.status_line_renderer();
preview_data.pull_request_url = self.status_line_pull_request_url().map(str::to_owned);
if self.rate_limit_snapshots_by_limit_id.contains_key("codex") {
for item in [
+17 -4
View File
@@ -4,7 +4,7 @@
//! behavior easier to review without paging through the rest of `chatwidget.rs`.
use super::*;
use crate::bottom_pane::status_line_from_segments;
use crate::bottom_pane::status_line_content::StatusLineRenderer;
use crate::branch_summary;
use crate::chatwidget::limit_label_for_window;
use crate::chatwidget::rate_limits::get_limits_duration;
@@ -216,12 +216,25 @@ impl ChatWidget {
}
}
self.set_status_line(status_line_from_segments(
let content = self.status_line_renderer().content(
segments,
self.local_settings.tui.status_line_use_colors,
self.thread_id,
self.status_line_pull_request_url(),
));
);
self.set_status_line(content);
}
pub(super) fn status_line_renderer(&self) -> StatusLineRenderer {
if self
.config
.features
.enabled(Feature::TuiExtensionsStatusLine)
{
StatusLineRenderer::Extension
} else {
StatusLineRenderer::Native
}
}
/// Clears the terminal title Codex most recently wrote, if any.
@@ -846,7 +859,7 @@ impl ChatWidget {
}
}
fn status_line_pull_request_url(&self) -> Option<&str> {
pub(super) fn status_line_pull_request_url(&self) -> Option<&str> {
self.status_line_git_summary
.as_ref()
.and_then(|summary| summary.pull_request.as_ref())
@@ -28,7 +28,11 @@ async fn thread_color_preview_matches_footer() {
let mut snapshot = Vec::new();
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 line = preview
.status_line_for_items(items, use_colors)
.unwrap()
.into_hyperlink_line()
.line;
let footer = crate::bottom_pane::status_line_from_segments(
items
.into_iter()
@@ -50,7 +54,7 @@ fn status_preview_line_option(chat: &mut ChatWidget, items: &[StatusLineItem]) -
let preview_data = chat.status_surface_preview_data();
preview_data
.status_line_for_items(items.iter().copied(), /*use_theme_colors*/ true)
.map(line_text)
.map(|content| line_text(content.into_hyperlink_line().line))
}
fn status_preview_line(chat: &mut ChatWidget, items: &[StatusLineItem]) -> String {