fix(chat): deliver background job notifications at step boundaries - #1932
Open
zhanba wants to merge 2 commits into
Open
fix(chat): deliver background job notifications at step boundaries#1932zhanba wants to merge 2 commits into
zhanba wants to merge 2 commits into
Conversation
Background job completion notifications waited for the whole turn to end before reaching the model, so they arrived late and often after the model had already moved past the point where they mattered. Deliver them at the agent loop step boundary instead, riding along with the continuation request that is sent anyway, in both the webui and the CLI runner. 🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-98432c863b7443779e3b27f5d90db811) Co-Authored-By: Pochi <noreply@getpochi.com>
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (74.07%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1932 +/- ##
==========================================
+ Coverage 33.32% 33.38% +0.06%
==========================================
Files 778 779 +1
Lines 83120 83210 +90
Branches 4897 4757 -140
==========================================
+ Hits 27696 27780 +84
- Misses 55304 55310 +6
Partials 120 120 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-98432c863b7443779e3b27f5d90db811) Co-Authored-By: Pochi <noreply@getpochi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
executeCommandwithbackground: true) were only handed to the model once the whole turn had ended. Mid-loop they sat in the queue, so they arrived late and often after the model had already moved past the point where they were actionable.packages/vscode-webui: the auto-dequeue effect inchat-toolbar.tsxgated delivery ontaskStatusbeing idle. Delivery is now also attempted from the auto-continuation decision chain (page.tsx->continueAutomatically), so it inherits every existing safety gate: an intentional pause (autoApproveGuard === "stop", paused todo loop) is never resumed by a notification, andsendQueuedMessage(..., { keepAutoApproveGuard: true })makes sure a one-shot manual approval is not upgraded to auto. Only a background-job notification sitting at the queue head is eligible; user-typed queued messages keep their previous behaviour. Dedup is keyed on message identity (deliveredNotificationsRef) rather than an in-flight boolean, so an aborted send cannot stall the queue.packages/cli:TaskRunnerhad the same gate — it only drainedpendingBackgroundJobNotificationson a"finished"step. The drain now also happens right before the continuationchat.sendMessage()when the step result is"next". The decision lives in a new pure helper,src/lib/background-job-notification-delivery.ts, so it is unit-testable without the fullTaskRunnerharness."retry"steps never inject (the retry must re-send the same state), and the end-of-taskwaitForAsyncWork()drain is untouched.Not in scope:
packages/cli/src/running-task-adaptor.tscreates per-taskBackgroundJobManagers but never subscribes toonDidFinish, so that path surfaces no background job notifications at all. Pre-existing, worth a follow-up.Test plan
cd packages/cli && bun run test— 16 files / 132 tests pass, including 6 new tests for the delivery helper (drains all pending events into one message;"next"delivers and empties the queue;"retry"/"finished"/ empty queue do not).cd packages/vscode-webui && bun run test— 77 files / 532 tests pass, including new coverage for the queue helpers,sendQueuedMessage(guard preservation, single-entry removal) and the toolbar delivery callback (head notification delivers once; user message ahead blocks it).bun tscclean in both packages;bun fix/bun checkclean at the repo root.attemptCompletion; two jobs finishing near the same boundary are batched into one notification message; a job started immediately beforeattemptCompletionis still awaited and delivered by the existing end-of-task drain.Note: the local
pre-pushhook could not runpackages/vscode's extension tests in this worktree (IPC handle ... is longer than 103 chars— the checkout path exceeds the macOS unix socket limit). Every other hook step passed; this change does not touchpackages/vscode.🤖 Generated with Pochi | Task