Skip to content

fix(web): prevent task checkboxes from overwriting large Markdown files - #6304

Open
yaacovcorcos wants to merge 1 commit into
pingdotgg:mainfrom
yaacovcorcos:agent/prevent-truncated-markdown-save
Open

fix(web): prevent task checkboxes from overwriting large Markdown files#6304
yaacovcorcos wants to merge 1 commit into
pingdotgg:mainfrom
yaacovcorcos:agent/prevent-truncated-markdown-save

Conversation

@yaacovcorcos

@yaacovcorcos yaacovcorcos commented Aug 12, 2026

Copy link
Copy Markdown

What Changed

  • Large Markdown files still open as rendered previews, but their task-list checkboxes are now read-only.
  • The preview also has a defensive guard that refuses task-list updates whenever the file contents are truncated.
  • The existing size warning now says explicitly that the preview is read-only.
  • Regression tests cover both a truncated file larger than the 1 MiB preview limit and an ordinary complete Markdown file.

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

T3 Code fixed large Markdown preview showing an explicit read-only banner and a disabled task checkbox

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, and END-OF-FILE-SENTINEL-MUST-SURVIVE tail 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 passed
  • pnpm --filter @t3tools/web typecheck
  • targeted lint for the three changed files
  • targeted format check for the three changed files
  • git diff --check

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included visual proof for the UI change
  • A video is not applicable; this change removes an unsafe interaction and has no animation

Model: GPT-5. Harness: OpenAI Codex.

Note

Prevent task checkboxes from modifying truncated Markdown files in file preview

  • Adds resolveMarkdownTaskPreviewUpdate in filePreviewMode.ts that returns null for truncated content or no-op changes, replacing direct use of setMarkdownTaskChecked.
  • Disables the onTaskListChange handler in RenderedMarkdownSurface when the file read is truncated, preventing partial overwrites of large files.
  • Updates the truncated file banner copy to "Read-only preview" to signal non-interactivity.

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 onTaskListChange is disabled when the read is truncated. A new resolveMarkdownTaskPreviewUpdate helper 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.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0e4c6bd-89d0-4d0c-abf7-a0af51916c46

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 12, 2026
@yaacovcorcos
yaacovcorcos marked this pull request as ready for review August 12, 2026 11:17
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant