Skip to content

Fix terminal chat auto-expand for commands without visible output#290482

Merged
meganrogge merged 1 commit intomainfrom
merogge/sleep
Jan 26, 2026
Merged

Fix terminal chat auto-expand for commands without visible output#290482
meganrogge merged 1 commit intomainfrom
merogge/sleep

Conversation

@meganrogge
Copy link
Copy Markdown
Collaborator

@meganrogge meganrogge commented Jan 26, 2026

fix #290480

Shell integration sequences (PromptStart, CommandStart, CommandExecuted, CommandFinished) fire multiple data events even for commands with no visible output. The old threshold of > 1 was too low, causing hasRealOutput to return true for sleep 2 since it receives ~4 SI sequence events. Raising the threshold to > 4 means only commands with actual ongoing output (like progress bars) will trigger the fallback, while silent long-running commands like sleep won't falsely auto-expand.

cc @Tyriar

Copilot AI review requested due to automatic review settings January 26, 2026 18:07
@meganrogge meganrogge self-assigned this Jan 26, 2026
@meganrogge meganrogge added this to the January 2026 milestone Jan 26, 2026
@meganrogge meganrogge enabled auto-merge (squash) January 26, 2026 18:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where terminal chat incorrectly auto-expands output for commands with no visible output (like sleep 3). The fix adjusts the threshold for detecting "real" terminal output from more than 1 data event to more than 4 data events.

Changes:

  • Increased the data event threshold from > 1 to > 4 to distinguish between shell integration sequences (which fire ~4 events) and actual command output
  • Updated comments to clarify that shell integration sequences fire multiple times per command (PromptStart, CommandStart, CommandExecuted, CommandFinished, etc.)

return receivedDataCount > 1;
// Shell integration sequences fire multiple times per command (PromptStart, CommandStart,
// CommandExecuted, CommandFinished, etc.), so we need a higher threshold
return receivedDataCount > 4;
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the magic number 4 into a named constant with documentation. The threshold value is empirically determined based on shell integration sequences firing (PromptStart, CommandStart, CommandExecuted, CommandFinished), but this isn't immediately obvious from the code. A constant like SHELL_INTEGRATION_SEQUENCE_COUNT = 4 with a comment explaining why this specific value was chosen would make the code more maintainable and prevent future changes from inadvertently breaking this logic.

Copilot uses AI. Check for mistakes.
@meganrogge meganrogge merged commit 513ca77 into main Jan 26, 2026
27 of 28 checks passed
@meganrogge meganrogge deleted the merogge/sleep branch January 26, 2026 18:30
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sleep 3 showing output briefly

3 participants