Skip to content

fix: prevent status --watch from dropping concurrent dispatches - #134

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-bug-management-13ec
Draft

fix: prevent status --watch from dropping concurrent dispatches#134
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-bug-management-13ec

Conversation

@cursor

@cursor cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bug and impact

polyagent status --watch could delete sessions from ~/.polyagent/state.json when another CLI process dispatched at the same time. The new session vanished from local state on the next watch tick.

Root cause

StateStore kept a long-lived in-memory session list and save() rewrote the entire file from that snapshot. upsert / upsertMany never reloaded disk first, so a concurrent dispatch write was overwritten.

Fix

  • Reload from disk before merging in upsert / upsertMany
  • Reload at the start of each status poll so --watch also sees newly dispatched sessions

Validation

  • Added regression tests for concurrent upsert/upsertMany
  • npx vitest run test/state.test.ts test/status-command.test.ts test/status.test.ts — all passing
Open in Web View Automation 

cursoragent and others added 2 commits August 13, 2026 11:16
status --watch kept a long-lived StateStore and saved the full file from
stale memory, so a concurrent dispatch could be overwritten on the next
tick. Reload from disk before merging upserts, and refresh at the start
of each status poll.

Co-authored-by: Parvez Kose <koseparvez@gmail.com>
Update the status-command mock for load/upsertMany and format the new
StateStore concurrency regression tests.

Co-authored-by: Parvez Kose <koseparvez@gmail.com>
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polyagent Ready Ready Preview Aug 13, 2026 11:18am

`[].every()` is vacuously true, so an empty sessions payload stopped the
3s refresh. GET /api/sessions also returns `{ sessions: [] }` on list
failures, which made a transient error permanently freeze the dashboard.

Co-authored-by: Parvez Kose <koseparvez@gmail.com>
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