Skip to content

Prevent alt buffer entrance from hanging chat agent#282883

Merged
meganrogge merged 3 commits intomainfrom
merogge/alt-buffer
Dec 16, 2025
Merged

Prevent alt buffer entrance from hanging chat agent#282883
meganrogge merged 3 commits intomainfrom
merogge/alt-buffer

Conversation

@meganrogge
Copy link
Collaborator

fix #280705

Before: (hanging)

image

After:

Screenshot 2025-12-11 at 5 22 45 PM

Copilot AI review requested due to automatic review settings December 11, 2025 22:23
@meganrogge meganrogge self-assigned this Dec 11, 2025
@meganrogge meganrogge added this to the December / January 2026 milestone Dec 11, 2025
@meganrogge meganrogge requested a review from Tyriar December 11, 2025 22:24
@meganrogge meganrogge enabled auto-merge (squash) December 11, 2025 22:24
Copy link
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 addresses issue #280705 by preventing the chat agent from hanging when terminal commands open the alternate buffer (e.g., when running interactive programs like vim, less, or top). The implementation adds a race condition between command execution and alternate buffer detection, allowing early termination with a user-friendly message when the alternate buffer is activated.

Key changes:

  • Added DeferredPromise and CancellationTokenSource imports to support cancellation and async coordination
  • Implemented _createAltBufferPromise() method to detect when xterm enters alternate buffer mode
  • Modified the command execution flow to race between normal execution and alternate buffer detection

Tyriar
Tyriar previously requested changes Dec 11, 2025
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Nice idea! Could we move the handling of this into the execute strategies instead so all these cases are consolidated here?

const onDone = Promise.race([
Event.toPromise(this._commandDetection.onCommandFinished, store).then(e => {
this._log('onDone via end event');
return {
'type': 'success',
command: e
} as const;
}),
Event.toPromise(token.onCancellationRequested as Event<undefined>, store).then(() => {
this._log('onDone via cancellation');
}),
Event.toPromise(this._instance.onDisposed, store).then(() => {
this._log('onDone via terminal disposal');
return { type: 'disposal' } as const;
}),
trackIdleOnPrompt(this._instance, 1000, store).then(() => {
this._log('onDone via idle prompt');
}),
]);

It'll be duplicated but it's way more obvious and keeps RunInTerminalTool simpler that way. If it makes sense to share code that can go into strategyHelpers.ts

@meganrogge meganrogge merged commit cbf7676 into main Dec 16, 2025
28 checks passed
@meganrogge meganrogge deleted the merogge/alt-buffer branch December 16, 2025 18:18
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 31, 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.

[inline terminal] less hangs the terminal

4 participants