Fix autodraft settings panel not reflecting auto-disable after pick #50
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/autodraft-settings-stale-state"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
useDraftAuthRecoverynow syncsuserAutodraft(settings badge/panel) from loader data after revalidation, alongside the existingautodraftStatussync. Previously the draft grid updated correctly on reconnect but the settings panel showed stale state.prev.mode === "next_pick") with an explicitreasonfield ("pick_complete"|"queue_empty") added to the server'sautodraft-updatedemit. This fixes two toast bugs caught in code review: the wrong toast showing when a user manually disables next_queue autodraft, and the wrong toast showing when next_queue's queue empties.userAutodraftRef(previously used to readprev.modefor toast logic) fromuseDraftAuthRecovery, its call site, anduseDraftSocketEvents.Test plan
source: "user"is filtered out by thedata.reasoncheck)When next_queue autodraft fires and turns itself off, two bugs prevented the UI from behaving correctly: 1. After reconnect, useDraftAuthRecovery synced autodraftStatus (draft grid) but not userAutodraft (settings panel), leaving the settings badge stale until the next page load. 2. Toast notifications for autodraft auto-disable were unreliable: the condition checked prev.mode rather than why the server disabled it, causing the wrong toast for manual disables and queue-empty events. Fix the reconnect sync by calling setUserAutodraft in the revalidation effect alongside setAutodraftStatus. Fix the toast logic by adding a reason field ("pick_complete" | "queue_empty") to the server's autodraft-updated emit, so the client can show the right message without guessing from local state. Also removes the now-unused userAutodraftRef. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>