Compare commits

...

1 Commits

Author SHA1 Message Date
Omer Strulovich
958ece0410 Load terminal title from thread name automatically
Co-authored-by: Codex <noreply@openai.com>
2026-03-05 08:56:32 -05:00

View File

@@ -738,10 +738,12 @@ fn decorate_title_context(
fn compute_title_context(
title_override: Option<String>,
thread_name: Option<String>,
task_running: bool,
tick: u128,
) -> Option<String> {
let context = title_override
.or(thread_name)
.as_deref()
.map(str::trim)
.filter(|name| !name.is_empty())
@@ -1790,6 +1792,7 @@ impl App {
let task_running = app.chat_widget.is_task_running();
let title_context = compute_title_context(
app.chat_widget.title_override(),
app.chat_widget.thread_name(),
task_running,
title_animation_tick(),
);
@@ -1900,6 +1903,7 @@ impl App {
let task_running = app.chat_widget.is_task_running();
let title_context = compute_title_context(
app.chat_widget.title_override(),
app.chat_widget.thread_name(),
task_running,
title_animation_tick(),
);
@@ -3821,14 +3825,22 @@ mod tests {
}
#[test]
fn title_context_defaults_to_none_without_manual_title() {
assert_eq!(compute_title_context(None, false, 0), None);
fn title_context_uses_thread_name_when_idle() {
assert_eq!(
compute_title_context(None, Some("named thread".to_string()), false, 0),
Some("named thread".to_string())
);
}
#[test]
fn title_context_prefers_manual_title_when_idle() {
assert_eq!(
compute_title_context(Some("manual title".to_string()), false, 0),
compute_title_context(
Some("manual title".to_string()),
Some("named thread".to_string()),
false,
0,
),
Some("manual title".to_string())
);
}