fix(ui): removed double padding on rendered content (#21029)

This commit is contained in:
Dev Randalpura
2026-03-04 17:00:34 -08:00
committed by GitHub
parent 3481032980
commit 205d69eb07
5 changed files with 176 additions and 18 deletions
@@ -8,7 +8,7 @@ import { renderWithProviders } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js';
import { MainContent } from './MainContent.js';
import { getToolGroupBorderAppearance } from '../utils/borderStyles.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { Box, Text } from 'ink';
import { act, useState, type JSX } from 'react';
import { useAlternateBuffer } from '../hooks/useAlternateBuffer.js';
@@ -56,10 +56,6 @@ vi.mock('./AppHeader.js', () => ({
),
}));
vi.mock('./ShowMoreLines.js', () => ({
ShowMoreLines: () => <Text>ShowMoreLines</Text>,
}));
vi.mock('./shared/ScrollableList.js', () => ({
ScrollableList: ({
data,
@@ -339,6 +335,10 @@ describe('MainContent', () => {
vi.mocked(useAlternateBuffer).mockReturnValue(false);
});
afterEach(() => {
vi.restoreAllMocks();
});
it('renders in normal buffer mode', async () => {
const { lastFrame, unmount } = renderWithProviders(<MainContent />, {
uiState: defaultMockUiState as Partial<UIState>,
@@ -457,6 +457,60 @@ describe('MainContent', () => {
unmount();
});
it('renders multiple history items with single line padding between them', async () => {
vi.mocked(useAlternateBuffer).mockReturnValue(true);
const uiState = {
...defaultMockUiState,
history: [
{ id: 1, type: 'gemini', text: 'Gemini message 1\n'.repeat(10) },
{ id: 2, type: 'gemini', text: 'Gemini message 2\n'.repeat(10) },
],
constrainHeight: true,
staticAreaMaxItemHeight: 5,
};
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
<MainContent />,
{
uiState: uiState as Partial<UIState>,
useAlternateBuffer: true,
},
);
await waitUntilReady();
const output = lastFrame();
expect(output).toMatchSnapshot();
unmount();
});
it('renders mixed history items (user + gemini) with single line padding between them', async () => {
vi.mocked(useAlternateBuffer).mockReturnValue(true);
const uiState = {
...defaultMockUiState,
history: [
{ id: 1, type: 'user', text: 'User message' },
{ id: 2, type: 'gemini', text: 'Gemini response\n'.repeat(10) },
],
constrainHeight: true,
staticAreaMaxItemHeight: 5,
};
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
<MainContent />,
{
uiState: uiState as unknown as Partial<UIState>,
useAlternateBuffer: true,
},
);
await waitUntilReady();
const output = lastFrame();
expect(output).toMatchSnapshot();
unmount();
});
it('renders a split tool group without a gap between static and pending areas', async () => {
const toolCalls = [
{