Skip to content

Commit 3dd95d7

Browse files
improve(ui): refine Markdown prose presentation (#125242)
* improve(ui): refine Markdown prose styling * improve(ui): polish Markdown prose spacing * improve(ui): normalize nested list rhythm * fix(ui): fill Markdown image fallback width * improve(ui): mute checked task styling * fix(ui): align Markdown list markers * fix(ui): preserve Markdown list rhythm with tasks * improve(ui): clarify Markdown block rhythm * test(ui): update Markdown disclosure geometry * test(ui): match compact Markdown indent * fix(ui): consolidate task list styling * style(ui): format Markdown presentation * test(ui): match Markdown block rhythm * test(ui): enforce uniform Markdown rhythm
1 parent 3d01697 commit 3dd95d7

3 files changed

Lines changed: 130 additions & 84 deletions

File tree

‎ui/src/e2e/chat-markdown-alignment.e2e.test.ts‎

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ suite.define(() => {
105105
if (!collapsedSummary || !jsonCollapse || !jsonSummary || !jsonCopy) {
106106
throw new Error("Missing authored or JSON disclosure markup");
107107
}
108-
const closedChevronStyle = getComputedStyle(collapsedSummary, "::after");
109-
const collapsedSummaryRect = collapsedSummary.getBoundingClientRect();
108+
const closedChevronStyle = getComputedStyle(collapsedSummary, "::before");
110109
const collapsedSummaryTextRect = textRect(
111110
"details:not(.json-collapse):not([open]) > summary",
112111
);
@@ -121,52 +120,44 @@ suite.define(() => {
121120
checkboxRect.y + checkboxRect.height / 2 - (taskTextRect.y + taskTextRect.height / 2),
122121
checkboxSize: checkboxRect.width,
123122
chevronClosedTransform: closedChevronStyle.transform,
124-
chevronInlineEnd: closedChevronStyle.insetInlineEnd,
123+
chevronInlineStart: closedChevronStyle.insetInlineStart,
125124
chevronTransitionDuration: closedChevronStyle.transitionDuration,
126125
chevronWidth: closedChevronStyle.width,
127-
collapsedSummaryPaddingInlineEnd: getComputedStyle(collapsedSummary).paddingInlineEnd,
128-
collapsedSummaryTextRight: collapsedSummaryTextRect.right,
126+
collapsedSummaryPaddingInlineStart:
127+
getComputedStyle(collapsedSummary).paddingInlineStart,
129128
collapsedSummaryTextX: collapsedSummaryTextRect.x,
130-
collapsedSummaryRight: collapsedSummaryRect.right,
129+
detailsRight: details.getBoundingClientRect().right,
131130
detailsX: details.getBoundingClientRect().x,
132131
jsonBorderInlineStartWidth: jsonCollapseStyle.borderInlineStartWidth,
133132
jsonCopyFloat: getComputedStyle(jsonCopy).float,
134133
jsonDetailsX: jsonCollapse.getBoundingClientRect().x,
135134
jsonSummaryDisplay: jsonSummaryStyle.display,
136135
jsonSummaryPaddingInlineStart: jsonSummaryStyle.paddingInlineStart,
137136
numberedTextX: textRect("ol > li").x,
137+
rootRight: root.getBoundingClientRect().right,
138138
rootX: root.getBoundingClientRect().x,
139139
summaryMarginBottom: summaryStyle.marginBottom,
140-
summaryTextX: textRect("details[open] > summary").x,
141140
taskTextX: taskTextRect.x,
142141
};
143142
});
144143

145-
const textStarts = [
146-
geometry.bulletTextX,
147-
geometry.numberedTextX,
148-
geometry.taskTextX,
149-
geometry.summaryTextX,
150-
geometry.collapsedSummaryTextX,
151-
];
144+
const textStarts = [geometry.bulletTextX, geometry.numberedTextX, geometry.taskTextX];
152145
expect(Math.max(...textStarts) - Math.min(...textStarts)).toBeLessThanOrEqual(1);
153146
expect(geometry.checkboxGap).toBeGreaterThanOrEqual(7);
154147
expect(geometry.checkboxGap).toBeLessThanOrEqual(9);
155148
expect(Math.abs(geometry.checkboxLineCenterDelta)).toBeLessThanOrEqual(1);
156149
expect(geometry.checkboxSize).toBe(16);
157-
expect(geometry.bodyTextX - geometry.rootX).toBeGreaterThanOrEqual(28);
158-
expect(geometry.detailsX).toBeGreaterThan(geometry.rootX);
159-
expect(geometry.detailsX).toBeLessThan(geometry.bodyTextX);
150+
expect(geometry.bodyTextX).toBeGreaterThan(geometry.detailsX);
151+
expect(Math.abs(geometry.detailsX - geometry.rootX)).toBeLessThanOrEqual(1);
152+
expect(Math.abs(geometry.detailsRight - geometry.rootRight)).toBeLessThanOrEqual(1);
160153
expect(Number.parseFloat(geometry.borderInlineStartWidth)).toBeGreaterThan(0);
161154
expect(Number.parseFloat(geometry.summaryMarginBottom)).toBeGreaterThan(0);
162155
expect(Number.parseFloat(geometry.chevronWidth)).toBe(16);
163-
expect(Number.parseFloat(geometry.chevronInlineEnd)).toBe(0);
164-
expect(Number.parseFloat(geometry.collapsedSummaryPaddingInlineEnd)).toBeGreaterThanOrEqual(
165-
24,
166-
);
167-
expect(geometry.collapsedSummaryRight - geometry.collapsedSummaryTextRight).toBeGreaterThan(
168-
24,
169-
);
156+
expect(Number.parseFloat(geometry.chevronInlineStart)).toBe(0);
157+
expect(
158+
Number.parseFloat(geometry.collapsedSummaryPaddingInlineStart),
159+
).toBeGreaterThanOrEqual(24);
160+
expect(geometry.collapsedSummaryTextX - geometry.detailsX).toBeGreaterThan(24);
170161
expect(geometry.chevronTransitionDuration).not.toBe("0s");
171162
expect(Math.abs(geometry.jsonDetailsX - geometry.rootX)).toBeLessThanOrEqual(1);
172163
expect(Number.parseFloat(geometry.jsonBorderInlineStartWidth)).toBe(0);
@@ -178,14 +169,14 @@ suite.define(() => {
178169
await collapsedSummary.click();
179170
await expect
180171
.poll(() =>
181-
collapsedSummary.evaluate((summary) => getComputedStyle(summary, "::after").transform),
172+
collapsedSummary.evaluate((summary) => getComputedStyle(summary, "::before").transform),
182173
)
183174
.not.toBe(geometry.chevronClosedTransform);
184175
},
185176
);
186177
});
187178

188-
it("preserves the shared Markdown gutter in RTL transcripts", async () => {
179+
it("preserves Markdown marker and disclosure alignment in RTL transcripts", async () => {
189180
await suite.withPage(
190181
{
191182
colorScheme: "light",
@@ -252,19 +243,27 @@ suite.define(() => {
252243
const unorderedList = root.querySelector("ul:not(.contains-task-list)");
253244
const orderedList = root.querySelector("ol");
254245
const summary = root.querySelector("details:not(.json-collapse) > summary");
255-
if (!checkbox || !task || !unorderedList || !orderedList || !summary) {
246+
const details = root.querySelector("details:not(.json-collapse)");
247+
if (!checkbox || !task || !unorderedList || !orderedList || !summary || !details) {
256248
throw new Error("Missing RTL Markdown geometry");
257249
}
258250
const checkboxRect = checkbox.getBoundingClientRect();
251+
const detailsRect = details.getBoundingClientRect();
252+
const rootRect = root.getBoundingClientRect();
259253
return {
260254
checkboxGap: checkboxRect.left - textRight(".task-list-item"),
261-
chevronInlineEnd: getComputedStyle(summary, "::after").insetInlineEnd,
255+
chevronInlineStart: getComputedStyle(summary, "::before").insetInlineStart,
256+
detailsRight: detailsRect.right,
257+
detailsX: detailsRect.x,
262258
orderedPaddingInlineStart: getComputedStyle(orderedList).paddingInlineStart,
259+
rootRight: rootRect.right,
260+
rootX: rootRect.x,
261+
summaryPaddingInlineStart: getComputedStyle(summary).paddingInlineStart,
262+
summaryTextRight: textRight("details:not(.json-collapse) > summary"),
263263
textStarts: [
264264
textRight("ul:not(.contains-task-list) > li"),
265265
textRight("ol > li"),
266266
textRight(".task-list-item"),
267-
textRight("details:not(.json-collapse) > summary"),
268267
],
269268
unorderedPaddingInlineStart: getComputedStyle(unorderedList).paddingInlineStart,
270269
};
@@ -273,11 +272,15 @@ suite.define(() => {
273272
expect(
274273
Math.max(...geometry.textStarts) - Math.min(...geometry.textStarts),
275274
).toBeLessThanOrEqual(1);
276-
expect(Number.parseFloat(geometry.unorderedPaddingInlineStart)).toBe(32);
277-
expect(Number.parseFloat(geometry.orderedPaddingInlineStart)).toBe(32);
275+
expect(Number.parseFloat(geometry.unorderedPaddingInlineStart)).toBe(24);
276+
expect(Number.parseFloat(geometry.orderedPaddingInlineStart)).toBe(24);
278277
expect(geometry.checkboxGap).toBeGreaterThanOrEqual(7);
279278
expect(geometry.checkboxGap).toBeLessThanOrEqual(9);
280-
expect(Number.parseFloat(geometry.chevronInlineEnd)).toBe(0);
279+
expect(Number.parseFloat(geometry.chevronInlineStart)).toBe(0);
280+
expect(Number.parseFloat(geometry.summaryPaddingInlineStart)).toBeGreaterThanOrEqual(24);
281+
expect(geometry.detailsRight - geometry.summaryTextRight).toBeGreaterThan(24);
282+
expect(Math.abs(geometry.detailsX - geometry.rootX)).toBeLessThanOrEqual(1);
283+
expect(Math.abs(geometry.detailsRight - geometry.rootRight)).toBeLessThanOrEqual(1);
281284
},
282285
);
283286
});

‎ui/src/e2e/route-css.e2e.test.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,17 @@ suite.define(() => {
201201
expect(chatMarkdownStyles.tableToCopyGap).toBeGreaterThan(0);
202202
expect(chatMarkdownStyles.taskListToDetailsGap).toBeGreaterThan(0);
203203
expect(chatMarkdownStyles.unorderedToOrderedGap).toBeGreaterThan(0);
204-
expect(chatMarkdownStyles.quoteMargin / chatMarkdownStyles.blockFontSize).toBeCloseTo(
205-
0.75,
206-
2,
207-
);
204+
expect(chatMarkdownStyles.quoteMargin / chatMarkdownStyles.blockFontSize).toBeCloseTo(1, 2);
208205
expect(chatMarkdownStyles.tableCopyMargin / chatMarkdownStyles.blockFontSize).toBeCloseTo(
209-
0.75,
206+
1,
210207
2,
211208
);
212209
expect(chatMarkdownStyles.detailsMargin / chatMarkdownStyles.blockFontSize).toBeCloseTo(
213-
0.75,
210+
1,
214211
2,
215212
);
216213
expect(chatMarkdownStyles.orderedMargin / chatMarkdownStyles.blockFontSize).toBeCloseTo(
217-
0.75,
214+
1,
218215
2,
219216
);
220217
},

0 commit comments

Comments
 (0)