Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/ox-core/src/config/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ pub struct TuiChromePatch {
/// Override for divider rules between entries.
#[serde(skip_serializing_if = "Option::is_none")]
pub show_dividers: Option<bool>,
/// Override for live activity indicator visibility above the input box.
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_indicator: Option<bool>,
}

/// Partial override for TUI glyph and icon settings.
Expand Down Expand Up @@ -301,6 +304,10 @@ impl TuiConfigPatch {
merge_opt(&mut target.tool_style, overlay_chrome.tool_style);
merge_opt(&mut target.density, overlay_chrome.density);
merge_opt(&mut target.show_dividers, overlay_chrome.show_dividers);
merge_opt(
&mut target.activity_indicator,
overlay_chrome.activity_indicator,
);
}

if let Some(overlay_glyphs) = overlay.glyphs {
Expand Down Expand Up @@ -418,6 +425,7 @@ mod tests {
tool_style = "card"
density = "relaxed"
show_dividers = true
activity_indicator = true
"#};
let overlay_toml = indoc! {r##"
[layout]
Expand Down Expand Up @@ -454,6 +462,7 @@ mod tests {
tool_style = "compact"
density = "compact"
show_dividers = false
activity_indicator = false
"##};

let mut base: TuiConfigPatch = toml::from_str(base_toml).unwrap();
Expand Down Expand Up @@ -482,6 +491,7 @@ mod tests {
assert_eq!(chrome.tool_style, Some(ToolStyle::Compact));
assert_eq!(chrome.density, Some(Density::Compact));
assert_eq!(chrome.show_dividers, Some(false));
assert_eq!(chrome.activity_indicator, Some(false));
}

fn assert_merged_input(input: &TuiInputPatch) {
Expand Down
13 changes: 11 additions & 2 deletions crates/ox-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,19 @@ impl App {
!matches!(self.status, AppStatus::Idle)
}

/// Returns `true` while an agent turn or any subagent is actively running.
/// Returns `true` while a visible spinner animation should tick.
#[must_use]
pub fn needs_spinner(&self) -> bool {
self.is_busy()
(self.is_busy() && self.tui_config.chrome.activity_indicator)
|| self.visible_entries().iter().any(|entry| {
matches!(
entry,
TranscriptEntry::ToolCall {
status: ToolCallStatus::Running,
..
}
)
})
|| self
.subagents
.iter()
Expand Down
5 changes: 3 additions & 2 deletions crates/ox-tui/src/render/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,18 @@ fn build_layout_plan(inputs: &LayoutPlanInputs<'_>) -> (Vec<ResolvedSlot>, Vec<C
let config = inputs.config;
let needs_transient_hint =
inputs.has_active_hint && !config.layout.slots.contains(&LayoutSlot::Hints);
let show_activity = inputs.has_activity && config.chrome.activity_indicator;
let extra = usize::from(inputs.overlay_height.is_some())
+ usize::from(inputs.completion.is_some())
+ usize::from(inputs.has_subagents)
+ usize::from(needs_transient_hint)
+ usize::from(inputs.has_activity);
+ usize::from(show_activity);
let mut slots = Vec::with_capacity(config.layout.slots.len() + extra);
let mut overlay_inserted = inputs.overlay_height.is_none();
let mut completion_inserted = inputs.completion.is_none();
let mut subagent_inserted = !inputs.has_subagents;
let mut hint_inserted = !needs_transient_hint;
let mut activity_inserted = !inputs.has_activity;
let mut activity_inserted = !show_activity;

for &slot in &config.layout.slots {
if slot == LayoutSlot::Input {
Expand Down
52 changes: 52 additions & 0 deletions crates/ox-tui/src/render/ui/tests/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,58 @@ fn render_activity_indicator_above_input_when_busy_and_hides_when_idle() {
assert!(!done_screen.contains("Running bash..."));
}

#[test]
fn render_activity_indicator_hides_when_disabled_in_chrome_config() {
let mut cfg = TuiConfig::default();
cfg.chrome.activity_indicator = false;
let mut app = App::new("gemini-4-hydrogen").with_tui_config(cfg);

app.submit_user_message("check status".into(), Vec::new());
app.set_turn_started_at(Instant::now().checked_sub(Duration::from_secs(4)));
assert!(!app.needs_spinner());

let thinking_screen = render_to_string(&app, 80, 14);
assert!(!thinking_screen.contains("Thinking..."));
assert!(!thinking_screen.contains('⣾'));

app.apply_agent_event(AgentEvent::TextDelta("working on it".into()));
assert!(!app.needs_spinner());
let streaming_screen = render_to_string(&app, 80, 14);
assert!(!streaming_screen.contains("Thinking..."));

app.apply_agent_event(AgentEvent::ToolCallStart {
id: "call_1".into(),
name: "bash".into(),
arguments: serde_json::json!({ "command": "cargo test" }),
});
assert!(app.needs_spinner());
let tool_screen = render_to_string(&app, 80, 14);
assert!(!tool_screen.contains("Running bash..."));
assert!(tool_screen.contains("bash"));

app.apply_agent_event(AgentEvent::ToolResult {
call_id: "call_1".into(),
name: "bash".into(),
content: "ok".into(),
is_error: false,
});
assert!(!app.needs_spinner());

app.apply_agent_event(AgentEvent::Done {
reason: AgentStopReason::Completed(StopReason::EndTurn),
turns: 1,
messages: app.messages().to_vec(),
});
assert!(!app.needs_spinner());

app.upsert_subagent(SubagentStatus {
id: "sub-1".into(),
role: "reviewer".into(),
state: SubagentState::Running("checking diff".into()),
});
assert!(app.needs_spinner());
}

#[test]
fn render_activity_indicator_uses_ascii_spinner_frames_in_ascii_preset() {
let mut app = App::new("gemini-4-hydrogen").with_tui_config(preset_config("ascii"));
Expand Down
10 changes: 10 additions & 0 deletions crates/ox-tui/src/style/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ pub struct TuiChromeConfig {
pub density: Density,
/// Whether to draw horizontal divider rules between transcript entries.
pub show_dividers: bool,
/// Whether to show the live activity indicator row above the input box while busy.
pub activity_indicator: bool,
}

impl Default for TuiChromeConfig {
Expand Down Expand Up @@ -290,6 +292,9 @@ impl TuiConfig {
if let Some(show_dividers) = chrome.show_dividers {
self.chrome.show_dividers = show_dividers;
}
if let Some(activity_indicator) = chrome.activity_indicator {
self.chrome.activity_indicator = activity_indicator;
}
}

if let Some(glyphs) = &patch.glyphs {
Expand Down Expand Up @@ -563,6 +568,7 @@ mod tests {
assert_eq!(cfg.chrome.tool_style, ToolStyle::Compact);
assert_eq!(cfg.chrome.density, Density::Normal);
assert!(!cfg.chrome.show_dividers);
assert!(cfg.chrome.activity_indicator);
assert_eq!(cfg.glyphs.accent_bar, "▎ ");
assert_eq!(cfg.glyphs.tool_collapsed, "▸");
assert_eq!(cfg.glyphs.tool_expanded, "▾");
Expand Down Expand Up @@ -634,6 +640,9 @@ mod tests {
[input]
border = "none"

[chrome]
activity_indicator = false

[glyphs]
tool_ok = "OK"
"#};
Expand Down Expand Up @@ -664,6 +673,7 @@ mod tests {
assert_eq!(resolved.chrome.density, Density::Compact);
// Layer 4 (user [tui.*]): overrides preset and theme.
assert_eq!(resolved.input.border, InputBorderStyle::None);
assert!(!resolved.chrome.activity_indicator);
assert_eq!(resolved.glyphs.tool_ok, "OK");
}

Expand Down
1 change: 1 addition & 0 deletions crates/ox-tui/tui/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ message_style = "prompt"
tool_style = "compact"
density = "normal"
show_dividers = false
activity_indicator = true

[glyphs]
accent_bar = "▎ "
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/tui/statusline.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ warn_pct = 50
error_pct = 80
```

To show turn status only in the statusline, include `"status"` in `left` or `right` and set `activity_indicator = false` under [`[tui.chrome]`](tui.md#tuichrome).

## External Command Mode

Setting `command` on `StatusLineConfig` replaces the built-in layout with stdout from an external command, rendering up to 4 lines (dropping empty trailing lines) and sizing the statusline slot to match. Scripts written for Claude Code statuslines, such as [hakulab/statusline](https://github.com/hakulab/statusline), work directly:
Expand Down
15 changes: 8 additions & 7 deletions docs/reference/tui/tui.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ Standalone preset files (`tui/<name>.toml`) omit the `[tui]` prefix and use `[la

### `[tui.chrome]`

| Field | Type | Default | Description |
| ------------------- | --------- | ----------- | --------------------------------------------------------------------------------- |
| `transcript_border` | `boolean` | `false` | Draw a box border around the transcript pane |
| `message_style` | `string` | `"prompt"` | Message presentation: `"prompt"`, `"accent_bar"`, `"prefix"`, or `"box"` |
| `tool_style` | `string` | `"compact"` | Tool call presentation: `"compact"` or `"card"` |
| `density` | `string` | `"normal"` | Vertical spacing between transcript entries: `"compact"`, `"normal"`, `"relaxed"` |
| `show_dividers` | `boolean` | `false` | Draw horizontal divider rules between transcript entries |
| Field | Type | Default | Description |
| -------------------- | --------- | ----------- | --------------------------------------------------------------------------------- |
| `transcript_border` | `boolean` | `false` | Draw a box border around the transcript pane |
| `message_style` | `string` | `"prompt"` | Message presentation: `"prompt"`, `"accent_bar"`, `"prefix"`, or `"box"` |
| `tool_style` | `string` | `"compact"` | Tool call presentation: `"compact"` or `"card"` |
| `density` | `string` | `"normal"` | Vertical spacing between transcript entries: `"compact"`, `"normal"`, `"relaxed"` |
| `show_dividers` | `boolean` | `false` | Draw horizontal divider rules between transcript entries |
| `activity_indicator` | `boolean` | `true` | Show the live activity spinner row above the input box while a turn is running |

### `[tui.glyphs]`

Expand Down
Loading