fix(tui): harden disposal recovery — bounded retry, session re-sync, fresh context, conditional event stream#16544
Open
sjawhar wants to merge 2 commits intoanomalyco:devfrom
Open
fix(tui): harden disposal recovery — bounded retry, session re-sync, fresh context, conditional event stream#16544sjawhar wants to merge 2 commits intoanomalyco:devfrom
sjawhar wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
f5450b0 to
1fc5100
Compare
…fresh context, conditional event stream
1fc5100 to
bdaeaef
Compare
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.
Issue for this PR
Closes #16545
Type of change
What does this PR do?
When the backend Instance is disposed while the TUI is active, several recovery bugs can cause a blank screen or infinite retry loops. This PR fixes all six identified issues:
sync.tsx — Disposal recovery hardening:
fullSyncedSessions, then re-syncs them after successful re-bootstrap so the user's current view refreshes automatically instead of showing stale datanew Promise(r => setTimeout(r, 2000))withsleep()fromnode:timers/promisesto match the rest of the codebaseworker.ts — Event stream lifecycle:
Instance.provide()inside the while loop so each reconnect iteration gets fresh context — previously a singleInstance.provide()wrapped the entire loop, so after disposal the reconnect used a stale contextstartEventStream(process.cwd())at module load and adds aneventsRPC method so the thread controls when and where to start the streameventStream.directorysoreload()can abort the stream and conditionally restart it, rather than relying on timing-sensitive SSE reconnectthread.ts — Transport-aware event stream startup:
worker.events({ directory })only when not in external transport mode (!externalguard) — previously the event stream started regardless of transport.catch()handler on the checkUpgrade call (was silently swallowing errors with empty.catch(() => {}))How did you verify your code works?
bun run typecheckpasses frompackages/opencodeinstance.tsorserver.ts(those belong to the separate idle timeout PR)Checklist