Skip to content

fix: prevent subscription resolvers from dropping notifications under backpressure (Refs: beans-x0zh)#169

Merged
hmans merged 1 commit intomainfrom
beans/established-mink-cuzc
Mar 21, 2026
Merged

fix: prevent subscription resolvers from dropping notifications under backpressure (Refs: beans-x0zh)#169
hmans merged 1 commit intomainfrom
beans/established-mink-cuzc

Conversation

@hmans
Copy link
Copy Markdown
Owner

@hmans hmans commented Mar 21, 2026

Summary

  • The AgentSessionChanged and ActiveAgentStatuses subscription resolvers blocked on sending each payload to the WebSocket transport via an unbuffered out channel. While blocked, new notifications on the buffer-1 notification channel were silently dropped. This could cause the frontend to miss entire RUNNING status transitions, making the "Agent is working..." spinner disappear while the agent was still active.
  • Changed both resolvers to use a latest-value pattern: when a new notification arrives while the resolver is blocked sending, it refreshes the pending payload with the latest session state instead of losing the update. The frontend may skip intermediate states but always sees the most recent one.
  • Added TestAgentSessionSubscription_DeliversLatestState to verify correct delivery under rapid notifications.

Test plan

  • Run mise test — all Go tests pass
  • Manual: start an agent task in Beans UI, verify the "Agent is working..." spinner stays visible throughout
  • Manual: trigger rapid agent state changes (e.g. quick tool calls) and verify the spinner doesn't flicker or disappear

… backpressure (Refs: beans-x0zh)

- Change AgentSessionChanged and ActiveAgentStatuses resolvers to use
  a latest-value pattern instead of blocking on send
- When a new notification arrives while the resolver is blocked sending
  to the WebSocket transport, refresh the pending state so the frontend
  always receives the most recent session status
- Add test for latest-value delivery under rapid notifications
@hmans hmans merged commit 01896d4 into main Mar 21, 2026
1 check passed
@hmans hmans deleted the beans/established-mink-cuzc branch March 21, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant