Repository navigation
fix: keep failed thread-notes drafts and retry on save reject (#935) - #1159
Conversation
Closing notes used to fire-and-forget setNotes and reseed from thread.notes, so a rejected write dropped the typed draft. Await the write, keep the editor open with Retry, and remember failed drafts per thread across navigation.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9fc8645a24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** Failed (or in-flight outgoing) drafts keyed by thread id (#935). */ | ||
| const notesFailedRef = useRef<Record<string, { draft: string; error: string }>>( | ||
| {}, | ||
| ); |
There was a problem hiding this comment.
Preserve failed drafts outside the ThreadView lifetime
When a save has failed and the user navigates to another top-level view such as Kanban, Activity, or Automations, App.tsx:1355-1445 replaces and unmounts ThreadView. Because the only retained copy is this component-local ref, returning to the thread creates a fresh ref and restores thread.notes, losing the typed draft this change is intended to protect. Store failed drafts in state that survives these view transitions, or flush them into such storage during unmount.
Useful? React with 👍 / 👎.
| if (wasOpen && source && outgoingDraft !== source.saved) { | ||
| rememberFailedNotes(source.id, outgoingDraft, ""); |
There was a problem hiding this comment.
Clear a failed draft when navigation finds clean text
After a save of draft X fails, if the user edits the textarea back to the last confirmed note and switches threads without a blur (for example with the keyboard thread navigation), this condition skips the whole block and leaves X in notesFailedRef. Returning to the thread then seeds the editor from that stale failed draft instead of the saved value. Clear the held entry when outgoingDraft === source.saved before closing the panel.
Useful? React with 👍 / 👎.
Why
Closing thread notes discarded the typed draft when
threads.setNotesrejected. The editor closed, an error flashed, and reopen restored only the last saved note.closeNotesfiredonSetNoteswithout waiting.App.handleSetNotesdropped the promise.useCoder.setNotesswallowed the rejection. Reopen always seeded fromthread.notes.Issue #935. Planboard already marked it done from a local merge that never reached
origin/main.What
useCoder.setNotesrethrows after recording the error so callers can see failure.App.handleSetNotesreturns that promise.Test
node --import=./test/support/disable-grok-mcp.mjs --import=./test/support/render.mjs --experimental-strip-types --test --test-timeout=20000 test/threadNotes.test.tsx8/8, including reject-and-retry, cross-thread draft provenance, pending-write lock, and A→B late-reject isolation.
npm run typecheckclean.