Skip to content

πŸ™Œ OpenHands: AI-Driven Development

issue #9388, this will fix the issue (#10450)

BenYao21d3d70fcc6093
diff --git a/openhands/cli/tui.py b/openhands/cli/tui.py
index 659020d0fc..9d24059c2a 100644
--- a/openhands/cli/tui.py
+++ b/openhands/cli/tui.py
@@ -73,6 +73,9 @@ streaming_output_text_area: TextArea | None = None
recent_thoughts: list[str] = []
MAX_RECENT_THOUGHTS = 5
+# Maximum number of lines to display for command output
+MAX_OUTPUT_LINES = 15
+
# Color and styling constants
DEFAULT_STYLE = get_cli_style()
@@ -407,20 +410,28 @@ def display_command_output(output: str) -> None:
# TODO: clean this up once we clean up terminal output
continue
formatted_lines.append(line)
- formatted_lines.append('\n')
- # Remove the last newline if it exists
- if formatted_lines:
- formatted_lines.pop()
+ # Truncate long outputs
+ title = 'Command Output'
+ if len(formatted_lines) > MAX_OUTPUT_LINES:
+ truncated_lines = formatted_lines[:MAX_OUTPUT_LINES]
+ remaining_lines = len(formatted_lines) - MAX_OUTPUT_LINES
+ truncated_lines.append(
+ f'... and {remaining_lines} more lines \n use --full to see complete output'
+ )
+ formatted_output = '\n'.join(truncated_lines)
+ title = f'Command Output (showing {MAX_OUTPUT_LINES} of {len(formatted_lines)} lines)'
+ else:
+ formatted_output = '\n'.join(formatted_lines)
container = Frame(
TextArea(
- text=''.join(formatted_lines),
+ text=formatted_output,
read_only=True,
style=COLOR_GREY,
wrap_lines=True,
),
- title='Command Output',
+ title=title,
style=f'fg:{COLOR_GREY}',
)
print_formatted_text('')