Skip to content

Wait for chat HTML fences before previewing - #49574

Merged
brennanb2025 merged 5 commits into
mainfrom
fix/chat-html-preview-fences
Nov 26, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
fix/chat-html-preview-fences

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Preview could redraw every time more HTML arrived. Code, Copy, and Wrap stay available as the page arrives. Preview becomes available when the page finishes, even if the reply is still writing below it. If the reply stops early, you can still preview the HTML that arrived.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​207 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171

What Changed

  • Use the displayed Markdown parser’s closing fence to enable Preview for each page.
  • Keep the reader’s selected view and retain plain source for Copy while Preview is showing.

Why

A partial page could trigger repeated whole-page sanitization and syntax highlighting while its code was hidden. Waiting for the closing fence lets the page render once while any later prose continues.

Linked Issue

STA-18540, introduced in #49288.

Visual Proof

Before, Preview could open while the HTML was arriving
After, Code stays visible while the HTML is arriving
After, Preview shows the completed page with prose below it
Saved item HTML in Preview

Testing

  • Windows renderer tests and seeded browser fixtures, including a split closer, cancellation, a reopened reply, raw Copy, and the sandbox
  • Parser regression tests cover nested fences, line endings, and partial closing delimiters
  • Seeded Electron checks covered streaming chat on Linux and saved item Preview on macOS, including raw Copy through clipboard IPC and deferred highlighting after scrolling

Performance

With 10 and 100 appends to a growing page, the previous behavior requested 11 and 101 sanitizations. Both now request zero while the fence is open and one when Preview is selected after closure. Later prose leaves the frame in place, and selecting Preview cancels hidden highlighting.

Risk

Level: Low. Fence detection could mistime the Preview control. A revert restores the previous timing. Preview continues to use the opaque, script-free sandbox and the existing content security policy.

AI Disclosure

Review

Check when Preview becomes available and how Copy behaves while Preview is selected.

Agent skill upstream boundary

  • Not applicable.

Notes

The change is confined to desktop and web Markdown rendering shared by chat and items.

Checklist

  • Focused change with a parser regression test
  • Reviewed the iframe and clipboard paths
  • Included seeded before and after screenshots

@brennanb2025
brennanb2025 marked this pull request as ready for review November 26, 2026 07:43
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds closing-fence detection for HTML code blocks in document Markdown. Native chat combines streaming and growing state, then uses that state and fence status to control HTML preview availability. When preview is unavailable, the Preview option is disabled and an accessible waiting message is shown. The HTML preview sanitizes the current code directly.

Merge Risk: Minimal · up to d978f

Chat HTML Preview now waits for the closing fence, with Code, Copy and Wrap still available. No concrete merge-blocking risk was found. The remaining risk is that fence detection mistimes the Preview control.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Wait for chat HTML fences before previewing" matches the main change. The PR delays Preview for HTML code blocks in chat until the Markdown parser detects the closing fence. The title is sp…
Description check Passed The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (STA-18540), Visual Proof with before and after images, Testing, Performance with measured sanitizati…
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: Title check

Explanation

The title "Wait for chat HTML fences before previewing" matches the main change. The PR delays Preview for HTML code blocks in chat until the Markdown parser detects the closing fence. The title is specific and short, and it names the primary behavior change.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (STA-18540), Visual Proof with before and after images, Testing, Performance with measured sanitization counts, Risk with level Low and a revert note, and Review. Some sections are incomplete. The Linked Issue cites a ticket and a PR number, but the template line 'Fixes #' is replaced with a non-GitHub-closing reference. The AI Disclosure section is blank. The Testing checkboxes are marked as checked only for test types, and the manual-testing and automated-test checkboxes are not all explicitly ticked. The Notes section is generic and the Review section is brief. Overall the description is mostly complete.

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a652b071-89e8-4fb9-a21b-3bf41636d2b5
Commits

Reviewing files that changed from the base of the PR and between ecbe35c and d978f17.

Files selected for processing: 5

  • src/renderer/src/components/comment-markdown/comment-markdown-block-pipeline.tsx
  • src/renderer/src/components/comment-markdown/comment-markdown-code-fence.ts
  • src/renderer/src/components/native-chat/markdown/code/NativeChatCodeBlock.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/plugins/languages/protected-copy-keys.json
Files skipped from review as they are similar to previous changes: 1

  • src/renderer/src/i18n/locales/en.json

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

@brennanb2025
brennanb2025 marked this pull request as draft November 26, 2026 07:53
@brennanb2025
brennanb2025 marked this pull request as ready for review November 26, 2026 10:33
@brennanb2025
brennanb2025 merged commit 4e43dff into main Nov 26, 2026
88 checks passed
nwparker pushed a commit to dbsghdz1/orca that referenced this pull request Nov 26, 2026
stablyai#49637 gave the file explorer one search field for file names and
text. Its 11 strings had no Korean, so the Korean UI showed them in
English: the field's placeholder (and "Search {{path}}" in a sparse
checkout), the Files and Text section headers (and "Files in
{{path}}" and "Text in workspace" in a sparse checkout), Show all,
No results, the row for too many matches, the "Not available here"
row, and the scope popover's line on what search covers. stablyai#49574 also
added a screen reader note for the chat HTML view's disabled Preview
toggle, with no Korean.

Add the 12 keys in en.json's order, using the catalog's existing
wording where it has one: 검색, 파일, 텍스트, 결과 없음, 미리보기,
스파스 체크아웃, "{{value0}}에서 검색" for Search {{value0}}, and
"…개 모두 표시" for Show all.

Fixes stablyai#49908
nwparker pushed a commit that referenced this pull request Nov 26, 2026
…9909)

#49637 gave the file explorer one search field for file names and
text. Its 11 strings had no Korean, so the Korean UI showed them in
English: the field's placeholder (and "Search {{path}}" in a sparse
checkout), the Files and Text section headers (and "Files in
{{path}}" and "Text in workspace" in a sparse checkout), Show all,
No results, the row for too many matches, the "Not available here"
row, and the scope popover's line on what search covers. #49574 also
added a screen reader note for the chat HTML view's disabled Preview
toggle, with no Korean.

Add the 12 keys in en.json's order, using the catalog's existing
wording where it has one: 검색, 파일, 텍스트, 결과 없음, 미리보기,
스파스 체크아웃, "{{value0}}에서 검색" for Search {{value0}}, and
"…개 모두 표시" for Show all.

Fixes #49908
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.

1 participant