fix(projects): verify command echo before Enter; retry when shell startup swallows keystrokes#48
Open
milehimikey wants to merge 1 commit into
Open
Conversation
A freshly spawned pane's shell startup (compinit, plugins, prompt frameworks) paints output before the line editor accepts input. waitForPaneReady fired on first paint, so the first typed character could be swallowed (claude -> laude), and runCommand pressed Enter even when the echo check timed out, submitting the mangled line. - waitForPaneReady now waits for quiescence: two consecutive identical non-blank reads 200ms apart (call-site timeout 5s -> 10s). - waitForPaneText returns whether the probe appeared. - runCommand only submits after the command visibly echoes; on timeout it clears the line (ctrl+u) and retypes, up to 3 attempts, before degrading to the old blind-Enter behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
When a project's startup command is typed into a freshly created pane, the shell's startup can swallow keystrokes — most often just the first character, so
clauderuns aslaude("command not found"). Two weaknesses inrunCommandcombine to cause this:waitForPaneReadyreturns on the first non-blank read. Shells with slower startup (compinit, plugin managers, prompt frameworks) paint output in bursts before the line editor accepts input, so typing starts too early and characters land in the gap.waitForPaneText) has no teeth: when it times out, Enter is pressed anyway, submitting the mangled line.Fix
waitForPaneReadynow waits for quiescence — two consecutive identical non-blank reads 200ms apart — instead of first paint (call-site timeout 5s → 10s).waitForPaneTextreports whether the probe appeared.runCommandonly presses Enter once the command visibly echoes back intact. On a failed echo check it clears the line (ctrl+u — backward-kill-line in both zsh emacs and vi-insert keymaps) and retypes, up to 3 attempts, before degrading to the previous blind-Enter behavior so a shell that never echoes (or a full-screen program) still works.Happy path cost is one extra 200ms quiescence read; the retry path only engages when the echo check fails.
Testing
go test -race ./...passes.laude; with this change the command lands intact across repeated launches, including with an artificialsleep 2at the top of.zshrc.🤖 Generated with Claude Code