Fix ANSI Escape Sequence Corruption in Clear Command #3414
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
The
/clearcommand suffered from a race condition where user input could start before the confirmation prompt was fully rendered. This caused corrupted ANSI escape sequences to appear in the terminal output.Root Cause
The
execute!macro flushes display to stderr, but user input reading (read_user_input) could start before the flush completed, causing:Solution
Implemented a bandaid synchronization fix using the existing conduit system (similar to the fix already present in
mod.rs):execute!(), send timing event to signal display completionDevelopment Workflow Compliance
✅ All required checks passed:
cargo clippy- No linting warnings forclear.rscargo +nightly fmt- Code properly formattedtypos- No typos foundTesting
cargo test- All tests passScreenshot Comparison
Left Panel (Before): Shows corrupted ANSI sequences appearing in the prompt due to race condition between display rendering and user input.
Right Panel (After): Clean, properly formatted confirmation prompt with complete styling and clear text layout.
Files Changed
crates/chat-cli/src/cli/chat/cli/clear.rs: Added bandaid synchronization logic with detailed comments explaining the temporary fixBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.