You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): GB18030 RTF files now preview instead of showing no preview - #42827
The web file preview's RTF parser (rtfCodePageLabel in apps/web/src/components/files/extendedDocumentPreview.ts) has no entry for Windows code page 54936 (Simplified Chinese GB18030). It falls back to "windows-54936", which TextDecoder rejects, so an RTF file declaring \ansicpg54936 shows "No preview for this file. This rich text code page is not supported." in the Files panel and in attachment previews. A font-table \cpg54936 uses the same helper and, under \fcharset0, decoded as windows-1252 mojibake (for example, 中文 shown as ÖÐÎÄ).
Change
Mapped 54936 to the WHATWG "gb18030" label in rtfCodePageLabel (apps/web/src/components/files/extendedDocumentPreview.ts).
Added two GB18030 rows to "decodes declared rich text code pages for raw bytes and escaped byte runs" (apps/web/src/components/files/FilePreviewPanel.test.ts): an \ansicpg54936 document covering 2-byte and 4-byte GB18030 sequences plus a \uc2\u20320\'c4\'e3 fallback pair, and a font-table \cpg54936 with \fcharset0 ({\rtf1\ansi{\fonttbl{\f0\fnil\fcharset0\cpg54936 SimSun;}}\f0 \'d6\'d0\'ce\'c4} -> "<p>中文</p>").
Added a real-app scenario (scripts/scenarios/rtf-preview-decodes-gb18030.e2e.ts) that opens a GB18030 RTF file (notes.rtf) via quick-open and asserts the decoded preview text.
Scope
Small one-line fix for an obvious bug, so no issue is needed: it adds the missing standard Windows code-page mapping beside the existing GBK, Big5, and Shift_JIS entries, plus unit and scenario coverage. PR #42776 already fixed the same missing mapping in the server's attachment text extractor; this PR fixes the web preview's own copy of the map.
Verification
Setup: An AI agent captured the Browser-panel screenshots against the T3 Code web dev server on Linux (Node v26.13.1), light theme, 2560x1600 viewport, with fresh isolated data on each commit and one synthetic project containing gb18030-note.rtf ({\rtf1\ansi\ansicpg54936 Quarterly notes: \'d6\'d0\'ce\'c4 \'95\'32\'82\'36 \'82\'35\'8f\'33 \uc2\u20320\'c4\'e3 done\par}).
Steps: Open the project → Files panel → click gb18030-note.rtf → maximize the panel (the after capture also sets reading size to 200%).
f99eceb76da
51398e4712f
The Files panel shows "No preview for this file" and "This rich text code page is not supported."
The Files panel previews the text "Quarterly notes: 中文 𠀀 龦 你 done".
Setup: The repo's scenario tool's own run: 1280x800, fresh isolated app per commit, environment labeled Scenario.
Steps: open thread → Control+P → notes.rtf.
f99eceb76da
51398e4712f
The scenario run shows "No preview for this file" for notes.rtf.
The scenario run previews notes.rtf as "Quarterly notes: 中文 𠀀 龦 你 done".
Not shown as a glyph in one capture: U+20000 (𠀀) renders as an empty box in the Browser-panel after capture only because that capture browser has no font with CJK Extension B glyphs (the page text holds the correct code point); the scenario head capture renders it.
An AI agent ran the focused RTF code-page test in apps/web/src/components/files/FilePreviewPanel.test.ts on Node v26.13.1:
On base (f99eceb76da), the \ansicpg54936 row failed with PreviewError (code: 'rtf-code-page', Test Files 1 failed (1) / Tests 1 failed | 49 skipped (50)).
With the 54936 map line removed and the earlier \ansicpg54936 row commented out so it would not fail first, the font-table \cpg54936 row failed with AssertionError: expected '<p>ÖÐÎÄ</p>' to be '<p>中文</p>' (Test Files 1 failed (1) / Tests 1 failed | 49 skipped (50)).
On head (51398e4712f), the focused test passed in 3 of 3 runs (Test Files 1 passed (1) / Tests 1 passed | 49 skipped (50)), and the whole FilePreviewPanel.test.ts file passed (Test Files 1 passed (1) / Tests 50 passed (50)).
An AI agent ran vp run scenarios:prove scripts/scenarios/rtf-preview-decodes-gb18030.e2e.ts --base f99eceb76da; it exited 0 (EXIT_CODE=0) with verdict "Proven: the scenario fails on base f99eceb76d and passes on head 51398e4712." On base it failed at expect.toHaveText on the preview body with observed: text [] (match count 0).
An AI agent ran vp run check:changed on head (51398e4712f, 3 files since f99eceb76dac); it exited 0 (EXIT_CODE=0: pass for format, lint, knip 1/2, knip 2/2, typecheck (2 packages), test (1 files), and react compiler (1 files); unused patch check skipped: no dependency files changed).
Reviewing files that changed from the base of the PR and between 51398e4 and 6b6b662.
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
No actionable comments were generated in the recent review.
Walkthrough
The RTF preview now maps code page 54936 to gb18030. Unit tests cover escaped-byte and font-specific declarations, and a browser test checks decoded text from a GB18030-encoded RTF.
Changes: GB18030 RTF decoding
Layer / File(s)
Summary
Code-page mapping and preview validation apps/web/src/components/files/extendedDocumentPreview.ts, apps/web/src/components/files/FilePreviewPanel.test.ts, scripts/scenarios/rtf-preview-decodes-gb18030.e2e.ts
Code page 54936 maps to gb18030. Unit tests cover escaped bytes with Unicode fallback and a font-specific declaration. The browser test checks decoded preview text.
GB18030-encoded RTF files should now preview instead of showing "No preview". The change is small and easy to revert, and no merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: GB18030 RTF files now preview instead of showing no preview. It matches the change that maps Windows code page 54936 to the gb18030 label, which the raw summary and ob…
Description check
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the expected behavior and the failing code path. The Change section lists the map ent…
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 names the main change: GB18030 RTF files now preview instead of showing no preview. It matches the change that maps Windows code page 54936 to the gb18030 label, which the raw summary and objectives both describe. It uses the conventional commit form and is specific.
Full details: Description check
Explanation
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the expected behavior and the failing code path. The Change section lists the map entry and tests. The Scope section explains why no issue is needed. The Verification section gives focused test results, scenario results, and before/after screenshots. The template asks for a model and harness note when an agent did the work, and the description includes one (Gemini 4 Neon in T3 Code Nightly).
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Seeded the two exact reported RTF fixtures in a synthetic git project and opened each through Control+P. Both sides used Chromium 156 on Linux, 1280×800, light theme, and fresh databases.
Proven: the scenario fails on base and passes on head. Base rendered font-table text as ÖÐÎÄ and rejected the quarterly notes code page. Head rendered 中文 and opened quarterly notes with the exact expected document text.
Visual limitation: installed browser fonts display boxes for 𠀀 and 龦; the rendered iframe text matches Quarterly notes: 中文 𠀀 龦 你 done exactly.
Not shown:
Visual glyph shapes for 𠀀 and 龦: installed browser fonts display boxes. Their decoded code points were verified in the real preview iframe's exact text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:M30-99 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The web file preview's RTF parser (
rtfCodePageLabelinapps/web/src/components/files/extendedDocumentPreview.ts) has no entry for Windows code page54936(Simplified Chinese GB18030). It falls back to"windows-54936", whichTextDecoderrejects, so an RTF file declaring\ansicpg54936shows"No preview for this file. This rich text code page is not supported."in the Files panel and in attachment previews. A font-table\cpg54936uses the same helper and, under\fcharset0, decoded as windows-1252 mojibake (for example,中文shown asÖÐÎÄ).Change
54936to the WHATWG"gb18030"label inrtfCodePageLabel(apps/web/src/components/files/extendedDocumentPreview.ts)."decodes declared rich text code pages for raw bytes and escaped byte runs"(apps/web/src/components/files/FilePreviewPanel.test.ts): an\ansicpg54936document covering 2-byte and 4-byte GB18030 sequences plus a\uc2\u20320\'c4\'e3fallback pair, and a font-table\cpg54936with\fcharset0({\rtf1\ansi{\fonttbl{\f0\fnil\fcharset0\cpg54936 SimSun;}}\f0 \'d6\'d0\'ce\'c4}->"<p>中文</p>").scripts/scenarios/rtf-preview-decodes-gb18030.e2e.ts) that opens a GB18030 RTF file (notes.rtf) via quick-open and asserts the decoded preview text.Scope
Small one-line fix for an obvious bug, so no issue is needed: it adds the missing standard Windows code-page mapping beside the existing GBK, Big5, and Shift_JIS entries, plus unit and scenario coverage. PR #42776 already fixed the same missing mapping in the server's attachment text extractor; this PR fixes the web preview's own copy of the map.
Verification
Setup: An AI agent captured the Browser-panel screenshots against the T3 Code web dev server on Linux (Node
v26.13.1), light theme, 2560x1600 viewport, with fresh isolated data on each commit and one synthetic project containinggb18030-note.rtf({\rtf1\ansi\ansicpg54936 Quarterly notes: \'d6\'d0\'ce\'c4 \'95\'32\'82\'36 \'82\'35\'8f\'33 \uc2\u20320\'c4\'e3 done\par}).Steps: Open the project → Files panel → click
gb18030-note.rtf→ maximize the panel (the after capture also sets reading size to 200%).f99eceb76da51398e4712fThe Files panel shows "No preview for this file" and "This rich text code page is not supported."
The Files panel previews the text "Quarterly notes: 中文 𠀀 龦 你 done".
Setup: The repo's scenario tool's own run: 1280x800, fresh isolated app per commit, environment labeled Scenario.
Steps: open thread → Control+P → notes.rtf.
f99eceb76da51398e4712fThe scenario run shows "No preview for this file" for notes.rtf.
The scenario run previews notes.rtf as "Quarterly notes: 中文 𠀀 龦 你 done".
Not shown as a glyph in one capture: U+20000 (𠀀) renders as an empty box in the Browser-panel after capture only because that capture browser has no font with CJK Extension B glyphs (the page text holds the correct code point); the scenario head capture renders it.
An AI agent ran the focused RTF code-page test in
apps/web/src/components/files/FilePreviewPanel.test.tson Nodev26.13.1:f99eceb76da), the\ansicpg54936row failed withPreviewError(code: 'rtf-code-page',Test Files 1 failed (1)/Tests 1 failed | 49 skipped (50)).54936map line removed and the earlier\ansicpg54936row commented out so it would not fail first, the font-table\cpg54936row failed withAssertionError: expected '<p>ÖÐÎÄ</p>' to be '<p>中文</p>'(Test Files 1 failed (1)/Tests 1 failed | 49 skipped (50)).51398e4712f), the focused test passed in 3 of 3 runs (Test Files 1 passed (1)/Tests 1 passed | 49 skipped (50)), and the wholeFilePreviewPanel.test.tsfile passed (Test Files 1 passed (1)/Tests 50 passed (50)).An AI agent ran
vp run scenarios:prove scripts/scenarios/rtf-preview-decodes-gb18030.e2e.ts --base f99eceb76da; it exited0(EXIT_CODE=0) with verdict "Proven: the scenario fails on basef99eceb76dand passes on head51398e4712." On base it failed atexpect.toHaveTexton the preview body withobserved: text [] (match count 0).An AI agent ran
vp run check:changedon head (51398e4712f,3 files since f99eceb76dac); it exited0(EXIT_CODE=0:passforformat,lint,knip 1/2,knip 2/2,typecheck (2 packages),test (1 files), andreact compiler (1 files);unused patch check skipped: no dependency files changed).Generated with Gemini 4 Neon in T3 Code Nightly