Include foreground activity in iTerm2 session status (#52226)

## Why

The iTerm2 session status reports `Working` without describing the current activity.

## What changed

Populate the OSC 21337 `detail` field from the TUI status header during foreground work, for example `Reading source`. Leave it empty for idle, waiting, background-only work, and the generic `Working` header.

Reuse terminal-title text filtering and the 240-character limit, then escape semicolons and backslashes for the status payload. Include detail in the emission cache so activity changes update the terminal even when the lifecycle state stays the same.

## Testing

Add coverage for foreground-only details, payload encoding, text filtering and truncation, and cache updates when the detail changes.

GitOrigin-RevId: b27a287b80e0db52be6cd9d5d246f03897e2996b
This commit is contained in:
Felipe Coury
2026-10-08 18:56:04 +00:00
committed by copyberry
parent bfe0fb9bb9
commit 96d238d0b9
7 changed files with 121 additions and 34 deletions
@@ -54,3 +54,30 @@ async fn session_status_follows_existing_lifecycle_state() {
[Idle, Working, Waiting, Working, Idle, Working, Idle]
);
}
#[tokio::test]
async fn session_status_detail_uses_only_foreground_activity() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let detail =
|chat: &ChatWidget, status| chat.iterm_session_detail(status).map(ToString::to_string);
chat.bottom_pane.set_task_running(/*running*/ true);
let generic = detail(&chat, Working);
chat.set_status_header("Reading source".to_string());
let working = detail(&chat, Working);
let waiting = detail(&chat, Waiting);
chat.bottom_pane.set_task_running(/*running*/ false);
let idle = detail(&chat, Idle);
let background = detail(&chat, Working);
let details = [generic, working, waiting, idle, background]
.map(|detail| detail.unwrap_or_else(|| "-".to_string()))
.join("\n");
insta::assert_snapshot!(details, @r"
-
Reading source
-
-
-
");
}