Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/cli/src/ui/components/MainContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ describe('MainContent', () => {

expect(output).toMatchSnapshot();
});
it('does not render empty history items', async () => {
const uiStateWithEmptyItems = {
...defaultMockUiState,
history: [
...defaultMockUiState.history,
{ id: 3, type: 'gemini_content', text: '' },
{ id: 4, type: 'gemini_content', text: 'Non-empty content' },
],
};

const { lastFrame } = renderWithProviders(<MainContent />, {
uiState: uiStateWithEmptyItems as Partial<UIState>,
});
await waitFor(() => expect(lastFrame()).toContain('Non-empty content'));
const output = lastFrame();

expect(output).toContain('Non-empty content');
expect(output).toMatchSnapshot();
});

describe('MainContent Tool Output Height Logic', () => {
const testCases = [
Expand Down
28 changes: 16 additions & 12 deletions packages/cli/src/ui/components/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@ export const MainContent = () => {

const historyItems = useMemo(
() =>
uiState.history.map((h) => (
<MemoizedHistoryItemDisplay
terminalWidth={mainAreaWidth}
availableTerminalHeight={staticAreaMaxItemHeight}
availableTerminalHeightGemini={MAX_GEMINI_MESSAGE_LINES}
key={h.id}
item={h}
isPending={false}
commands={uiState.slashCommands}
/>
)),
uiState.history
.filter((h) => !(h.type === 'gemini_content' && !h.text))
Comment thread
devr0306 marked this conversation as resolved.
Resolved
.map((h) => (
<MemoizedHistoryItemDisplay
terminalWidth={mainAreaWidth}
availableTerminalHeight={staticAreaMaxItemHeight}
availableTerminalHeightGemini={MAX_GEMINI_MESSAGE_LINES}
key={h.id}
item={h}
isPending={false}
commands={uiState.slashCommands}
/>
)),
[
uiState.history,
mainAreaWidth,
Expand Down Expand Up @@ -116,7 +118,9 @@ export const MainContent = () => {
const virtualizedData = useMemo(
() => [
{ type: 'header' as const },
...uiState.history.map((item) => ({ type: 'history' as const, item })),
...uiState.history
.filter((h) => !(h.type === 'gemini_content' && !h.text))
.map((item) => ({ type: 'history' as const, item })),
{ type: 'pending' as const },
],
[uiState.history],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,17 @@ AppHeader
ShowMoreLines
"
`;

exports[`MainContent > does not render empty history items 1`] = `
"AppHeader
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
> Hello
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
✦ Hi there

ShowMoreLines
Non-empty content

ShowMoreLines
"
`;
2 changes: 1 addition & 1 deletion packages/cli/src/ui/utils/MarkdownDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const RenderCodeBlockInternal: React.FC<RenderCodeBlockProps> = ({
const RESERVED_LINES = 2; // Lines reserved for the message itself and potential padding

// When not in alternate buffer mode we need to be careful that we don't
// trigger flicker when the pending code is to long to fit in the terminal
// trigger flicker when the pending code is too long to fit in the terminal
if (
!isAlternateBuffer &&
isPending &&
Expand Down