fix(ui): remove redundant newlines in Gemini messages (#18538)

This commit is contained in:
N. Taylor Mullen
2026-02-09 20:18:21 -08:00
committed by GitHub
parent d3cfbdb3b7
commit ece001f264
13 changed files with 46 additions and 49 deletions

View File

@@ -19,7 +19,7 @@ import {
import { createExtension } from '../test-utils/createExtension.js';
import { ExtensionManager } from './extension-manager.js';
import { themeManager, DEFAULT_THEME } from '../ui/themes/theme-manager.js';
import { GEMINI_DIR, type Config } from '@google/gemini-cli-core';
import { GEMINI_DIR, type Config, tmpdir } from '@google/gemini-cli-core';
import { createTestMergedSettings, SettingScope } from './settings.js';
describe('ExtensionManager theme loading', () => {
@@ -29,7 +29,7 @@ describe('ExtensionManager theme loading', () => {
beforeAll(async () => {
tempHomeDir = await fs.promises.mkdtemp(
path.join(fs.realpathSync('/tmp'), 'gemini-cli-test-'),
path.join(tmpdir(), 'gemini-cli-test-'),
);
});

View File

@@ -122,6 +122,9 @@ const configProxy = new Proxy({} as Config, {
return () =>
'/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long';
}
if (prop === 'getUseBackgroundColor') {
return () => true;
}
const internal = getMockConfigInternal();
if (prop in internal) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion

View File

@@ -9,17 +9,21 @@ import { ShowMoreLines } from './ShowMoreLines.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { useOverflowState } from '../contexts/OverflowContext.js';
import { useStreamingContext } from '../contexts/StreamingContext.js';
import { useAlternateBuffer } from '../hooks/useAlternateBuffer.js';
import { StreamingState } from '../types.js';
vi.mock('../contexts/OverflowContext.js');
vi.mock('../contexts/StreamingContext.js');
vi.mock('../hooks/useAlternateBuffer.js');
describe('ShowMoreLines', () => {
const mockUseOverflowState = vi.mocked(useOverflowState);
const mockUseStreamingContext = vi.mocked(useStreamingContext);
const mockUseAlternateBuffer = vi.mocked(useAlternateBuffer);
beforeEach(() => {
vi.clearAllMocks();
mockUseAlternateBuffer.mockReturnValue(false);
});
it.each([

View File

@@ -31,7 +31,7 @@ export const ShowMoreLines = ({ constrainHeight }: ShowMoreLinesProps) => {
}
return (
<Box>
<Box paddingX={1}>
<Text color={theme.text.secondary} wrap="truncate">
Press ctrl-o to show more lines
</Text>

View File

@@ -150,9 +150,7 @@ export const ToolConfirmationQueue: React.FC<ToolConfirmationQueueProps> = ({
borderStyle="round"
/>
</Box>
<Box paddingX={2} marginBottom={1}>
<ShowMoreLines constrainHeight={constrainHeight} />
</Box>
<ShowMoreLines constrainHeight={constrainHeight} />
</OverflowProvider>
);
};

View File

@@ -54,3 +54,14 @@ exports[`<BackgroundShellDisplay /> > scrolls to active shell when list opens 1`
│ ● 2. tail -f log.txt (PID: 1002) │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘"
`;
exports[`<BackgroundShellDisplay /> > selects the current process and closes the list when Ctrl+L is pressed in list view 1`] = `
"┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 1: npm sta... (PID: 1001) (Focused) Close (Ctrl+B) | Kill (Ctrl+K) | List (Ctrl+L) │
│ │
│ Select Process (Enter to select, Ctrl+K to kill, Esc to cancel): │
│ │
│ ● 1. npm start (PID: 1001) │
│ 2. tail -f log.txt (PID: 1002) │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘"
`;

View File

@@ -28,7 +28,7 @@ AppHeader
│ Line 20 │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
ShowMoreLines"
ShowMoreLines"
`;
exports[`MainContent > MainContent Tool Output Height Logic > 'ASB mode - Unfocused shell' 1`] = `
@@ -53,7 +53,7 @@ AppHeader
│ Line 19 █ │
│ Line 20 █ │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
ShowMoreLines"
ShowMoreLines"
`;
exports[`MainContent > MainContent Tool Output Height Logic > 'Normal mode - Constrained height' 1`] = `
@@ -77,7 +77,7 @@ exports[`MainContent > MainContent Tool Output Height Logic > 'Normal mode - Con
│ Line 19 │
│ Line 20 │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
ShowMoreLines"
ShowMoreLines"
`;
exports[`MainContent > MainContent Tool Output Height Logic > 'Normal mode - Unconstrained height' 1`] = `
@@ -101,7 +101,7 @@ exports[`MainContent > MainContent Tool Output Height Logic > 'Normal mode - Unc
│ Line 19 │
│ Line 20 │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
ShowMoreLines"
ShowMoreLines"
`;
exports[`MainContent > does not constrain height in alternate buffer mode 1`] = `

View File

@@ -16,8 +16,7 @@ exports[`ToolConfirmationQueue > calculates availableContentHeight based on avai
│ 4. No, suggest changes (esc) │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
Press ctrl-o to show more lines
"
Press ctrl-o to show more lines"
`;
exports[`ToolConfirmationQueue > does not render expansion hint when constrainHeight is false 1`] = `
@@ -38,8 +37,7 @@ exports[`ToolConfirmationQueue > does not render expansion hint when constrainHe
│ 3. Modify with external editor │
│ 4. No, suggest changes (esc) │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
"
╰──────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`ToolConfirmationQueue > renders expansion hint when content is long and constrained 1`] = `
@@ -58,7 +56,7 @@ exports[`ToolConfirmationQueue > renders expansion hint when content is long and
│ 4. No, suggest changes (esc) │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
Press ctrl-o to show more lines
Press ctrl-o to show more lines
@@ -88,6 +86,5 @@ exports[`ToolConfirmationQueue > renders the confirming tool with progress indic
│ 2. Allow for this session │
│ 3. No, suggest changes (esc) │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
"
╰──────────────────────────────────────────────────────────────────────────────╯"
`;

View File

@@ -50,7 +50,10 @@ export const GeminiMessage: React.FC<GeminiMessageProps> = ({
terminalWidth={terminalWidth}
renderMarkdown={renderMarkdown}
/>
<Box marginBottom={1}>
<Box
marginTop={isAlternateBuffer ? 0 : 1}
marginBottom={isAlternateBuffer ? 1 : 0}
>
<ShowMoreLines
constrainHeight={availableTerminalHeight !== undefined}
/>

View File

@@ -48,7 +48,10 @@ export const GeminiMessageContent: React.FC<GeminiMessageContentProps> = ({
terminalWidth={terminalWidth}
renderMarkdown={renderMarkdown}
/>
<Box marginBottom={1}>
<Box
marginTop={isAlternateBuffer ? 0 : 1}
marginBottom={isAlternateBuffer ? 1 : 0}
>
<ShowMoreLines
constrainHeight={availableTerminalHeight !== undefined}
/>

View File

@@ -260,9 +260,7 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
)
}
{(borderBottomOverride ?? true) && visibleToolCalls.length > 0 && (
<Box paddingX={1}>
<ShowMoreLines constrainHeight={constrainHeight} />
</Box>
<ShowMoreLines constrainHeight={constrainHeight} />
)}
</Box>
);