fix(shared): EPUB preview titles keep emoji whole at the name limit #48273
main fromrefs/pull/48273/head·opened View on GitHubProblem#
When a filename emoji crosses the standalone EPUB reader's 300-code-unit limit, the reader keeps half the emoji. The lone UTF-16 high surrogate reaches the chapter iframe's accessibility title.
Deterministic repro on origin/main (a75e74eb48d6bb7b758401bc85a8d24d9c690bfa)
node --input-type=module -e '
import { epubPreviewRequest } from "./packages/shared/src/filePreview.ts";
const hash = new URLSearchParams({ file: "/api/assets/test.epub", name: "a".repeat(299) + "📚" });
const { name } = epubPreviewRequest(new URL("https://app.t3.codes/epub-preview.html#" + hash));
console.log(JSON.stringify({ len: name.length, isWellFormed: name.isWellFormed(), lastCodeUnit: name.charCodeAt(name.length - 1).toString(16) }));
'
Observed: {"len":300,"isWellFormed":false,"lastCodeUnit":"d83d"}. Expected: exactly "a".repeat(299), a well-formed string.
For the workspace flow, write a one-chapter EPUB directly into a ZIP entry named "a".repeat(299) + "📚.epub" using JSZip.file(name, epubBytes). Mount it on a Linux environment host with archivemount -o readonly workspace.zip mount, then open the EPUB from the mounted directory in the mobile workspace file tree. ThreadFilesRouteScreen passes the workspace basename to EpubFilePreview, which builds the standalone reader URL; epubPreviewMain passes the parsed name through OfficeViewer and EpubViewer to iframe[srcdoc].title.
Change#
Keep the existing limit and drop the last code unit only if it is a high surrogate. A complete emoji that fits still survives. This fixes the standalone web reader and its mobile WebView caller at the shared parsing boundary; the inline web and desktop file panels bypass this parser.
Scope#
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification#
- The focused
filePreview.test.tsregression fails on base withAssertionError: expected false to be true // Object.is equalityand passes on head. It also checks that an emoji that fits survives. - Chat attachment names are capped at 255 code units, but the workspace basename is not:
archivemounton Linux exposed a real, readable 306-code-unit EPUB filename. The scenario used the realprojects.listEntries,filesystem.getMetadata, andassets.createUrlRPCs and the production mobilebasenameandepubPreviewUrlhelpers. Chromium opened the generated URL without editing the fragment. Both revisions loaded the EPUB; base hadd83dat the title cutoff, while head had 299acharacters followed by: Sample chapter. vp run check:changedexited 0: format, lint, Knip, 37 package typechecks, and 107 tests passed. Before/after transcript.- Not shown: Native mobile navigation and WebView, desktop shell, assistive-technology speech, or remote/tunnel sessions. The change is in the iframe title attribute, not in the visible layout.
Authored by GPT-6.2 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
00aede9Macroscope's review found this PR approvable — This keeps EPUB preview titles from ending with half an emoji at the name limit. Existing asset validation, length limits, and fallback behavior remain unchanged.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Walkthrough
-
The EPUB preview request now removes a trailing unmatched high surrogate from the truncated name and uses
EPUBif the adjusted name is empty. A regression test covers truncation around an emoji.Changes: EPUB preview name handling
Layer / File(s) Summary Name truncation and regression coverage
packages/shared/src/filePreview.ts,packages/shared/src/filePreview.test.tsThe request removes a trailing unmatched high surrogate and uses EPUBif the adjusted name is empty. Tests check whether an emoji fits within the name limit.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Suggested reviewers:
yash-singh1,iamshadmantaqi
Merge Risk:
Minimal · up to00aed-
This fixes EPUB preview titles that could end in half an emoji at the name limit. It has a narrow blast radius and no identified merge-blocking risk.
Pre-merge checks:
4-
Check name Status Explanation Title check The title "fix(shared): EPUB preview titles keep emoji whole at the name limit" describes the main change: the EPUB preview name truncation no longer splits a surrogate pair at the 300-code-unit limit… Description check The description follows the template well. It has Problem, Change, Scope, and Verification sections. The problem includes expected behavior and a deterministic reproduction. The change explains the fi… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title "fix(shared): EPUB preview titles keep emoji whole at the name limit" describes the main change: the EPUB preview name truncation no longer splits a surrogate pair at the 300-code-unit limit. It follows the conventional commit format and names the affected area (shared package). It is specific and clear, so it passes.
Full details: Description check
-
Explanation
The description follows the template well. It has Problem, Change, Scope, and Verification sections. The problem includes expected behavior and a deterministic reproduction. The change explains the fix and why it sits at the shared parsing boundary. Scope explains why no issue is linked, which the template allows for small obvious fixes. Verification lists the focused regression test, the end-to-end comparison, and the repo check run, and it states what was not checked. The text is long, and the template asks for concise sections, but all required information is present, so the check passes.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 7ca6705
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6a2e3e17-f498-446e-b98c-80abe49350fe
Commits-
Reviewing files that changed from the base of the PR and between 7ca670595c71ff636d84563145f5ce90e7e9e374 and 00aede947a912092e43c35a866b4c3bcc440ced4.
Files selected for processing: 2-
packages/shared/src/filePreview.test.tspackages/shared/src/filePreview.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
-
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes