perf(terminal): fix write-buffer leak on destroy + lifecycle test harness - #55
Merged
Merged
Conversation
…t handler lifecycles destroySession left the session's terminalWriteBuffers entry (and its scheduled rAF/timeout flush) in place. Mostly self-healing today, but it holds up to 256 KB of chunks per closed session and becomes a real use-after-dispose hazard once terminal disposal happens routinely (upcoming LRU cap on live xterm instances). Also documents the audited-safe lifecycles (OSC-52 parser handler, DnD listeners, flush guard) so they aren't re-audited, and adds lifecycle regression tests (jsdom harness for terminal-manager.js).
This was referenced Jun 11, 2026
This was referenced Jun 11, 2026
abasiri
pushed a commit
that referenced
this pull request
Aug 1, 2026
…55) Routes terminal copy through the main-process clipboard (the renderer's navigator.clipboard is unreliable on Wayland/Ozone) and wires up OSC 52 so programs in the terminal — including Claude Code — can set the system clipboard. OSC 52 read-back queries are deliberately refused rather than answered, so a session cannot exfiltrate the user's clipboard; decodeOsc52Payload() documents that and test/clipboard-osc52.test.js pins it. Co-authored-by: ymajoros <yannick@valuya.be>
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.
PR 1/4 — renderer memory plan (Stage 1: lifecycle hygiene)
First of the 4-PR sequence from the renderer memory-optimization plan (
.work-files/switchboard/mem-opt-go-sidecar/option1-plan.md, baseline: 789 MB RSS, 462 MB renderer).Changes
destroySessionnow clears the session'sterminalWriteBuffersentry and cancels its scheduled rAF/timeout flush. Today the stale entry mostly self-heals, but it pins up to 256 KB of chunks per closed session and becomes a use-after-dispose hazard once disposal becomes routine (PR 3 introduces an LRU cap that disposes terminals).terminal.dispose()), DnD/search-bar listeners (die withentry.element), and the intentional guard influshTerminalBuffer.test/terminal-manager-lifecycle.test.js— jsdom +vm.runInContextharness for terminal-manager.js (the file had no direct coverage). Asserts full teardown: maps, write buffer, DOM, singledispose(). Shared lexical-scope trick documented for reading top-levelconsts.Verification
task checkgreen — 198/198 tests, 0 lint errors. No live Electron needed (and deliberately not used: single-instance lock).No user-visible behavior change. PR 2 (scrollback differentiation) stacks on this branch for the shared test file.