You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): keep file edits safe when previews load or refresh slowly - #31696
Open a file, edit it, and tap Save twice quickly. Before this follow-up, both taps could write the file. Now one save runs at a time, and text you type while it is saving stays available to save afterward. Slow preview replies also cannot replace edits belonging to another file or desktop.
What Changed
Allow only one file save at a time, including two taps before the screen rerenders.
Only let the latest preview load update the file on screen.
Keep unsaved text editable when the same file's details refresh.
Treat a different file or computer as a separate document, even if the path looks the same.
Why
A slow file read or background refresh should not undo your work or mix up files from different computers.
Linked Issue
Maintainer-discovered regression. Bounded GitHub symptom and exact-file searches found no exact duplicate. Related #24469 and #29096 concern rendering/navigation; this fixes load and draft ownership.
Visual Proof
Captured with the visual-proof skill. Before uses base 15246eb4a45; after uses this PR's standalone commit fce94316866. The scenario passed asserted capture runs 3 times per version before representative screenshots were selected. The captures were visually inspected.
Evidence scope: Actual production RN Web screen; truncated reconnect preserves draft. Other race cases in mounted tests.
01-before-preview-3.png
02-after-preview-3.png
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
The hook/transport boundary harnesses are labeled in the captures. These are browser evidence where stated; they do not establish native keyboard, gesture, permission dialog, safe-area or real-network behavior. Full code regressions cover additional cases described above.
Follow-up before/after proof
Created with the visual-proof skill. Before source 3b987331c83e; after source 9622c261ab7e, included in the current head. Captured through headless Chromium CDP, with asserted outcomes in three runs per version. Representative screenshots were visually inspected.
Evidence scope: Production React Native Web file-preview screen with scripted read/write responses. The capture invokes the real Save handler twice before React rerenders; the diagnostic counter shows two desktop writes before and one after. This deliberately scripts same-frame taps and does not establish native touch behavior.
before.png
after.png
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
Testing
The combined review checkout aa6fe5dae109 contains this PR at 9622c261ab7e and the other mobile PRs reviewed together. Validation ran with ORCA_BACKGROUND_LAUNCH=1 on macOS.
Full mobile run: 11,493 passed, 2 failed, 6 skipped. Both failures were recording checks for the intentional new uncertain-paste warning. After updating only that golden, the affected two recording suites passed 1,197 tests, including both previously failing checks. This accounts for all 11,495 non-skipped tests; it is not a claim of a second clean full-suite invocation.
Production mobile typecheck and the test-typecheck ratchet passed (1,111 test files; 116 grandfathered).
Changed-code quality gate passed with zero new findings across eight code files, including React Doctor and design-system checks. Follow-up code formatting and lint checks passed.
Mobile web build and packaged asset verification passed. The package manager warned that its pre-script dependency refresh could not replace the shared node_modules symlink; the build and both asset verifiers nevertheless completed successfully.
An earlier attempt using the shared checkout’s newer Vitest crashed. The reported full run and recording recheck used the mobile package’s pinned Vitest 4.1.12 with four workers. These are combined-checkout results; separate CI must validate each PR against current main. Native-device coverage remains limited as described in Visual Proof and Review.
Rebase and review (2026-10-28)
Rebased onto current main (one mechanical conflict: main's new useMobileColorScheme() call moved into the inner document component). A Codex + Claude review round found no P0/P1. The one P3 was taken: the new early return for a dirty draft left an always-true if (!preserveDirtyDraft) guard, now removed. The added tests share one route and mount helper instead of repeating it (276 → 153 lines, same cases). Focused mobile suites pass: src/files (260 tests) and the RPC recording goldens (1,695 tests).
Risk-reduction checks
Second pass: Fixed two Save taps in the same frame sending two file writes. A synchronous save latch now permits one write. The regression also checks that typing during an earlier save remains unsaved and editable.
Current PR head: 9622c261ab7e. Combined review head: aa6fe5dae109.
CI status: the earlier locale issue #31747 has merged. This PR remains a draft; skipped draft workflows do not count as a fresh passing full CI run.
The new duplicate-Save regression failed before the fix (two actual writes) and passes afterward (one). The file suites passed 271 tests. Typing during a clean refresh did not reproduce a defect because that editor is hidden while the refresh loads.
AI Disclosure
Review
Merge risk: Medium. The editor handles unsaved work. Two clients saving the same file at the same moment could both pass the desktop's "file unchanged" check before either committed. That is a host-side race that already existed on main, fixed separately in #35418 (per-file write queue on the desktop, no wire change).
Previously reviewed by a separate agent team; this pass traced the production paths again and added failing-before regressions for the three newly reproduced defects.
Agent skill upstream boundary
Not applicable; this change copies no upstream skill-installer implementation.
Notes
Existing RPC methods and wire compatibility are retained. Review considered desktop host changes, remote execution authority, folder workspaces, and native/web consumers. Native simulator follow-up was limited after the three owned simulators became stuck shutting down; no unrelated simulator/process was reset.
Checklist
Focused change with a root-cause explanation.
Automated regression coverage and independent review.
Before/after proof attached with exact evidence scope.
Cross-platform and remote compatibility considered.
Required PR CI checks have passed.
nwparker
changed the title
fix(mobile): preserve file drafts across refresh and reject stale reads
fix(mobile): keep file edits safe when previews load or refresh slowly
Oct 22, 2026
Overlapping preview reads overwrite current content, and refreshed metadata or equivalent route objects revoke dirty editor state. Keep document-owned drafts editable and accept only the current load.
[Medium impact] The PR appears safe to merge; no actionable issues were found.
Summary
Keeps mobile file drafts separate by file and computer, ignores older preview replies, and blocks overlapping saves.
Only the newest file read can update the preview.
Unsaved file edits stay with their document.
The artifact editor starts only one save at a time.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Open or update preview] --> B{Same host and file?}
B -- No --> C[Mount a separate document]
B -- Yes --> D[Keep current draft]
C --> E[Start preview read]
D --> E
E --> F{Latest read?}
F -- No --> G[Ignore reply]
F -- Yes --> H{Unsaved edits?}
H -- Yes --> I[Keep editable draft]
H -- No --> J[Show loaded file]
K[Tap Save] --> L{Save already running?}
L -- Yes --> M[Ignore extra tap]
L -- No --> N[Check saved file and write]
N --> O[Mark submitted text as saved]
The preview document is keyed by host, execution host, and preview source. Preview loads use revision and source-key checks to ignore stale results. Dirty drafts remain unchanged for the tested refresh and route cases. Artifact saves use a ref to prevent concurrent writes. Tests cover load ordering, draft preservation, authority changes, and save behavior.
Priority: Normal
Merge Risk: Minimal · up to b14c4
No merge-blocking code defect was established. Required CI has not yet passed.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: protecting mobile file edits during slow preview loads or refreshes.
Description check
The description is detailed and covers the user impact, implementation, rationale, visual proof, testing, risks, compatibility, and review status. The linked issue section lists related issues but doe…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is detailed and covers the user impact, implementation, rationale, visual proof, testing, risks, compatibility, and review status. The linked issue section lists related issues but does not provide a direct Fixes # issue link, and required CI checks remain pending; these omissions do not make the otherwise complete description largely incomplete.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The current test does not verify the conflict-check baseline used by the next save. Model the desktop content as First edit after the first write, then save Newer edit and assert that the second write occurs.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Open a file, edit it, and tap Save twice quickly. Before this follow-up, both taps could write the file. Now one save runs at a time, and text you type while it is saving stays available to save afterward. Slow preview replies also cannot replace edits belonging to another file or desktop.
What Changed
Why
A slow file read or background refresh should not undo your work or mix up files from different computers.
Linked Issue
Maintainer-discovered regression. Bounded GitHub symptom and exact-file searches found no exact duplicate. Related #24469 and #29096 concern rendering/navigation; this fixes load and draft ownership.
Visual Proof
Captured with the visual-proof skill. Before uses base
15246eb4a45; after uses this PR's standalone commitfce94316866. The scenario passed asserted capture runs 3 times per version before representative screenshots were selected. The captures were visually inspected.Evidence scope: Actual production RN Web screen; truncated reconnect preserves draft. Other race cases in mounted tests.
The hook/transport boundary harnesses are labeled in the captures. These are browser evidence where stated; they do not establish native keyboard, gesture, permission dialog, safe-area or real-network behavior. Full code regressions cover additional cases described above.
Follow-up before/after proof
Created with the visual-proof skill. Before source
3b987331c83e; after source9622c261ab7e, included in the current head. Captured through headless Chromium CDP, with asserted outcomes in three runs per version. Representative screenshots were visually inspected.Evidence scope: Production React Native Web file-preview screen with scripted read/write responses. The capture invokes the real Save handler twice before React rerenders; the diagnostic counter shows two desktop writes before and one after. This deliberately scripts same-frame taps and does not establish native touch behavior.
Testing
The combined review checkout
aa6fe5dae109contains this PR at9622c261ab7eand the other mobile PRs reviewed together. Validation ran withORCA_BACKGROUND_LAUNCH=1on macOS.An earlier attempt using the shared checkout’s newer Vitest crashed. The reported full run and recording recheck used the mobile package’s pinned Vitest 4.1.12 with four workers. These are combined-checkout results; separate CI must validate each PR against current main. Native-device coverage remains limited as described in Visual Proof and Review.
Rebase and review (2026-10-28)
Rebased onto current
main(one mechanical conflict: main's newuseMobileColorScheme()call moved into the inner document component). A Codex + Claude review round found no P0/P1. The one P3 was taken: the new early return for a dirty draft left an always-trueif (!preserveDirtyDraft)guard, now removed. The added tests share one route and mount helper instead of repeating it (276 → 153 lines, same cases). Focused mobile suites pass:src/files(260 tests) and the RPC recording goldens (1,695 tests).Risk-reduction checks
Second pass: Fixed two Save taps in the same frame sending two file writes. A synchronous save latch now permits one write. The regression also checks that typing during an earlier save remains unsaved and editable.
Current PR head:
9622c261ab7e. Combined review head:aa6fe5dae109.CI status: the earlier locale issue #31747 has merged. This PR remains a draft; skipped draft workflows do not count as a fresh passing full CI run.
The new duplicate-Save regression failed before the fix (two actual writes) and passes afterward (one). The file suites passed 271 tests. Typing during a clean refresh did not reproduce a defect because that editor is hidden while the refresh loads.
AI Disclosure
Review
Merge risk: Medium. The editor handles unsaved work. Two clients saving the same file at the same moment could both pass the desktop's "file unchanged" check before either committed. That is a host-side race that already existed on
main, fixed separately in #35418 (per-file write queue on the desktop, no wire change).Previously reviewed by a separate agent team; this pass traced the production paths again and added failing-before regressions for the three newly reproduced defects.
Agent skill upstream boundary
Notes
Existing RPC methods and wire compatibility are retained. Review considered desktop host changes, remote execution authority, folder workspaces, and native/web consumers. Native simulator follow-up was limited after the three owned simulators became stuck shutting down; no unrelated simulator/process was reset.
Checklist