fix(cli): ignore stream-json input format in TTY mode to prevent hanging#2047
Merged
tanzhenxin merged 2 commits intomainfrom Mar 6, 2026
Merged
fix(cli): ignore stream-json input format in TTY mode to prevent hanging#2047tanzhenxin merged 2 commits intomainfrom
tanzhenxin merged 2 commits intomainfrom
Conversation
- Force TEXT input format in TTY mode instead of allowing stream-json which would cause the process to hang when runNonInteractiveStreamJson is called without proper stdin data. - Always initialize app regardless of input format to ensure proper setup. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Contributor
📋 Review SummaryThis PR addresses a critical issue where the CLI would hang when running in TTY mode with stream-json input format. The fix involves forcing TEXT input format for interactive terminal sessions and simplifying the initialization flow, which prevents the hanging issue and makes startup behavior more predictable. 🔍 General Feedback
🎯 Specific FeedbackNo specific issues identified in this review. ✅ Highlights
|
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
This was referenced Mar 3, 2026
- Add missing config methods: getUsageStatisticsEnabled, getSessionId, getOutputFormat - Fix stdin TTY setting for stream-json mode to ensure correct code path execution - Fix duplicate key definition issue Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.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.
TLDR
Fix process hang when running in TTY mode with stream-json input format by forcing TEXT input format for interactive terminal sessions and simplifying initialization flow.
Dive Deeper
The CLI would hang when running in an interactive terminal (TTY) with
stream-jsoninput format configured. This happened because the code attempted to read from stdin without checking if stdin was actually available in TTY mode.The fix adds a check for
process.stdin.isTTYat the start of the input format detection. When running in TTY mode, the input format is forced toTEXTregardless of configuration. This ensures the CLI uses the appropriate input method for interactive terminal sessions.Additionally, the initialization flow was simplified by removing the conditional deferral of
initializeApp()for stream-json mode. The initialization now runs consistently for all input formats, making the startup behavior more predictable.This fix only alleviates the CLI crash caused by using
--input-format=stream-jsonin tty mode; it does not fix the CLI crash issue whenNO_COLOR=true. This issue will be tracked separately.Reviewer Test Plan
Run the CLI in an interactive terminal (TTY mode) with stream-json format configured and verify it no longer hangs:
Verify normal TEXT mode still works:
Test piping input to ensure non-TTY mode still functions correctly:
Verify initialization completes successfully in all scenarios without errors.
Testing Matrix
Linked issues / bugs
Related to #2044
Releted to #1785