Skip to content

fix(tui): share dialog width instead of one resize listener per row - #56234

Merged
jlongster merged 1 commit into
anomalyco:devfrom
tobwen:resize-listener-leak
Oct 17, 2026
Merged

jlongster merged 1 commit into
anomalyco:devfrom
tobwen:resize-listener-leak

Conversation

@tobwen

@tobwen tobwen commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Follow-up to #44055 (closed as fixed in v2.0.21, same symptom, different site).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

DialogSelectDetails called useTerminalDimensions() per option row, registering one renderer resize listener per mounted row. Palettes with 15+ entries trip Nodes MaxListeners warning routinely:

Possible EventEmitter memory leak detected. 16 resize listeners added.

Introduced by #55517 (row components split). The width is now computed once at the top of DialogSelect and passed down as a prop; rows only read it.

How did you verify your code works?

New test dialog rows do not add renderer resize listeners: 30 options mounted, renderer listener count stays flat. Without the fix: 5 -> 32 (fails); with it: stays at 5. Full dialog-select suite: 34 pass. tsgo -b: clean. oxlint: clean. Also verified in a local build: the warning no longer appears when opening palettes with many entries.

Screenshots / recordings

n/a (no visual change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. The per-row useTerminalDimensions() call is removed, and the width is now computed once in DialogSelect with the same dialog/dimensions values, so details still re-truncate on resize. I checked it by running the new test against the base, where the resize listener count goes from 5 to 32 and the test fails. With this PR the full dialog-select suite passes (34/34) and tsgo -b is clean in packages/tui. DialogSelect is the only place that renders DialogSelectDetails, so nothing else is missing the new width prop.

Public API: unchanged; only internal component props are touched.

No concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants