Skip to content

Fixed choice-dialog flicker from resize-triggered reflow - #175

Merged
oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/choice-menu-resize-flicker
Sep 30, 2026
Merged

oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/choice-menu-resize-flicker

Conversation

@oleg68

@oleg68 oleg68 commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reported symptom (GrandOrgue project): a choice dialog (e.g. Bash-command permission prompt) flickers — after it appears, the remaining terminal area resizes, a "different" dialog is detected and shown, it resizes again, and so on in a loop.
  • Root cause: ChoiceMenuPanel resizes the terminal to fit itself. That resize makes Claude Code's Ink renderer re-wrap the same dialog at the new column width (confirmed against the existing git-commit-bash-dialog / git-commit-bash-dialog-narrow fixtures, where only one option's wrapped text differs). The controller applied any detected difference immediately, so the reflowed variant replaced the menu just shown, triggering another resize → another reflow → loop. (Scrollback/history-buffer access was not the issue — detectChoiceMenu only ever needs the live viewport, which was already read under JediTerm's buffer lock.)
  • Fix: ClaudeSessionController now requires a replacement candidate that differs from the currently active menu to be seen on two consecutive polls before it replaces the active menu. A first-time show (no menu currently active) is still applied immediately — only replacing an already-shown menu is debounced. Since withholding the replacement prevents the resize that caused the divergence, the screen naturally reverts to the original menu on the next poll for one-off reflow artifacts, while genuinely new dialogs still get applied once confirmed.

Test plan

  • Added a regression test reproducing the flicker using the real git-commit-bash-dialog / -narrow dialog text (confirmed failing before the fix, passing after)
  • Added a test confirming a genuinely different menu is still applied after two consecutive confirmations (debounce doesn't block legitimate replacements)
  • mvn test — full suite green
  • mvn package — full build succeeds

🤖 Generated with Claude Code

…Claude's response text re-wrapped to a slightly different width after the dialog first appeared

Showing a choice menu resizes the terminal to fit ChoiceMenuPanel, which
makes Claude's Ink renderer re-wrap the dialog at the new column width.
The reflowed variant was previously applied to the model immediately,
triggering another resize, another reflow, and so on. detectChoiceMenu
now requires a replacement candidate to be confirmed on two consecutive
polls before it replaces the currently active menu, so a one-off reflow
never causes the destabilizing resize that produced it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@oleg68
oleg68 merged commit 2cf6e8f into nbplugins:main Sep 30, 2026
3 checks passed
@oleg68
oleg68 deleted the bugfix/choice-menu-resize-flicker branch September 30, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant