diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 89abe7f9a2..1cd41731db 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -2356,7 +2356,7 @@ conventions and context. loaded, allowing you to verify the hierarchy and content being used by the AI. - See the [Commands documentation](./commands.md#memory) for full details on - the `/memory` command and its sub-commands (`show` and `refresh`). + the `/memory` command and its sub-commands (`show` and `reload`). By understanding and utilizing these configuration layers and the hierarchical nature of context files, you can effectively manage the AI's memory and tailor diff --git a/packages/cli/src/ui/components/messages/DenseToolMessage.test.tsx b/packages/cli/src/ui/components/messages/DenseToolMessage.test.tsx index d28e8ed468..1767eb10ad 100644 --- a/packages/cli/src/ui/components/messages/DenseToolMessage.test.tsx +++ b/packages/cli/src/ui/components/messages/DenseToolMessage.test.tsx @@ -1,6 +1,6 @@ /** * @license - * Copyright 2025 Google LLC + * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ @@ -31,6 +31,7 @@ describe('DenseToolMessage', () => { status: CoreToolCallStatus.Success, resultDisplay: 'Success result' as ToolResultDisplay, confirmationDetails: undefined, + terminalWidth: 80, }; it('renders correctly for a successful string result', async () => { diff --git a/packages/cli/src/ui/components/messages/DenseToolMessage.tsx b/packages/cli/src/ui/components/messages/DenseToolMessage.tsx index 60355c72a7..d127b75e91 100644 --- a/packages/cli/src/ui/components/messages/DenseToolMessage.tsx +++ b/packages/cli/src/ui/components/messages/DenseToolMessage.tsx @@ -1,6 +1,6 @@ /** * @license - * Copyright 2025 Google LLC + * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ @@ -36,8 +36,13 @@ import { colorizeCode } from '../../utils/CodeColorizer.js'; import { useToolActions } from '../../contexts/ToolActionsContext.js'; import { getFileExtension } from '../../utils/fileUtils.js'; +const PAYLOAD_MARGIN_LEFT = 6; +const PAYLOAD_BORDER_CHROME_WIDTH = 4; // paddingX=1 (2 cols) + borders (2 cols) +const PAYLOAD_SCROLL_GUTTER = 4; +const PAYLOAD_MAX_WIDTH = 120 + PAYLOAD_SCROLL_GUTTER; + interface DenseToolMessageProps extends IndividualToolCallDisplay { - terminalWidth?: number; + terminalWidth: number; availableTerminalHeight?: number; } @@ -63,10 +68,6 @@ const hasPayload = (res: unknown): res is PayloadResult => { return typeof value === 'string'; }; -/** - * --- RENDER HELPERS --- - */ - const RenderItemsList: React.FC<{ items?: string[]; maxVisible?: number; @@ -88,15 +89,11 @@ const RenderItemsList: React.FC<{ ); }; -/** - * --- SCENARIO LOGIC (Pure Functions) --- - */ - function getFileOpData( diff: FileDiff, status: CoreToolCallStatus, resultDisplay: unknown, - terminalWidth?: number, + terminalWidth: number, availableTerminalHeight?: number, isClickable?: boolean, ): ViewParts { @@ -177,7 +174,7 @@ function getFileOpData( @@ -309,10 +306,6 @@ function getGenericSuccessData( return { description, summary, payload }; } -/** - * --- MAIN COMPONENT --- - */ - export const DenseToolMessage: React.FC = (props) => { const { callId, @@ -339,7 +332,7 @@ export const DenseToolMessage: React.FC = (props) => { const [isFocused, setIsFocused] = useState(false); const toggleRef = useRef(null); - // 1. Unified File Data Extraction (Safely bridge resultDisplay and confirmationDetails) + // Unified File Data Extraction (Safely bridge resultDisplay and confirmationDetails) const diff = useMemo((): FileDiff | undefined => { if (isFileDiff(resultDisplay)) return resultDisplay; if (confirmationDetails?.type === 'edit') { @@ -375,7 +368,7 @@ export const DenseToolMessage: React.FC = (props) => { isActive: isAlternateBuffer && !!diff, }); - // 2. State-to-View Coordination + // State-to-View Coordination const viewParts = useMemo((): ViewParts => { if (diff) { return getFileOpData( @@ -459,7 +452,7 @@ export const DenseToolMessage: React.FC = (props) => { return colorizeCode({ code: addedContent, language: fileExtension, - maxWidth: terminalWidth ? terminalWidth - 6 : 80, + maxWidth: terminalWidth - PAYLOAD_MARGIN_LEFT, settings, disableColor: status === CoreToolCallStatus.Cancelled, returnLines: true, @@ -468,7 +461,7 @@ export const DenseToolMessage: React.FC = (props) => { return renderDiffLines({ parsedLines, filename: diff.fileName, - terminalWidth: terminalWidth ? terminalWidth - 6 : 80, + terminalWidth: terminalWidth - PAYLOAD_MARGIN_LEFT, disableColor: status === CoreToolCallStatus.Cancelled, }); } @@ -502,7 +495,6 @@ export const DenseToolMessage: React.FC = (props) => { {item} ); - // 3. Final Layout return ( @@ -529,7 +521,7 @@ export const DenseToolMessage: React.FC = (props) => { {showPayload && isAlternateBuffer && diffLines.length > 0 && ( = (props) => { borderStyle="round" borderColor={theme.border.default} borderDimColor={true} - maxWidth={terminalWidth ? Math.min(124, terminalWidth - 6) : 124} + maxWidth={Math.min( + PAYLOAD_MAX_WIDTH, + terminalWidth - PAYLOAD_MARGIN_LEFT, + )} > = (props) => { keyExtractor={keyExtractor} estimatedItemHeight={() => 1} hasFocus={isFocused} - width={ - // adjustment: 6 margin - 4 padding/border - 4 right-scroll-gutter - terminalWidth ? Math.min(120, terminalWidth - 6 - 4 - 4) : 70 - } + width={Math.min( + PAYLOAD_MAX_WIDTH, + terminalWidth - + PAYLOAD_MARGIN_LEFT - + PAYLOAD_BORDER_CHROME_WIDTH - + PAYLOAD_SCROLL_GUTTER, + )} /> )} {showPayload && (!isAlternateBuffer || !diff) && viewParts.payload && ( - + {viewParts.payload} )} {showPayload && outputFile && ( - + (Output saved to: {outputFile})