Skip to content

Fix crash when remote peer deletes all content in docs editor#124

Merged
hackerwins merged 1 commit into
mainfrom
fix/remote-delete-cursor-crash
Apr 12, 2026
Merged

Fix crash when remote peer deletes all content in docs editor#124
hackerwins merged 1 commit into
mainfrom
fix/remote-delete-cursor-crash

Conversation

@hackerwins

@hackerwins hackerwins commented Apr 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix "Block not found" error when a remote client selects all and deletes in a collaborative docs session
  • Add Doc.findBlock() (non-throwing block lookup) and EditorAPI.validateCursorPosition() to relocate a stale cursor after remote changes remove the block it references
  • Call validateCursorPosition() in the onRemoteChange handler between refresh() and render()

Test plan

  • Open the same document in two browser tabs
  • In tab B, select all (Ctrl/Cmd+A) and delete
  • Verify tab A does not throw "Block not found" and gracefully shows the updated (empty) document
  • Verify normal collaborative editing still works after the deletion

🤖 Generated with Claude Code

When a remote client selects all and deletes, the local cursor still
references a now-removed block. The formatting toolbar re-renders and
calls getBlockType(), which throws "Block not found". Add
validateCursorPosition() to relocate the cursor to the first available
block after remote changes remove the block it was on.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@hackerwins has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 54 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 54 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd6fd200-c78a-462c-9e76-16df26d4743f

📥 Commits

Reviewing files that changed from the base of the PR and between d50e76e and 5bcd621.

📒 Files selected for processing (3)
  • packages/docs/src/model/document.ts
  • packages/docs/src/view/editor.ts
  • packages/frontend/src/app/docs/docs-view.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remote-delete-cursor-crash

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 and usage tips.

@github-actions

github-actions Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Verification: verify:self

Result: ✅ PASS in 119.2s

Lane Status Duration
sheets:build ✅ pass 13.6s
docs:build ✅ pass 7.9s
verify:fast ✅ pass 59.7s
frontend:build ✅ pass 15.5s
verify:frontend:chunks ✅ pass 0.3s
backend:build ✅ pass 4.8s
cli:build ✅ pass 1.8s
verify:entropy ✅ pass 15.5s

Verification: verify:integration

Result: ✅ PASS

@codecov

codecov Bot commented Apr 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.33333% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/docs/src/model/document.ts 5.55% 17 Missing ⚠️
packages/docs/src/view/editor.ts 0.00% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hackerwins
hackerwins merged commit aa389c9 into main Apr 12, 2026
4 checks passed
@hackerwins
hackerwins deleted the fix/remote-delete-cursor-crash branch April 12, 2026 11:59
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