Skip to content

fix(mobile): allow Markdown refresh during desktop tab snapshots - #30040

Merged
nwparker merged 1 commit into
mainfrom
fix/mobile-refresh-snapshot-race
Oct 17, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/mobile-refresh-snapshot-race

Conversation

@nwparker

@nwparker nwparker commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Refreshing Markdown on a phone now updates the text even when desktop tab snapshots arrive during the request. The editor stays mounted, and phone edits and saves still win over older replies.

What Changed

The previous guard treated every replacement document object as a phone edit. Desktop snapshots also replace that object to mark it stale, so an otherwise successful refresh was silently discarded.

Track a local revision on phone edits and save start/completion instead. Refresh accepts metadata-only changes, preserves newer desktop-change warnings, and keeps the existing read ordering and closed-document guards. Add eight tests through the real reader and edit/save hooks and update three recorded save expectations for the local field.

Why

Object identity rejects harmless metadata updates. Comparing text alone misses an edit followed by undo or a save returning identical text and version. The local revision distinguishes those operations without changing the host protocol or adding another state store.

Linked Issue

Follow-up to #30033 for #30031.

Visual Proof

Same delayed refresh with repeated desktop stale notifications, using the actual mobile reader/editor in a hidden Electron component harness on macOS (RPC replies are simulated).

Before: the read finishes but the old heading remains.

Before refresh fix

After: the new heading appears in the same editor. A newer desktop-change warning remains until a refresh without an intervening snapshot.

After refresh fix

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Three focused passes: 46 tests each, covering metadata snapshots, edit/undo, save/read ordering, same-content saves, failed saves, overlapping reads, disk fallback, closed documents, and tab lifetime.

Full mobile suite (10,846 passed, 6 skipped), mobile typecheck, test typecheck ratchet, mobile lint, formatting, and the changed-code quality gate pass. Full PR CI (.github/workflows/pr.yml, including PR checks passed) and Mobile Checks passed for 8871af76a6b14c19453d23fcb2186b0cf68016f9. The first browser job timed out in two existing HTML preview navigation tests; both cases and the full 30-test HTML preview file passed locally, and the unchanged commit passed the CI retry. No tests were weakened or skipped to obtain that result.

Three rendered refresh passes through the real Refresh control confirmed updated headings and retained editor identity. Also checked active-tab retap makes no read, a failed refresh retains content, a delayed clean reply retains a newer warning, and a quiet refresh clears it. No native iOS/Android device run or live SSH session was performed for this follow-up; shared client logic and simulated remote/folder identifiers are covered.

Review

Three independent sub-agent reviews covered concurrency, integration, and test quality. The integration review found the newer-warning race; it is fixed and verified. No outstanding findings.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The revision remains client state. No host RPC, filesystem, platform, or provider behavior changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and folder workspace impact considered
  • Relevant local lint, typechecks, and tests pass; CI covers the mobile web build and full aggregate gate

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64776f56-0ab0-4d97-8bb4-6db12833774c
📥 Commits

Reviewing files that changed from the base of the PR and between b2419a5 and 8871af7.

📒 Files selected for processing: 7
  • mobile/rpc-foundation/goldens/matrix-session.markdown-save-markdown.savetab-1.json
  • mobile/rpc-foundation/goldens/session-markdown-save-conflict.json
  • mobile/rpc-foundation/goldens/session-markdown-saved.json
  • mobile/src/session/mobile-markdown-refresh-races.test.ts
  • mobile/src/session/mobile-session-document-read-settlement.ts
  • mobile/src/session/mobile-session-route-types.ts
  • mobile/src/session/use-mobile-session-markdown-actions.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The ready Markdown document state now tracks local revisions. Local edits and save transitions increment the revision. Read settlement checks document fields rather than object identity, preserves local revision values, and retains stale status when required. New tests cover refresh and save races. Updated goldens record revised save states and checkpoint references.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8871a

No actionable merge-blocking issue was established; the Markdown refresh change is ready for normal final checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: allowing mobile Markdown refreshes during desktop tab snapshot updates.
Description check Passed The description is complete and relevant. It covers the user impact, implementation, rationale, linked issues, visual proof, testing, review notes, compatibility considerations, and checklist status.
Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 7ad3d49 into main Oct 17, 2026
37 of 39 checks passed
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