Skip to content

fix(files): bound text preview reads and cancel stalled responses - #785

Merged
devswha merged 8 commits into
devswha:mainfrom
kilhyeonjun:fix/bounded-file-preview-text-20261011
Oct 11, 2026
Merged

devswha merged 8 commits into
devswha:mainfrom
kilhyeonjun:fix/bounded-file-preview-text-20261011

Conversation

@kilhyeonjun

Copy link
Copy Markdown
Contributor

Change

A text-file response that ignores Range could make the viewer read its entire body, and an HTTP error body was displayed as file contents. The viewer now enforces a 256 KiB UTF-8 byte budget locally, rejects error bodies, and aborts stalled or closed previews. Headers and body share a five-second deadline. Partial previews keep their download link and show a translated note.

This is a standalone client-side fix from main: plain text and existing media/server contracts are preserved. Includes ko/ja/zh, changelog, documentation and registered/typechecked synthetic browser coverage.

Validation

  • Generated schema freshness, production build and full typecheck: pass.
  • Full unit suite: 2,509 pass, 50 skip, 0 fail (142.42s); bounded stream/cancel/deadline/UTF-8/range tests and CI registry covered.
  • Actual FileViewer browser: HTTP401 body rejected; oversized HTTP200 ignoring Range and outdated stat capped; UTF-8 retained; stalled headers/body time out; closing aborts the response; subsequent preview recovers.
  • Independent implementation review: GO, no blocking findings.
  • Workflow syntax skipped (actionlint unavailable); no workflow YAML changed. This UI patch does not claim broader Native integration lanes passed. Fork CI requires maintainer approval.

Synthetic mobile screenshot.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bff0f4dd-8c80-458d-9c36-3ef1e961e4d4

📥 Commits

Reviewing files that changed from the base of the PR and between e4d3922 and b1e763d.


📒 Files selected for processing (8)
  • CHANGELOG.md
  • scripts/ci-browser.test.ts
  • src/components/FileViewer.tsx
  • src/lib/filePreviewText.test.ts
  • src/lib/filePreviewText.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts

🚧 Files skipped from review as they are similar to previous changes (4)
  • src/lib/i18n.zh.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • CHANGELOG.md

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



📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Text previews now stay within a 256 KiB limit, including when servers ignore partial-content requests. Oversized files display a notice that only part of the file is shown.
    • HTTP errors no longer expose response bodies. Stalled previews time out, and closing a preview cancels its active request.
    • Added translated partial-file notices in Japanese, Korean, and Simplified Chinese.
  • Tests
    • Expanded browser checks for preview limits, errors, timeouts, cancellation, and successful file loading.

Walkthrough

Text previews now read within a 256 KiB byte limit, reject HTTP errors, and support timeout and abort cancellation. FileViewer reports partial previews using response metadata. Unit and browser QA cover these cases, and browser CI runs the new QA script.

Changes

Text Preview Handling

Layer / File(s) Summary
Bounded preview reading and display
src/lib/filePreviewText.ts, src/components/FileViewer.tsx, src/lib/filePreviewText.test.ts, src/lib/i18n.*.ts, CHANGELOG.md
The preview reader validates responses and range metadata, limits reading, and supports timeout and abort cancellation. FileViewer displays truncation notices based on response metadata, with tests and translations for the behavior.
Browser validation and CI wiring
scripts/file-preview-text-fixture.tsx, scripts/file-preview-text-browser-qa.ts, scripts/ci-browser.sh, scripts/ci-browser.test.ts, tsconfig.tools.json
The browser fixture and QA script exercise error, oversized, delayed, closed, and UTF-8 responses. Browser CI runs the script, and the tool TypeScript configuration includes its entrypoints.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: devswha


Merge Risk: ⚪ Minimal · up to b1e76

Text previews are bounded and cancellable, and the browser checks are wired into CI. No identified issue needs resolution before merge.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 10 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: bounding text preview reads and cancelling stalled responses.
Description check Passed The description includes the required Change and Validation sections. It explains the problem, resulting behavior, test results, UI evidence, and HTTP coverage.
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.

Full details: Docstring Coverage

Explanation

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


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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.

kilhyeonjun and others added 7 commits October 11, 2026 16:12
…exact-budget file whole

A 206 with a known total now shows the specific "Showing the first 256 KB of 1 MB." note; the
generic note is left for a 200 that ignored Range and was cut. A 200 that ends exactly at the
byte budget is no longer reported as truncated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@devswha
devswha merged commit 8f7e6e9 into devswha:main Oct 11, 2026
5 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.

2 participants