fix(core): make read_background_output delay abort-aware#27839
fix(core): make read_background_output delay abort-aware#27839SandyTao520 wants to merge 1 commit into
Conversation
Pressing ESC during a read_background_output call with delay_ms left the scheduler blocked until the timer fired, since the sleep ignored the abort signal. Use the abortable timers/promises setTimeout so cancellation rejects immediately with an AbortError, which the tool executor already converts into a Cancelled result. Fixes #18007
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a responsiveness issue in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
🛑 Action Required: Evaluation ApprovalSteering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged. Maintainers:
Once approved, the evaluation results will be posted here automatically. |
There was a problem hiding this comment.
Code Review
This pull request updates the ReadBackgroundOutputInvocation class in shellBackgroundTools.ts to use an abort-aware delay using setTimeout from node:timers/promises instead of a standard Promise with setTimeout. This ensures that when the user cancels, the delay is aborted immediately rather than blocking the scheduler. Corresponding unit tests have been added in shellBackgroundTools.test.ts to verify that the delay aborts correctly when the signal is aborted or already aborted. There are no review comments to address, and I have no feedback to provide.
|
Size Change: +38 B (0%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
Summary
Pressing ESC to cancel a
read_background_outputcall marked it as cancelledin the UI, but the spinner kept spinning and new prompts were queued. The
tool's optional
delay_mssleep used a plainsetTimeoutthat ignored theabort signal, so the underlying tool promise kept the scheduler's executing
slot occupied until the timer fired.
Details
ReadBackgroundOutputInvocation.executenow uses the abortablesetTimeoutfromnode:timers/promises, passing the executionabortSignal.AbortError, whichtool-executor.tsalready converts into aCancelledresult via itsisAbortErrorhandling — no executor changesneeded.
signal.
Related Issues
Fixes #18007
How to Validate
npm test -w @google/gemini-cli-core -- src/tools/shellBackgroundTools.test.ts— all 12 tests pass, including the two new abort cases.
read_background_outputwith a largedelay_ms(e.g. 30000), press ESC.The spinner stops immediately and the next prompt is accepted without
queueing.
Pre-Merge Checklist