Repository navigation
web(drafts): preserve edits through stale saves and navigation - #67
Conversation
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: 0c955ce220
ℹ️ 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".
TusanHomichi
left a comment
There was a problem hiding this comment.
Merge review at 0c955ce: hold this PR. I inspected the controller/route lifecycle and agree with the four existing, unresolved Codex findings; this summary does not create duplicate findings. pr-gate run 34661983530 is green, but it does not cover these boundaries.
Required repairs and regression evidence:
DraftEditorController::destroy()cancels the only pending autosave inside the 600 ms debounce window. Preserve/flush legitimate working-copy edits against their original draft identity before allowing navigation, or explicitly warn/block navigation. Do not mistake the requirement to discard refused recovery buffers on navigation for permission to silently discard unsaved ordinary edits. Add a real navigation-before-debounce regression.received()ignores successful saves, so following the offered copy-back-and-save recovery path leavesrefusalUnresolvedset. Make successful resolution clear the matching guard without requiring an additional discard action, and without allowing unrelated/failed saves or a first attempted workflow action to clear other unresolved text. Test copy-back -> successful save -> submit/finalize without discard.- The identity-change cleanup replaces the controller but leaves the page-level refusal guard set. Keep all refusal/guard state in the same draft lifetime, and prove that client-side navigation to another
[id]does not leave it blocked with no recovery panel capable of resolving it. recoverFromRefusal()resumes afterawait load()using the currenteditor, even whenload()returned null because the route changed. Capture the originating controller and generation/draft identity and invalidate the complete continuation before it updates buffers, errors, or guards. Distinguish obsolete navigation results from actual reload failures. Hold the refusal-triggered GET, navigate to another draft using SPA navigation (not a full page reload), then release it; assert no old content, error, or guard appears in the destination. A different-form destination and an A -> B -> A navigation are useful checks against field-ID coincidences and identity-only guards.
Keep the existing recovery text memory-only and read-only; no automatic merging/resubmission. Retain the existing failed-reload, late-typing, and repeated-refusal coverage. Revalidate against current main, which now includes #68, and rerun the full repository/browser gates. #59 remains open.
Verification limitation: this review used source inspection and GitHub CI/review evidence; no independent local Rust/browser run was performed.
A refused save reloaded the winning copy and took the writer's own text with it, turning an honest concurrency refusal into lost work (#34). The draft working copy, its autosave chain, and the recovery buffers now have one owner: `web/src/lib/drafts/`, which the route page reads instead of holding a second copy of every editable value (#59, partial). The refusal keeps every save the contract refused, newest first, with anything typed while the request was in flight, shown read-only, copyable, and field-labelled. Nothing is merged, resubmitted, persisted, or sent anywhere, and the buffers die with the draft identity. Recovery state and its guard share the controller's lifetime, which is what the review's four lifecycle findings needed: - a queued ordinary edit is saved when the route goes away instead of being cancelled with its debounce timer; refused recovery text is not resubmitted, and a refusal the page has not answered yet is skipped; - the workflow-act guard is per refusal, and a save the writer makes after seeing a refusal resolves exactly the buffers that save carries — copying the text back and saving unlocks submission and finalization without an extra discard, while another refusal's uncopied text keeps holding the act; - the guard lives with the buffers in the controller, so a draft identity change takes it away instead of leaving a page blocked with nothing to dismiss; - the recovery continuation captures the controller and the route it started on, so a refusal whose reload lands after the page moved on touches no buffer, no error, and no guard of the draft now on screen. Browser proof in `web/e2e/draft-recovery.spec.ts` now runs eleven scenarios over two real writer contexts, synchronized on held requests: the loser copies their sentence; text typed during a pending request and text typed while the winner was reloading both stay recoverable and never reach the server; a failed reload keeps the buffer; a second refusal adds to the first; a workflow act makes no request until the writer acknowledges, and then does; copy-back and save lifts the guard without a discard; an edit made inside the debounce window survives navigation; a refusal dies with its draft while another draft's acts work; and a refusal that lands after the page moved on changes nothing. Each fix was falsified against the behaviour it replaces before it was kept.
0c955ce to
afed873
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afed87374b
ℹ️ 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".
Repairs at
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3581462bbd
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e16723500c
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9995a61dc6
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 526844ff79
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fbfd69ede
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8477e8941c
ℹ️ 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".
Problem and behavior
A stale autosave reloaded the winning draft and erased the losing writer’s edits. The draft workspace now keeps divergent narratives, deletions, and ratings in a read-only, copyable recovery panel. The writer chooses what to copy back and save, or discards it. Buffers stay in memory and clear on deliberate navigation.
Saves serialize against the accepted revision. SPA departure waits for pending ordinary saves with the editor mounted; failed saves offer Retry save, and native unload warns while edits or fresh recovery are pending. Reload latest draft retries only the GET and preserves recovery text. Origin guards keep late loads and workflow replies tied to their draft and controller.
When submission or finalization freezes a queued save, local fields remain labeled and selectable while the authoritative copy loads. A typed refusal is distinguished from an unconfirmed transport outcome. The server copy then returns as the main content, with local differences kept separately. Review, finalize, and amend actions wait until recovery is resolved.
Fields pause during workflow requests and accepted navigation; interrupted navigation can resume without clearing buffers. Invalid numeric draft/version URLs show an error before fetching and allow valid SPA reentry.
Scope and issue
Closes #34. Recovery follows ADR 0008: buffers stay in memory, with no persistence or automatic merge. Existing service, API, schema, and record-integrity contracts are unchanged. The primary issue owns the execution graph and historical evidence.
Verification
Final candidate
b515cb92f18de119ca56592c0289213d3ded3150, tree67a472a327a9821df872cead15fa08bbfad2a420, includes maine0679bc.678b6fe; no new automated approval is claimed for this head.Fixtures use invented data. Debug browser checks read built assets from disk and do not prove release embedding. Synthetic stranded-history coverage is qualified separately from natural navigation overlap. Hosted binary/static outputs were not downloaded; no hosted output hashes are claimed.
Merged to
mainas03cc8c77af26183dd7a0a61870152d21757dcb85. The merged tree equals the tested candidate tree; local main was fast-forwarded and task-owned branch/worktree cleanup was verified. Merge verification receipt.