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/zeph-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct App {
metrics_rx: Option<watch::Receiver<MetricsSnapshot>>,
active_panel: Panel,
tool_expanded: bool,
compact_tools: bool,
status_label: Option<String>,
throbber_state: throbber_widgets_tui::ThrobberState,
confirm_state: Option<ConfirmState>,
Expand Down Expand Up @@ -86,6 +87,7 @@ impl App {
metrics_rx: None,
active_panel: Panel::Chat,
tool_expanded: false,
compact_tools: false,
status_label: None,
throbber_state: throbber_widgets_tui::ThrobberState::default(),
confirm_state: None,
Expand Down Expand Up @@ -188,6 +190,11 @@ impl App {
self.tool_expanded
}

#[must_use]
pub fn compact_tools(&self) -> bool {
self.compact_tools
}

#[must_use]
pub fn status_label(&self) -> Option<&str> {
self.status_label.as_deref()
Expand Down Expand Up @@ -466,6 +473,9 @@ impl App {
KeyCode::Char('e') => {
self.tool_expanded = !self.tool_expanded;
}
KeyCode::Char('c') => {
self.compact_tools = !self.compact_tools;
}
KeyCode::Tab => {
self.active_panel = match self.active_panel {
Panel::Chat => Panel::Skills,
Expand Down
52 changes: 31 additions & 21 deletions crates/zeph-tui/src/widgets/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,30 +268,40 @@ fn render_tool_message(

// Output lines (everything after the command)
if content_lines.len() > 1 {
let output_lines = &content_lines[1..];

let mut wrapped: Vec<Line<'static>> = Vec::new();
for line in output_lines {
let spans = vec![
Span::styled(indent.clone(), Style::default()),
Span::styled((*line).to_string(), theme.code_block),
];
wrapped.extend(wrap_spans(spans, wrap_width));
}

let total_visual = wrapped.len();
let show_all = app.tool_expanded() || total_visual <= TOOL_OUTPUT_COLLAPSED_LINES;

if show_all {
lines.extend(wrapped);
} else {
lines.extend(wrapped.into_iter().take(TOOL_OUTPUT_COLLAPSED_LINES));
let remaining = total_visual - TOOL_OUTPUT_COLLAPSED_LINES;
let hint = format!("{indent}... ({remaining} more lines, press 'e' to expand)");
if app.compact_tools() {
let line_count = content_lines.len() - 1;
let noun = if line_count == 1 { "line" } else { "lines" };
let summary = format!("{indent}-- {line_count} {noun}");
lines.push(Line::from(Span::styled(
hint,
summary,
Style::default().add_modifier(Modifier::DIM),
)));
} else {
let output_lines = &content_lines[1..];

let mut wrapped: Vec<Line<'static>> = Vec::new();
for line in output_lines {
let spans = vec![
Span::styled(indent.clone(), Style::default()),
Span::styled((*line).to_string(), theme.code_block),
];
wrapped.extend(wrap_spans(spans, wrap_width));
}

let total_visual = wrapped.len();
let show_all = app.tool_expanded() || total_visual <= TOOL_OUTPUT_COLLAPSED_LINES;

if show_all {
lines.extend(wrapped);
} else {
lines.extend(wrapped.into_iter().take(TOOL_OUTPUT_COLLAPSED_LINES));
let remaining = total_visual - TOOL_OUTPUT_COLLAPSED_LINES;
let hint = format!("{indent}... ({remaining} more lines, press 'e' to expand)");
lines.push(Line::from(Span::styled(
hint,
Style::default().add_modifier(Modifier::DIM),
)));
}
}
}
}
Expand Down
Loading