Warn before closing the window while any run is still active#1747
Open
iyernaveenr wants to merge 1 commit into
Open
Warn before closing the window while any run is still active#1747iyernaveenr wants to merge 1 commit into
iyernaveenr wants to merge 1 commit into
Conversation
Closing the window severs every run's event stream and the backend aborts the in-flight work. The existing warning only checked the active Project's current task, so runs streaming in other Projects were killed silently. Consider every live run when deciding whether to show the close warning, so quitting mid-run is always an informed choice. Signed-off-by: Naveen R. Iyer <iyernaveenr@gmail.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.
Problem
Closing the window while agent runs are streaming kills them silently: the event streams are severed, the backend treats it as a client disconnect and aborts the in-flight work, cleaning up the task locks. The affected conversations are left permanently incomplete (dangling tool rows, progress stuck, no final answer, zero recorded tokens) with no warning at close time.
Root cause
A close warning exists, but it only checks the status of the active Project's current task. Runs streaming in other Projects -- exactly the situation when working with several Projects in parallel -- are invisible to it, so the window closes without the "a task is currently running" dialog.
Fix
Track whether any run in any Project still holds a live event stream (the set of active stream controllers is the ground truth for what a window close would sever), and show the existing close-notice dialog when either the active task is busy or any such run exists. Cancel keeps the app and the runs alive; confirming still quits, making an interrupted run an informed choice instead of a silent side effect.
Testing
Verified on Linux desktop: with a long-running task streaming in one Project and a different Project focused, closing the window now shows the running-task dialog (previously it closed silently and the backend logged a stream cancellation and aborted the run); Cancel left the runs untouched and they completed normally afterwards. With no runs active, the window closes immediately as before.
tscpasses; lint and formatting are clean for the changed files.