gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Robust Gemini CLI terminal resizing/scrolling

Open SaptaDey opened this issue 1 year ago • 42 comments

TLDR

This issue tracks terminal resizing/scrolling issues.

Issues seen:

  • Jumpy terminal
    • https://github.com/google-gemini/gemini-cli/issues/2877
  • CLI stuck in middle of terminal
    • https://github.com/google-gemini/gemini-cli/issues/2959
  • CLI scrolls through the whole chat (multiple times) on typing each and every letter I type after "/".
    • https://github.com/google-gemini/gemini-cli/issues/2646
  • Scrolling through output on generated responses
    • #2941
  • Termux issues
    • https://github.com/google-gemini/gemini-cli/issues/4077
    • https://github.com/google-gemini/gemini-cli/issues/4075
    • https://github.com/google-gemini/gemini-cli/issues/3959
  • Resizing Issues
    • https://github.com/google-gemini/gemini-cli/issues/3750
    • https://github.com/google-gemini/gemini-cli/issues/3920
    • https://github.com/google-gemini/gemini-cli/issues/4335
    • https://github.com/google-gemini/gemini-cli/issues/2859

What happened?

https://github.com/user-attachments/assets/651022a8-3109-4760-868e-18e5470242f3

What did you expect to happen?

Look at the video, it's just keep going like this for hours

Client information

$ gemini /about
# paste output here

Login information

Google Account

Anything else we need to know?

Look at the video, it's just keep going like this for hours

SaptaDey avatar Jun 30 '25 00:06 SaptaDey

Me too

wildcatDownstairs avatar Jun 30 '25 07:06 wildcatDownstairs

Me too

agrawalankush avatar Jul 01 '25 12:07 agrawalankush

Can people impacted please note what their operating system and terminal is. Some of the issues causing infinite loops are due to specific terminals (for example, there is a known issue for a terminal with an on screen keyboard).

The particular issue in the video appears to be due characters in some lines that are confusing Ink. We should be able to fix that particular case by filtering out those characters before adding them to UI rendered with ink. Notice how the box border in the wrong locations.

Image

jacob314 avatar Jul 03 '25 19:07 jacob314

Can people impacted please note what their operating system and terminal is. Some of the issues causing infinite loops are due to specific terminals (for example, there is a known issue for a terminal with an on screen keyboard).

The particular issue in the video appears to be due characters in some lines that are confusing Ink. We should be able to fix that particular case by filtering out those characters before adding them to UI rendered with ink. Notice how the box border in the wrong locations.

Image

OS: Windows Edition Windows 11 Pro for Workstations Version 25H2 OS build 26200.5670 Windows Terminal: Microsoft Corporation 1.22.11141.0

I have a desktop system standard German QWERTZ physical-keyboard , there is no on-screen keyboard or touch functions.

SaptaDey avatar Jul 04 '25 09:07 SaptaDey

Part of issue from @jacob314

This is the classic ink flicker issue you are hitting. The issue occurs when we try to make the active ui in the terminal taller than the visible area in the terminal. We have a bunch of logic to avoid that but what we are missing is support for virtual keyboards that reduce the true height of the terminal. Once we figure out how to get the correct height given the space taken up by the on screen keyboard the flicker/scroll will go away.

jackwotherspoon avatar Jul 04 '25 16:07 jackwotherspoon

Same trouble here using VSCode Insiders edition. No no-standard peripherals.

Version: 1.101.2 Commit: 2901c5ac6db8a986a5666c3af51ff804d05af0d4 Date: 2025-06-24T20:27:15.391Z Electron: 35.5.1 ElectronBuildId: 11727614 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Linux x64 6.11.0-29-generic

coder3337 avatar Jul 07 '25 12:07 coder3337

Getting same issue:

https://github.com/user-attachments/assets/cd3a34ec-1ff7-4d84-90a8-6997c168b59c

Gemini-cli version: 0.1.9 System: Ubuntu 24.10 Terminal: GNOME Terminal 3.52.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD

Lost all my work context, any solution ?

Aman-Singh-Kushwaha avatar Jul 09 '25 07:07 Aman-Singh-Kushwaha

Ditto, Termux. See also another User: https://github.com/google-gemini/gemini-cli/issues/3959 . I suspect the dynamic keyboard plays a role, but also it happens now and then when I ssh to Termux (sic, recommended) from Ubuntu.

Other than that using Gemini in Termux, with sudo, is great: so many logcat errors or weird "onnxruntime-level" installation problems, see https://github.com/rhasspy/piper/issues/180#issuecomment-3035987953 can be solved now!

Manamama avatar Jul 12 '25 11:07 Manamama

I wrote a full "prettifier" script: https://github.com/google-gemini/gemini-cli/discussions/3965, https://github.com/Manamama/Puzzles_for_AIs/tree/main/docs/pmbok_instructions/code/Gemini%20CLI%20logs%20prettifier

, which would prettify and render all as below, avoiding also scrolling issues. One just needs to serve the standard out content methinks. Speaking of which, two weeks ago I dabbled in just that too: https://github.com/google-gemini/gemini-cli/discussions/2841, but of course this version still suffers scrolling delays.

Ref: Image

Manamama avatar Jul 12 '25 12:07 Manamama

that logs prettifier is great. I'd be open to bundling it with Gemini CLI if it is translated to typescript so it can be run in node without requiring a dependency on python

jacob314 avatar Jul 12 '25 18:07 jacob314

Be my guest. Mention me by name: I have never done a PR yet here . Glad that my ideas helped!

Aha, re: "if it is translated to typescript " - me no coder. Seriously. I dabble in "humanities" and such mostly, see e.g. https://github.com/google-gemini/gemini-cli/discussions/2386

Manamama avatar Jul 12 '25 20:07 Manamama

One can use my tip for now: https://github.com/google-gemini/gemini-cli/issues/3959#issuecomment-3065102893

I self revisited it as I have just had this issue on Termux once again today. The (self) tip worked, but it is a crutch, as of course it rms all. (One needs to think well what to memorize into .md files, but actually it is a good 🤯 exercise for the both parties: 💃🏽 & 🤖.)

Manamama avatar Jul 13 '25 09:07 Manamama

I believe #4055 to be a duplicate of this one. The user there encounters the issue on Android/Termux with the Termux integrated terminal. I can also report that I use Gemini CLI in the same environment and experience the same bug.

As I commented on that issue: The issue depicted in the videos happens anytime Gemini CLI is used in a window that is too small and tries to emit too large of an output during a single tool call. It causes the entire history of the terminal to scroll rapidly from top to bottom endlessly, scrolling once per every attempt at updating the on-screen contents of the terminal. This goes away once whatever's causing the scrolling is pushed into the agent's history as it moves on to the next step or tool call.

segin avatar Jul 13 '25 18:07 segin

Oh yes, Termux has the narrow terminal and this video perfectly shows how it looks on most of our ends.

Is it indeed a question of non-80 chars terminal then? (Indeed when I ssh to Termux from PC, it is gone.) Maybe we need to ... just rotate Termux and Droid 90 degs left now and then? ;) Never tested if it would work, but of course the soft keyboard takes half a screen if rotated to landscape.

If it is the software keyboard, then one could connect an USB keybard or the null keyboard or a BT one to avoid it, but then... one could just ssh to Termux instead with the full terminal, keyboard etc. instead.

Further tip: Ctrl + L → Clear screen (same as clear) works on Termux too.

Some formal tests are needed, unless this root cause be obvious.

ver. 1.1 format fixes mostly

Manamama avatar Jul 13 '25 20:07 Manamama

@Manamama this happens outside of Termux and seems to be tied to the number of displayable rows more than the number of columns. Columns contribute due to the way text and code in tool call previews are wrapped, but strictly speaking, the issue appears to be related to how many rows are available in the terminal.

Truth be told, I've also had it happen on a terminal on a PC that was over 70 rows tall after some period of time - the chat just got really long and it started to eat itself.

segin avatar Jul 13 '25 22:07 segin

Update: rotating and Ctrl + L → Clear help for a turn or two only, tested now IRL case of the same series of symptoms... Weird that Ctrl + L does not work mid-term, as it seemed a strong candidate to wipe the output but not memory...

Manamama avatar Jul 14 '25 12:07 Manamama

Look here, seems important, an easy way out: https://github.com/sugyan/claude-code-webui/issues/188#issue-3228633164 and https://github.com/google-gemini/gemini-cli/discussions/2841#discussioncomment-13751702

Very interim "adaptation plan" that Gemini itself (Flash!) came up with and is working on now attached, for what it is worth.

GEMINI_ADAPTATION_PLAN.md

Manamama avatar Jul 14 '25 15:07 Manamama

The same thing happens to me in Windows PowerShell

MartinPSDev avatar Jul 16 '25 15:07 MartinPSDev

@jacob314 as part of triage cli identifed a few more issues i've added to the list here:

  • https://github.com/google-gemini/gemini-cli/issues/3750
  • https://github.com/google-gemini/gemini-cli/issues/3920
  • https://github.com/google-gemini/gemini-cli/issues/4335
  • https://github.com/google-gemini/gemini-cli/issues/2859

mattKorwel avatar Jul 16 '25 23:07 mattKorwel

This is in the issue I tried to dupe alin on, but I see this on MacOS with both Terminal.app ant iTerm.

robertlipe avatar Jul 18 '25 00:07 robertlipe