fix(tui): dispose stale session UI renderers#4693
Merged
Merged
Conversation
Stopped new-session and session-switch UI paths from detaching active loader/render components without running their disposal hooks. Added container and loader coverage for disposing children before destructive transcript/status replacement. Fixes #4686
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Collaborator
Author
|
No code change requested by this notice. PR #4693 remains ready for maintainer review; Codex review quota needs repo-admin action outside this branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro
Starting a replacement chat after a prior session can leave transient TUI components detached but alive. I reproduced the render loop with
bun .wt/repro-4686.js: after a statusLoaderwas removed withContainer.clear(), it still calledrequestComponentRender()(before=3, after=5) and exited with code 1. I also checked the reporter's resize follow-up withbun test packages/tui/test/resize-viewport-defer.test.ts packages/tui/test/issue-2088-repro.test.ts packages/tui/test/issue-2095-repro.test.ts, which kept the existing resize renderer regressions green.Cause
Container.clear()inpackages/tui/src/tui.tsonly detaches children; it does not call childdispose()hooks. New-session and session-switch UI paths inpackages/coding-agent/src/modes/controllers/*,interactive-mode.ts, andui-helpers.tsusedclear()for destructive transcript/status replacement, so activeLoader/transcript components could keep timers alive and continue requesting TUI renders after the new chat or resize redraw started.Fix
Container.disposeChildren()inpackages/tui/src/tui.tsfor the common destructive-clear contract: dispose every child, then detach it.clearTransientSessionUi(),resetTranscript(),renderInitialMessages(), ordisposeChildren()instead of non-disposing clears.renderInitialMessages()can dispose the old transcript blocks itself.disposeChildren()and for detached loader repaint timers stopping when a container is destructively cleared.Verification
bun test packages/tui/test/container-dispose.test.ts packages/tui/test/loader.test.ts→ 11 pass, 0 fail.bun --cwd=packages/tui run check→ passed.bun --cwd=packages/coding-agent run check:types→ passed.bun --cwd=packages/coding-agent run check→ passed.bun test packages/tui/test/resize-viewport-defer.test.ts packages/tui/test/issue-2088-repro.test.ts packages/tui/test/issue-2095-repro.test.ts→ 26 pass, 0 fail.bun run fix→ passed before commit.Fixes #4686