Repository navigation
vscode: overwrite terminal reconnect notices in place, wipe on successful reconnect - #1002
Merged
Merged
Conversation
amrmelsayed
added a commit
that referenced
this pull request
Jun 6, 2026
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.
PIR Review: Overwrite reconnect notices in place, wipe on successful reconnect
Fixes #1001
Summary
The VSCode terminal adapter wrote a fresh
\r\n-terminated "Connection lost — retrying…" line on every reconnect attempt, so notices stacked in scrollback and were never cleared when the connection came back — leaving orphaned status lines above the resumed output. This change adopts the overwrite-in-place pattern the original#936PR intended: each retry notice now leads with\r\x1b[2K(carriage return + erase-line) and drops its trailing newline, so only one notice line is ever visible and the attempt counter ticks1/6 → 6/6in place. AhadReconnectNoticeflag drives aclearReconnectNotice()helper called from thews.on('open')success path, which wipes that single line before Tower's replayed buffer resumes. The give-up (#939) state overwrites the last retry notice but is itself never wiped, so it remains visible as the terminal failure state.Files Changed
packages/vscode/src/terminal-adapter.ts(+40 / -3)packages/vscode/src/__tests__/terminal-adapter.test.ts(+78 / -0)Commits
c0d2f6cf[PIR vscode: terminal-adapter reconnect notices accumulate as orphaned scrollback lines; not cleared on successful reconnect #1001] Plan draftfc6c9bc7[PIR vscode: terminal-adapter reconnect notices accumulate as orphaned scrollback lines; not cleared on successful reconnect #1001] Overwrite reconnect notices in place and wipe on successful reconnecte8c1c846[PIR vscode: terminal-adapter reconnect notices accumulate as orphaned scrollback lines; not cleared on successful reconnect #1001] Thread: implement phase completeTest Results
pnpm check-types: ✓ passpnpm lint: ✓ passnode esbuild.js(bundle): ✓ passpnpm test:unit(vitest run): ✓ pass (336 tests, 5 new for PIR vscode: terminal-adapter reconnect notices accumulate as orphaned scrollback lines; not cleared on successful reconnect #1001)dev-approvalgate — confirmed working as expected (single notice line ticking in place, cleared on reconnect, give-up state preserved).Architecture Updates
No arch changes — this is a localized rendering fix within
CodevPseudoterminal's existing reconnect loop. It introduces no new module boundaries, dependencies, or patterns; it completes the in-place-overwrite mechanic the#936reconnect overhaul (already documented) had only partially implemented.Lessons Learned Updates
No new durable lesson worth promoting to
codev/resources/lessons-learned.md. The one notable point is local-and-already-recorded in arch convention: transient terminal status notices should overwrite in place (\r\x1b[2K) and pair every "lost"-side write with a symmetric "recovered"-side wipe, rather than appending\r\n-terminated lines that orphan in scrollback. This is captured in the code comments at the change site and in the issue thread; it does not generalize beyond terminal-notice rendering.Things to Look At During PR Review
\r\x1b[2Kon the first retry notice erases whatever is on the terminal's current line, which can be a partial last line of real output if the drop happened mid-stream. This is intentional and safe because Tower replays its full scrollback buffer on every reconnect (thepause/resumepath inhandleControlMessage), so the content is re-rendered after the success-wipe. Verified manually at the dev-approval gate.giveUp()conditional prefix: the erase prefix is applied only whenhadReconnectNoticeis true (exhausted-budget path, where a retry notice is on the line). The immediate-4xx path writes no prefix so it doesn't disturb an unrelated current line — covered by theimmediate 4xx give-up has no erase prefixtest.How to Test Locally
afx dev pir-1001afx tower stop && afx tower start) within the first 2-3 backoff intervals → a single notice line ticks the attempt counter in place; no orphaned[Codev: Connection lost…]line remains after reconnect.yes | head -200, bounce Tower mid-stream → no garbled output after reconnect (replay restores it).Click here to reconnectgive-up notice remains visible and is not wiped.