Skip to content

Comments

fix(ui): preventing empty history items from being added#19014

Merged
jacob314 merged 11 commits intomainfrom
remove-extra-space
Feb 18, 2026
Merged

fix(ui): preventing empty history items from being added#19014
jacob314 merged 11 commits intomainfrom
remove-extra-space

Conversation

@devr0306
Copy link
Contributor

@devr0306 devr0306 commented Feb 13, 2026

Summary

This pull request addresses the issue of empty history items being added to the history items list.

Details

In handleContentEvent in useGeminiStream.ts, empty history items were being added due to findLastSafeSplitPoint returning 0 for code content within code blocks. So, for larger code blocks, addItem was called multiple times with an empty string before the actual content could get added. This led to extra space being rendered above the code blocks.

Related Issues

Fixes #18452

How to Validate

  1. Enter alternate buffer mode and ask "Without calling any tool, show me an example java class"
  2. Exit alternate buffer mode and ask the same thing

Both cases should display content without extra spaces

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@devr0306 devr0306 requested a review from a team as a code owner February 13, 2026 17:53
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @devr0306, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a user interface rendering anomaly where empty history items were inadvertently displayed, leading to unnecessary vertical spacing. By implementing a filtering mechanism, the application now correctly omits these empty entries, resulting in a cleaner and more compact display of historical content.

Highlights

  • UI Rendering Fix: Empty history items, specifically 'gemini_content' with no text, are now filtered out to prevent them from being rendered.
  • Space Reduction: This change resolves an issue where empty history items caused extra vertical space above rendered content in the UI.
Changelog
  • packages/cli/src/ui/components/MainContent.test.tsx
    • Added a new test case to verify that empty history items are not rendered.
  • packages/cli/src/ui/components/MainContent.tsx
    • Implemented a filter within the 'historyItems' useMemo hook to exclude 'gemini_content' items that have no text.
    • Applied the same filtering logic to the 'virtualizedData' useMemo hook to ensure empty history items are not included in the virtualized list.
  • packages/cli/src/ui/components/snapshots/MainContent.test.tsx.snap
    • Updated the snapshot to reflect the new test case for not rendering empty history items.
  • packages/cli/src/ui/utils/MarkdownDisplay.tsx
    • Corrected a typo from "to long" to "too long" in a comment.
Activity
  • The author has added a new test case to validate the fix for empty history items.
  • The author has validated the changes on MacOS using 'npm run'.
  • Instructions for validating the fix have been provided, including steps to reproduce the original issue and confirm its resolution in both alternate buffer mode and regular mode.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses the issue of empty history items being rendered by filtering them out before they are passed to the UI components. The addition of a new test case ensures this behavior is covered and prevents regressions. My main feedback is to refactor the duplicated filtering logic into a separate useMemo hook to improve code maintainability and reduce the chance of future bugs.

@devr0306
Copy link
Contributor Author

devr0306 commented Feb 13, 2026

From /review-frontend:

LGTM! The fix effectively filters out empty history items, resolving the extra spacing issue. The added test case correctly verifies this behavior using the established testing patterns. Thanks for the cleanup in MarkdownDisplay.tsx as well.

@github-actions
Copy link

github-actions bot commented Feb 13, 2026

Size Change: +61 B (0%)

Total Size: 24.5 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.5 MB +61 B (0%)
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 13, 2026
@devr0306 devr0306 changed the title Filtered out empty history items from being rendered fix(ui): filtered out empty history items from being rendered Feb 13, 2026
@devr0306 devr0306 changed the title fix(ui): filtered out empty history items from being rendered fix(ui): filter out empty history items from being rendered Feb 13, 2026
@devr0306 devr0306 changed the title fix(ui): filter out empty history items from being rendered fix(ui): preventing empty history items from being added Feb 17, 2026
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devr0306 devr0306 added this pull request to the merge queue Feb 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2026
@devr0306 devr0306 added this pull request to the merge queue Feb 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2026
@devr0306 devr0306 enabled auto-merge February 18, 2026 16:58
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jacob314 jacob314 disabled auto-merge February 18, 2026 20:52
@jacob314 jacob314 merged commit 3099df1 into main Feb 18, 2026
26 of 27 checks passed
@jacob314 jacob314 deleted the remove-extra-space branch February 18, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra space above rendered code

2 participants