Fix terminal tool progress listener leak - #332460
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoAug 25, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Dmitriy Vasyura (dmitrivMS)
August 25, 2026 00:42
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes terminal tool progress listener accumulation by routing updates through TerminalChatService.
Changes:
- Removes per-row background-event listeners.
- Updates all matching active progress parts centrally.
- Adds service-level regression coverage.
Show a summary per file
| File | Description |
|---|---|
terminalChatService.test.ts |
Tests progress-part notification behavior. |
terminalChatService.ts |
Dispatches updates through the active-part registry. |
terminal.ts |
Extends the progress-part contract. |
chatTerminalToolProgressPart.ts |
Exposes session identity and direct update handling. |
Review details
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
August 25, 2026 03:45
Contributor
|
LGTM, thank you
|
Anthony Kim (anthonykim1)
approved these changes
Aug 25, 2026
Dmitriy Vasyura (dmitrivMS)
deleted the
dev/dmitriv/terminal-continue-listener-leak
branch
August 25, 2026 16:13
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.
Summary
onDidContinueInBackgroundemitterTerminalChatService's existing active progress-part registryLog evidence
The newest populated Insiders session (
20260823T004915) reported:The allocation stack pointed to
ChatTerminalToolProgressPart: every terminal tool row registered a listener on one service-wide emitter. A sufficiently long chat therefore crossed the listener threshold even though each row only cared about its own terminal tool session.Fix
TerminalChatService.continueInBackgroundnow walks its already-maintained active progress-part set and directly marks parts whose terminal tool session ID matches. This removes the O(number of rendered terminal rows) listeners while preserving duplicate-row updates and the service event consumed by Agent Host.Validation
npm run transpile-clientChatTerminalToolProgressPartandTerminalChatServicesuites: 23 passedgit diff --checkA fresh-session log reproduction was not practical because the original warning requires dozens of live terminal-tool rows. The regression test directly exercises 50 rendered rows.
Related issues
Related to #311225.
Related to #294050.
These are non-closing references: both reports cover broader memory-growth scenarios with additional retention paths, so this change may mitigate one contributor without establishing a complete fix.