Skip to content

fix: keep failed thread-notes drafts and retry on save reject (#935) - #1159

Merged
currentbits merged 1 commit into
mainfrom
coder/notes-save-reject-935
Sep 9, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/notes-save-reject-935

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Why

Closing thread notes discarded the typed draft when threads.setNotes rejected. The editor closed, an error flashed, and reopen restored only the last saved note.

closeNotes fired onSetNotes without waiting. App.handleSetNotes dropped the promise. useCoder.setNotes swallowed the rejection. Reopen always seeded from thread.notes.

Issue #935. Planboard already marked it done from a local merge that never reached origin/main.

What

  • useCoder.setNotes rethrows after recording the error so callers can see failure.
  • App.handleSetNotes returns that promise.
  • ThreadView awaits the write. A rejected save keeps the editor open with the typed draft and a Retry control. Escape still discards.
  • Failed drafts stay keyed by source thread across navigation. A late reject on A cannot overwrite B's editor.
  • Reopening a thread with an in-flight write restores the draft locked until that write settles. An unchanged close after a successful flush does not write again.

Test

node --import=./test/support/disable-grok-mcp.mjs --import=./test/support/render.mjs --experimental-strip-types --test --test-timeout=20000 test/threadNotes.test.tsx

8/8, including reject-and-retry, cross-thread draft provenance, pending-write lock, and A→B late-reject isolation.

npm run typecheck clean.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-09T10:19:26.564249Z 9fc8645 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +4355 to +4358
/** Failed (or in-flight outgoing) drafts keyed by thread id (#935). */
const notesFailedRef = useRef<Record<string, { draft: string; error: string }>>(
{},
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +5299 to +5300
if (wasOpen && source && outgoingDraft !== source.saved) {
rememberFailedNotes(source.id, outgoingDraft, "");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@currentbits
currentbits merged commit bf6fb02 into main Sep 9, 2026
3 of 6 checks passed
@currentbits
currentbits deleted the coder/notes-save-reject-935 branch October 3, 2026 16:07
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