fix(chat): contain streaming code block layout (#5760)

This commit is contained in:
Rod Boev authored and t committed 2026-07-09 03:08:19 +00:00
1 parent 862a121b24
commit 837a552746
2 files changed
+24 -1

No files matched your search

+1 -1
View File
@@ -2310,7 +2310,7 @@
.msg-body > h4:first-child,.msg-body > h5:first-child,.msg-body > h6:first-child{margin-top:0;} .msg-body > h4:first-child,.msg-body > h5:first-child,.msg-body > h6:first-child{margin-top:0;}
.msg-body strong{color:var(--strong);font-weight:600;}.msg-body em{color:var(--em);font-style:italic;} .msg-body strong{color:var(--strong);font-weight:600;}.msg-body em{color:var(--em);font-style:italic;}
.msg-body code{font-family:"SF Mono","Fira Code",ui-monospace,monospace;font-size:var(--message-code-font-size);background:var(--code-inline-bg);padding:1px 5px;border-radius:4px;color:var(--code-text);} .msg-body code{font-family:"SF Mono","Fira Code",ui-monospace,monospace;font-size:var(--message-code-font-size);background:var(--code-inline-bg);padding:1px 5px;border-radius:4px;color:var(--code-text);}
.msg-body pre{background:var(--code-bg);border:1px solid var(--border);border-radius:10px;padding:14px 16px;overflow-x:auto;margin:10px 0;} .msg-body pre{background:var(--code-bg);border:1px solid var(--border);border-radius:10px;padding:14px 16px;overflow-x:auto;contain:content;margin:10px 0;}
.msg-body pre code{background:none;padding:0;border-radius:0;color:var(--pre-text);font-size:var(--message-pre-code-font-size);line-height:1.6;} .msg-body pre code{background:none;padding:0;border-radius:0;color:var(--pre-text);font-size:var(--message-pre-code-font-size);line-height:1.6;}
.msg-body pre.md-source-block,.preview-md pre.md-source-block{white-space:pre-wrap;overflow-x:hidden;overflow-wrap:anywhere;} .msg-body pre.md-source-block,.preview-md pre.md-source-block{white-space:pre-wrap;overflow-x:hidden;overflow-wrap:anywhere;}
.msg-body pre.md-source-block code,.preview-md pre.md-source-block code{display:block;white-space:inherit;overflow-wrap:anywhere;word-break:break-word;} .msg-body pre.md-source-block code,.preview-md pre.md-source-block code{display:block;white-space:inherit;overflow-wrap:anywhere;word-break:break-word;}
@@ -0,0 +1,23 @@
from pathlib import Path
import re
REPO = Path(__file__).resolve().parent.parent
STYLE_CSS = (REPO / "static" / "style.css").read_text(encoding="utf-8")
def _base_msg_body_pre_rule() -> str:
match = re.search(r"(^|\n)\s*\.msg-body pre\{([^}]*)\}", STYLE_CSS)
assert match, "base .msg-body pre rule not found in style.css"
return match.group(2)
def test_msg_body_pre_containment_contract():
rule = _base_msg_body_pre_rule()
assert "overflow-x:auto" in rule, ".msg-body pre must keep horizontal scrolling"
assert "contain:content" in rule, ".msg-body pre must add contain: content"
def test_msg_body_pre_avoids_strict_containment():
rule = _base_msg_body_pre_rule()
assert "contain:strict" not in rule, ".msg-body pre must not use contain: strict"