fix(backend): report accepted-but-not-yet-active runs as busy in session listings - #28
Open
hbruceweaver wants to merge 2 commits into
Open
hbruceweaver wants to merge 2 commits into
hbruceweaver wants to merge 2 commits into
Conversation
4 tasks
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
swarm) showed as idle in the cross-workspace sidebar ("0 working sessions") for the whole turn.backend.runAgentpublishesAttentionBusyat dispatch, right afterBeginAccepted. The TUI reacts by re-fetchingListWorkspaceOverviews, but the overview computedIsBusyviaIsSessionBusy, which only checksactiveRequests— not set untilsessionAgent.Rungets pastreadyWg/UpdateModels/model resolution. The refresh read idle, and nothing re-refreshes mid-turn (sessionUpdatedEvents are deliberately ignored). Human-typed sessions usually got a second refresh from the title rename; swarm-spawned ones arrive titled and never did.IsSessionBusyOrAccepted(active OR accepted-not-yet-active, per session) onSessionAgent/Coordinatorand use it for observer-facing state: session overviews,GetAgentSession, RESTisSessionBusy, andSwarmSend'sdelivery.IsSessionBusystays strict:Runuses it to decide queue-vs-become-active and must not see its own reservation.IsBusycounts accepted runs but onlyclearActiveRequestsignalledidleCh, soWaitForIdleslept through a run cancelled on entry (or failing incoordinator.runbefore activation) until an unrelated run ended or its ctx expired.endAcceptednow signals when a session's count reaches zero. Also closes a lost-wakeup window inWaitForIdleitself: it now captures the idle channel before the busy check, so a release landing between the two closes the captured channel instead of a replacement the waiter never sees.Test plan
TestIsSessionBusyOrAccepted_ObservesDispatchWindow— busy fromBeginAcceptedthrough active to idle with no gap; per-session; strict predicate unchanged.TestWaitForIdle_WakesWhenAcceptedRunReleased,TestEndAccepted_OnlyLastReleaseSignals,TestWaitForIdle_NoLostWakeupWhenReleaseRacesBusyCheck(500 iterations,-raceclean).go test ./internal/agent ./internal/backend ./internal/server(the pre-existingTestE2E_ShutdownCallbackFiresWhenLastClientLeavesfailure reproduces on pristineupstream/feature).swarm new; sidebar shows the busy dot and "1 working session" immediately.