Conversation
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.
Motivation
Several interrelated bugs were causing terminal state to be lost or incorrectly restored after hub and worker restarts, and E2E tests were flaky due to brittle selectors and race conditions.
svcCtx.Shutdown()completed, so watchers never received the disconnect notice.titleas the discriminator for detecting missing worker-side data. Shells that never emit OSC title sequences would trigger an infinite retry loop.getByText,button:has-text) that broke when UI text or styling changed, and a streaming auto-scroll race caused flaky hover-state assertions.Modifications
signal.NotifyContextwith manual context management and a goroutine signal handler inbackend/cmd/leapmux/worker.gososvcCtx.Shutdown()runs before the bidi stream closes. Wrapped all shutdown paths insync.Onceto prevent duplicate invocations.frontend/src/components/shell/useTerminalOperations.ts.TerminalView.tsxto apply the initial screen snapshot via a reactive effect that triggers when the snapshot arrives, rather than unconditionally on mount, with a per-instance latch to prevent double-painting.useWorkspaceRestore.tsto usecols(nottitle) as the discriminator for missing worker-side data, and to distinguish DISCONNECTED status from genuinely absent data.data-testidattributes toEditorToolbar.tsx,DirectoryTree.tsx, andWorkerSectionContent.tsxto give E2E tests stable anchors.waitForAgentIdle()in thesendAndWaitForReply()E2E helper to eliminate the auto-scroll/hover race.09-worker-management,14a-workspace-archive,20-markdown-editor-input,25-chat-message-rendering, and25-tunnel-uito usedata-testidselectors.TerminalViewcovering deferred hydration and one-shot latch behavior.useWorkspaceRestorecovering the retry mechanism when worker-side payload (cols, rows, screen) arrives after status-change events.Result