Prevent alt buffer entrance from hanging chat agent#282883
Conversation
There was a problem hiding this comment.
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
DeferredPromiseandCancellationTokenSourceimports 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
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts
Outdated
Show resolved
Hide resolved
Tyriar
left a comment
There was a problem hiding this comment.
Nice idea! Could we move the handling of this into the execute strategies instead so all these cases are consolidated here?
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
fix #280705
Before: (hanging)
After: