Problem
When Blazor re-renders (triggered by OnStateChanged), the draft restore system (restoreDraftsAndFocus) can overwrite whatever the user is currently typing with a stale draft from draftBySession.
Steps to reproduce
- Send a message (e.g.,
/prompt use PR Review -- 559) in a session
- The message is sent and the textarea clears
- Type a new message
- A Blazor re-render fires (from any state change)
- The textarea is overwritten with the OLD message (
/prompt use PR Review -- 559)
Root cause
draftBySession retains the old draft text. The JS-side __liveDrafts mechanism captures live input and merges it before restore, but there's a race window: if the render happens between send (textarea cleared) and the next input event, the stale draft wins.
Relevant code
PolyPilot/wwwroot/index.html:687-787 — restoreDraftsAndFocus
PolyPilot/Components/Pages/Dashboard.razor:1167-1175,1209-1231 — draft save/restore
Problem
When Blazor re-renders (triggered by
OnStateChanged), the draft restore system (restoreDraftsAndFocus) can overwrite whatever the user is currently typing with a stale draft fromdraftBySession.Steps to reproduce
/prompt use PR Review -- 559) in a session/prompt use PR Review -- 559)Root cause
draftBySessionretains the old draft text. The JS-side__liveDraftsmechanism captures live input and merges it before restore, but there's a race window: if the render happens between send (textarea cleared) and the nextinputevent, the stale draft wins.Relevant code
PolyPilot/wwwroot/index.html:687-787—restoreDraftsAndFocusPolyPilot/Components/Pages/Dashboard.razor:1167-1175,1209-1231— draft save/restore