fix(sessions): preempt paste-end Enter race with belt-and-suspenders double-Enter#240
Open
brianjones-v4n wants to merge 1 commit into
Open
Conversation
…double-Enter The Enter after bracketed-paste-end is occasionally eaten by a race with the paste-end (\e[201~) sequence on Claude Code v2.1.105+ TUIs. Today this is recovered asynchronously by verifyInjection, but the recovery fires routinely (12 events in 48h on one host) rather than rarely. This adds a preemptive second Enter ~100ms after the primary Enter in the bracketed-paste branch of rawInject. If the first Enter was eaten by the race, the second submits; if the first succeeded, the second arrives at an empty input prompt and is a no-op in the Claude Code TUI. verifyInjection stays in place as the last-resort safety net for the rare case both Enters miss. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@brianjones-v4n is attempting to deploy a commit to the sagemind Team on Vercel. A member of the Team first needs to authorize it. |
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
The Enter after bracketed-paste-end is occasionally eaten by a race with the paste-end (
\e[201~) sequence on Claude Code v2.1.105+ TUIs. Today this is recovered asynchronously byverifyInjection, but in practice the recovery fires routinely (12 events in 48h on one production host) rather than rarely — meaning the "fallback" has become the de-facto primary path.This adds a preemptive second
Enter~100ms after the primaryEnterin the bracketed-paste branch ofrawInject. The mechanism:Enterwas eaten by the race → the second submits the input.Entersucceeded → the second arrives at an empty input prompt and is a no-op in the Claude Code TUI.verifyInjectionstays in place as the last-resort safety net for the rare case both Enters miss.Test plan
tests/unit/SessionManager-injection.test.ts:send-keys Entercalls follow the paste-end sequenceverifyInjectiondoc acknowledges the new primary-path layeringnpx vitest run tests/unit/SessionManager-injection.test.ts— 8/8 passingRisk
Low. The second
Enteris sent ~100ms after the first; if it ever fires when the input box is non-empty, that would be due to a separate ordering bug already present today — andverifyInjectionwould still cover the recovery.🤖 Generated with Claude Code