@devries-cameron20 / t3code-1 / commits / 2a8ec9c8e1
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): single-digit numbered lists no longer clip in wide fonts (#23573)

Julius Marminge committed Nov 11, 2026 at 15:34 UTC 2a8ec9c8e1bb5aa7205166ed0008cf720e7f9449
3 files changed +56 -9
apps/web/src/appearanceFonts.browser.test.ts
+36
@@ -52,4 +52,40 @@ describe("applyAppearanceFontVariables", () => {
52 else root.setAttribute("style", style);
53 }
54 });
55 +
56 + it("widens the numbered-list gutter only when the interface font's marker would clip", () => {
57 + const root = document.documentElement;
58 + const style = root.getAttribute("style");
59 + const gutter = (sans: string) => {
60 + applyAppearanceFontVariables(root, {
61 + sans,
62 + code: "",
63 + composer: "",
64 + sizeInterface: 16,
65 + sizePrompt: 14,
66 + sizeCode: 13,
67 + smoothing: true,
68 + separate: false,
69 + });
70 + const markdown = document.createElement("div");
71 + markdown.className = "chat-markdown";
72 + markdown.style.fontSize = "14px";
73 + const list = document.createElement("ol");
74 + markdown.append(list);
75 + document.body.append(markdown);
76 + try {
77 + return Number.parseFloat(getComputedStyle(list).paddingInlineStart);
78 + } finally {
79 + markdown.remove();
80 + }
81 + };
82 + try {
83 + // `0. ` in a 14px monospace font is about 25px, past the 20px default.
84 + expect(gutter("monospace")).toBeGreaterThan(24);
85 + expect(gutter("sans-serif")).toBe(20);
86 + } finally {
87 + if (style === null) root.removeAttribute("style");
88 + else root.setAttribute("style", style);
89 + }
90 + });
91 });
apps/web/src/appearanceFonts.ts
+16 -3
@@ -88,6 +88,16 @@ export function applyAppearanceFontVariables(
88 }
89 }
90
91 + const markerWidth = probeWidth(
92 + appearanceFontStack(preferences.sans, DEFAULT_SANS_FONT_STACK),
93 + LIST_MARKER_PROBE_TEXT,
94 + );
95 + if (markerWidth === null) {
96 + root.style.removeProperty("--list-marker-sans");
97 + } else {
98 + root.style.setProperty("--list-marker-sans", `${(markerWidth / PROBE_FONT_SIZE).toFixed(3)}em`);
99 + }
100 +
101 root.style.fontSize = `${clampInterfaceFontSize(preferences.sizeInterface)}px`;
102 root.style.setProperty(
103 "--font-size-prompt",
@@ -127,15 +137,18 @@ function clampCodeFontSize(value: number): number {
137 }
138
139 const FONT_PROBE_TEXT = "mmmmmmmmMMWli1O0@# fjord";
140 +// The widest single-digit `ol` marker; CSS can't measure it to size the list gutter.
141 +const LIST_MARKER_PROBE_TEXT = "0. ";
142 +const PROBE_FONT_SIZE = 16;
143 let fontProbeContext: CanvasRenderingContext2D | null | undefined;
144
132 -function probeWidth(fontList: string): number | null {
145 +function probeWidth(fontList: string, text = FONT_PROBE_TEXT): number | null {
146 if (fontProbeContext === undefined) {
147 fontProbeContext = document.createElement("canvas").getContext("2d");
148 }
149 if (fontProbeContext === null) return null;
137 - fontProbeContext.font = `16px ${fontList}`;
138 - return fontProbeContext.measureText(FONT_PROBE_TEXT).width;
150 + fontProbeContext.font = `${PROBE_FONT_SIZE}px ${fontList}`;
151 + return fontProbeContext.measureText(text).width;
152 }
153
154 /** Probes canvas metrics because document.fonts.check() accepts uninstalled families. */
apps/web/src/index.css
+4 -6
@@ -1933,13 +1933,11 @@ code {
1933 list-style-type: disc;
1934 }
1935
1936 -/* --list-gutter defaults to the same 1.25rem as .chat-markdown ul, but
1937 - ChatMarkdown's `ol` renderer widens it (via inline style) for lists whose
1938 - widest marker has multiple characters so it isn't clipped by list-style-position:
1939 - outside painting the marker past the padding box. Reset it here too so a
1940 - nested ol without its own widened marker doesn't inherit the outer one. */
1936 +/* Outside markers paint past the padding box, so the gutter must fit `0. `,
1937 + measured per font in appearanceFonts. ChatMarkdown widens it inline for
1938 + multi-digit markers; setting it here stops a nested ol inheriting that. */
1939 :is(.chat-markdown, .composer-tiptap) ol {
1942 - --list-gutter: 1.25rem;
1940 + --list-gutter: max(1.25rem, var(--list-marker-sans, 0px));
1941 padding-inline-start: var(--list-gutter, 1.25rem);
1942 list-style-type: decimal;
1943 }