fix(web): prevent task checkboxes from overwriting large Markdown files - #6304
fix(web): prevent task checkboxes from overwriting large Markdown files#6304yaacovcorcos wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
ApprovabilityVerdict: Approved 56d80e6 Straightforward bug fix that prevents data loss by disabling task checkbox interactions when viewing truncated Markdown files. The change is simple, self-contained, and includes appropriate tests. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Why
The file reader intentionally returns only the first 1 MiB of a large text file and marks that result as truncated. The rendered Markdown path was selected before the general read-only truncated-text path, however, so task-list checkboxes still had an active save handler.
Clicking one of those checkboxes could send the truncated prefix to the whole-file writer. That could replace the complete Markdown file with only its first 1 MiB and discard everything after the preview limit.
This change keeps the useful rendered preview while removing its mutation path. Complete Markdown files behave exactly as before.
UI Changes
The existing warning now begins with “Read-only preview,” and task checkboxes in a truncated Markdown preview no longer accept changes. The layout is unchanged.
Visual proof
This screenshot is from an isolated desktop build of this PR using a synthetic 1,232,144-byte Markdown file. After clicking the visible checkbox, it remained disabled and unchecked. The file also retained its original SHA-256 (
f96f00c1a67f7aa39888fbdacf85f6075e033ed3e6f6946b80fe1710c076559e), byte count, andEND-OF-FILE-SENTINEL-MUST-SURVIVEtail marker.Validation
pnpm exec vp test run apps/web/src/components/files/FilePreviewPanel.test.ts apps/web/src/components/files/fileSaveCoordinator.test.ts apps/web/src/components/files/projectFilesQueryState.test.ts— 12 tests passedpnpm --filter @t3tools/web typecheckgit diff --checkChecklist
Model: GPT-5. Harness: OpenAI Codex.
Note
Prevent task checkboxes from modifying truncated Markdown files in file preview
resolveMarkdownTaskPreviewUpdatein filePreviewMode.ts that returnsnullfor truncated content or no-op changes, replacing direct use ofsetMarkdownTaskChecked.onTaskListChangehandler inRenderedMarkdownSurfacewhen the file read is truncated, preventing partial overwrites of large files.Macroscope summarized 56d80e6.
Note
Medium Risk
Touches the Markdown preview save path that writes project files; a missed truncated guard could still cause data loss, though the change itself is a narrow defensive fix.
Overview
Prevents truncated Markdown previews from saving partial content when task-list checkboxes are toggled.
Rendered Markdown still opens for large files, but
onTaskListChangeis disabled when the read is truncated. A newresolveMarkdownTaskPreviewUpdatehelper also refuses updates for truncated content as a second guard. The size warning now says Read-only preview. Complete Markdown files keep the previous editable checkbox behavior.Reviewed by Cursor Bugbot for commit 56d80e6. Bugbot is set up for automated code reviews on this repo. Configure here.