Skip to content

fix: schedule promptFallbackScheduler immediately in trackIdleOnPrompt#312387

Merged
meganrogge merged 1 commit intomainfrom
merogge/fix-trackIdleOnPrompt-hang
Apr 24, 2026
Merged

fix: schedule promptFallbackScheduler immediately in trackIdleOnPrompt#312387
meganrogge merged 1 commit intomainfrom
merogge/fix-trackIdleOnPrompt-hang

Conversation

@meganrogge
Copy link
Copy Markdown
Collaborator

@meganrogge meganrogge commented Apr 24, 2026

When no terminal data events arrive after a command is sent (e.g. shell integration is broken and the command finishes silently or hangs waiting for input), neither the idle scheduler nor the prompt fallback scheduler was ever triggered, causing trackIdleOnPrompt to block forever.

This caused run_in_terminal to hang indefinitely in both RichExecuteStrategy and BasicExecuteStrategy, leading to 7 timeout failures (X_AGENT_STILL_RESPONDING) in terminalbench evaluation runs.

Fix: schedule the promptFallbackScheduler immediately so it can fire even without data events. If no data arrives within promptFallbackMs (default 1s), the fallback transitions to PromptAfterExecuting and schedules the idle timer, which resolves ~2s after the last data event (or immediately if none arrived). When data does arrive, the existing onData handler reschedules/cancels as before — no behavior change for the normal path.

Fixes #312384

  • Shell integration works → zero behavior change (state guard exits early)
  • Shell integration broken + data flowing → zero change (initial fallback canceled on first data event)
  • Shell integration broken + no data at all → resolves after ~11s instead of hanging forever

Copilot AI review requested due to automatic review settings April 24, 2026 15:43
@meganrogge meganrogge self-assigned this Apr 24, 2026
@meganrogge meganrogge added this to the 1.118.0 milestone Apr 24, 2026
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

Fixes a hang in the terminal chat agent’s execution flow by ensuring the idle/prompt fallback logic in trackIdleOnPrompt can make progress even when the terminal produces zero data events (eg broken shell integration), preventing run_in_terminal from blocking indefinitely.

Changes:

  • Schedule promptFallbackScheduler immediately so the prompt fallback can fire without relying on onData.
  • Add inline documentation explaining why immediate scheduling is necessary (avoid indefinite block when no data events arrive).
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.ts Arms the prompt-fallback scheduler immediately in trackIdleOnPrompt to avoid indefinite hangs when no terminal data events occur.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

When no terminal data events arrive after a command is sent (e.g. shell
integration is broken and the command finishes silently or hangs waiting
for input), neither the idle scheduler nor the prompt fallback scheduler
was ever triggered, causing trackIdleOnPrompt to block forever.

This caused run_in_terminal to hang indefinitely in both
RichExecuteStrategy and BasicExecuteStrategy, leading to 7 timeout
failures (X_AGENT_STILL_RESPONDING) in terminalbench evaluation runs.

Fix: add a separate initial fallback timer (10s) that fires only when
no data events arrive at all. This is long enough to avoid false early
completion for slow-starting commands (e.g. sleep 5), but prevents the
infinite hang. Once any data arrives, the initial fallback is canceled
and the existing data-driven promptFallbackScheduler (1s) takes over.

Behavior summary:
- Shell integration works → no change (C sequence sets Executing state,
  initial fallback guard exits early)
- Shell integration broken + data flowing → no change (onData cancels
  initial fallback, existing debounce logic handles idle detection)
- Shell integration broken + no data at all → resolves after ~11s
  instead of hanging forever

Fixes #312384

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@meganrogge meganrogge force-pushed the merogge/fix-trackIdleOnPrompt-hang branch from 9783ec5 to f01aebc Compare April 24, 2026 15:49
@meganrogge meganrogge requested a review from anthonykim1 April 24, 2026 15:51
@anthonykim1
Copy link
Copy Markdown
Contributor

anthonykim1 commented Apr 24, 2026

This is great, So this would fix "silent" case where shell integration could be broken (and trackIdleOnPrompt is used) + commands that would hang with no output would now resolve after ~11s instead of indefinite hang.

@meganrogge meganrogge merged commit 64e0919 into main Apr 24, 2026
26 checks passed
@meganrogge meganrogge deleted the merogge/fix-trackIdleOnPrompt-hang branch April 24, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal agent: trackIdleOnPrompt never resolves when no terminal data arrives — causes indefinite hang

3 participants