fix: wait for CLI readiness before SendPrompt to prevent prompt loss#267
Open
DragonFSKY wants to merge 1 commit intosmtg-ai:mainfrom
Open
fix: wait for CLI readiness before SendPrompt to prevent prompt loss#267DragonFSKY wants to merge 1 commit intosmtg-ai:mainfrom
DragonFSKY wants to merge 1 commit intosmtg-ai:mainfrom
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
When creating an instance with a prompt via Shift+N, SendPrompt() was called synchronously right after the instance started, before the CLI (Claude, Aider, Codex, etc.) had finished initializing. This caused the prompt text to be lost. Changes: - Add ProgramCodex constant for Codex CLI detection - Add IsCliReady() to detect CLI input-ready state by checking program-specific prompt indicators (❯ for Claude, > for others) - Add WaitForCliReady() with polling (200ms interval, 30s timeout) and content stability fallback for unknown CLIs - Add Instance.WaitForCliReady() wrapper method - Change instanceStartedMsg handler to send prompt asynchronously via tea.Cmd, preventing UI blocking during the wait Fixes smtg-ai#266
931456b to
4627594
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.
Summary
SendPrompt()sends text before CLI (Claude, Aider, Codex, etc.) finishes initialization, causing the prompt to be lost when using Shift+N to create an instance with a promptIsCliReady()/WaitForCliReady()methods to detect CLI input-ready state by checking program-specific prompt patterns (❯ for Claude, > for Aider/Gemini/Codex) with content-stability fallback for unknown CLIsinstanceStartedMsghandler to send the prompt asynchronously viatea.Cmd, so the UI remains responsive during the waitTest plan
Fixes #266