authorgravatar for 206951365+cursor[bot]@users.noreply.github.comcursor[bot] <206951365+cursor[bot]@users.noreply.github.com> 2026-06-23 11:47:26-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-23 11:47:26-07:00
logc6c64918f8c582cc8b12de155d6c9aae12037147
treefd84fba317dac5412b9ea499eac7d01190e8e7c5
parent4abf8b46c591ae2b36aa29598c388100df651411
signature Signed by PGP key B5690EEEBB952194

Reduce ChatMarkdown settings rerenders (#3536)

Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>

1 files changed, 7 insertions(+), 3 deletions(-)

apps/web/src/components/ChatMarkdown.tsx+7-3
......@@ -54,7 +54,7 @@ import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering";
5454import { fnv1a32 } from "../lib/diffRendering";
5555import { LRUCache } from "../lib/lruCache";
5656import { useTheme } from "../hooks/useTheme";
57import { useClientSettings } from "../hooks/useSettings";
57import { getClientSettings } from "../hooks/useSettings";
5858import {
5959 chatMarkdownClipboardPayload,
6060 serializeTableElementToCsv,
......@@ -293,10 +293,14 @@ function getHighlighterPromise(language: string): Promise<DiffsHighlighter> {
293293 return promise;
294294}
295295
296function readInitialWordWrapSetting(): boolean {
297 return getClientSettings().wordWrap;
298}
299
296300function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
297301 const containerRef = useRef<HTMLDivElement | null>(null);
298302 const tableRef = useRef<HTMLTableElement | null>(null);
299 const [expanded, setExpanded] = useState(useClientSettings((settings) => settings.wordWrap));
303 const [expanded, setExpanded] = useState(readInitialWordWrapSetting);
300304 const [copied, setCopied] = useState(false);
301305 const copiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
302306 const expandLabel = expanded ? "Collapse table cells" : "Expand table cells";
......@@ -526,7 +530,7 @@ function MarkdownCodeBlock({
526530 children: ReactNode;
527531}) {
528532 const [copied, setCopied] = useState(false);
529 const [wrapped, setWrapped] = useState(useClientSettings((settings) => settings.wordWrap));
533 const [wrapped, setWrapped] = useState(readInitialWordWrapSetting);
530534 const copiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
531535 const wrapLabel = wrapped ? "Disable line wrap" : "Wrap lines";
532536 const copyLabel = copied ? "Copied" : "Copy code";