summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/messages/ToolMessage.tsx
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-05-15 22:56:03 -0700
committerN. Taylor Mullen <[email protected]>2025-05-15 22:57:28 -0700
commit9c46acc793df3573e6fbcf53ac3e46663494e410 (patch)
tree82c40d365c60f5e578a7548c65a15cb6e4838ccd /packages/cli/src/ui/components/messages/ToolMessage.tsx
parent33743d347b6721f8eec537d01ad9f6a95b4c6683 (diff)
Refactor: Improve UI rendering and address code review comments
This commit addresses several code review comments primarily focused on improving the rendering and stability of the CLI UI. Key changes include: - Passing `isPending` and `availableTerminalHeight` props to `MarkdownDisplay` to enable more intelligent rendering of content, especially for pending messages and code blocks. - Adjusting height calculations in `ToolGroupMessage` and `ToolMessage` to more accurately reflect available space. - Refining the logic in `App.tsx` for measuring and utilizing terminal height, including renaming `footerRef` to `mainControlsRef` for clarity. - Ensuring consistent prop drilling for `isPending` and `availableTerminalHeight` through `HistoryItemDisplay`, `GeminiMessage`, and `GeminiMessageContent`. - In `MarkdownDisplay`, when `isPending` is true and content exceeds `availableTerminalHeight`, the code block will now be truncated with a "... generating more ..." message. If there's insufficient space even for the message, a simpler "... code is being written ..." will be shown.
Diffstat (limited to 'packages/cli/src/ui/components/messages/ToolMessage.tsx')
-rw-r--r--packages/cli/src/ui/components/messages/ToolMessage.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/cli/src/ui/components/messages/ToolMessage.tsx b/packages/cli/src/ui/components/messages/ToolMessage.tsx
index 220578de..091785f2 100644
--- a/packages/cli/src/ui/components/messages/ToolMessage.tsx
+++ b/packages/cli/src/ui/components/messages/ToolMessage.tsx
@@ -26,7 +26,6 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
const statusIndicatorWidth = 3;
const hasResult = resultDisplay && resultDisplay.toString().trim().length > 0;
const staticHeight = /* Header */ 1;
- availableTerminalHeight -= staticHeight;
let displayableResult = resultDisplay;
let hiddenLines = 0;
@@ -37,7 +36,7 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
const lines = resultDisplay.split('\n');
// Estimate available height for this specific tool message content area
// This is a rough estimate; ideally, we'd have a more precise measurement.
- const contentHeightEstimate = availableTerminalHeight - 5; // Subtracting lines for tool name, status, padding etc.
+ const contentHeightEstimate = availableTerminalHeight - staticHeight - 5; // Subtracting lines for tool name, status, padding etc.
if (lines.length > contentHeightEstimate && contentHeightEstimate > 0) {
displayableResult = lines.slice(0, contentHeightEstimate).join('\n');
hiddenLines = lines.length - contentHeightEstimate;
@@ -83,7 +82,11 @@ export const ToolMessage: React.FC<ToolMessageProps> = ({
<Box flexDirection="column">
{typeof displayableResult === 'string' && (
<Box flexDirection="column">
- <MarkdownDisplay text={displayableResult} />
+ <MarkdownDisplay
+ text={displayableResult}
+ isPending={false}
+ availableTerminalHeight={availableTerminalHeight}
+ />
</Box>
)}
{typeof displayableResult === 'object' && (