Skip to content

Commit 9058d5d

Browse files
committed
fix(web): HTML render skeletons drop bordered panel outlines
Boxes that only wrap other blocks are no longer part of the outline, so the skeleton shows filled blocks and text bars without thin border edges.
1 parent a2f6d42 commit 9058d5d

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

‎apps/server/src/htmlRender/headlessChrome.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ const MEASURE_EXPRESSION =
163163
"(() => { const root = document.documentElement; return root.scrollHeight > root.clientHeight ? root.scrollHeight : root.getBoundingClientRect().height; })()";
164164

165165
// The page's main blocks in document order, for a client's loading skeleton:
166-
// media and solid shapes, text with its line count, tables with their row
167-
// count, and boxes with their own background or border, whose contents follow.
166+
// media and solid shapes, text with its line count, and tables with their row
167+
// count. Boxes that only wrap other blocks are walked through, not drawn.
168168
// Past the detail budget, remaining blocks are kept whole, and once the outline
169169
// is full, one block of text lines stands in for the rest of the page, so the
170170
// skeleton still reaches the bottom.
@@ -219,14 +219,12 @@ const OUTLINE_EXPRESSION = `(() => {
219219
if (boxes.length >= detail) { if (el.querySelector(media) || (!text && !el.firstElementChild)) add("media", r, 1); else addText(el, s, r); continue; }
220220
if (text) { addText(el, s, r); continue; }
221221
if (el.children.length === 0) { if (filled(s)) add("media", r, 1); continue; }
222-
if (filled(s) && r.height >= 24) add("panel", r, 1);
223222
walk(el, s);
224223
}
225224
};
226225
walk(document.body, getComputedStyle(document.body));
227226
if (full) {
228-
// Panels enclose later blocks, so their bottoms say nothing about what was left out.
229-
const top = Math.max(0, ...boxes.filter((b) => b[0] !== "panel").map((b) => b[2] + b[4]));
227+
const top = Math.max(0, ...boxes.map((b) => b[2] + b[4]));
230228
const root = document.documentElement;
231229
const rest = (root.scrollHeight > root.clientHeight ? root.scrollHeight : root.getBoundingClientRect().height) - top;
232230
if (rest >= 8) boxes.push(["text", 0, top, document.documentElement.clientWidth, rest, Math.max(1, Math.round(rest / 28))]);
@@ -237,7 +235,7 @@ const Outlined = Schema.Struct({
237235
result: Schema.Struct({
238236
value: Schema.Array(
239237
Schema.Tuple([
240-
Schema.Literals(["text", "media", "table", "panel"]),
238+
Schema.Literals(["text", "media", "table"]),
241239
Schema.Finite,
242240
Schema.Finite,
243241
Schema.Finite,

‎apps/web/src/components/chat/HtmlRenderFrame.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ const SKELETON_SECTION_HEIGHT = 264;
189189

190190
const OUTLINE_BOX_CLASS = {
191191
media: "rounded-lg bg-muted-foreground/15",
192-
panel: "rounded-lg border border-muted-foreground/15",
193192
text: "",
194193
table: "",
195194
} as const;

‎packages/shared/src/htmlRender.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe("htmlRenderOutlineBoxes", () => {
273273
const outline = encodeHtmlRenderOutline([
274274
{ kind: "text", x: 0, y: 0, width: 300, height: 40, lines: 2 },
275275
{ kind: "media", x: 0, y: 48, width: 728, height: 300, lines: 1 },
276-
{ kind: "panel", x: 2, y: 2, width: 0, height: 10, lines: 1 },
276+
{ kind: "media", x: 2, y: 2, width: 0, height: 10, lines: 1 },
277277
]);
278278
const outlined = readHtmlRenderReference({
279279
...reference,
@@ -285,7 +285,7 @@ describe("htmlRenderOutlineBoxes", () => {
285285
})!;
286286

287287
it("round-trips through a tool result and stretches to the client's width and height", () => {
288-
// The empty panel is dropped when encoded.
288+
// The empty box is dropped when encoded.
289289
expect(outline).toBe("t0,0,75,10,2;m0,12,182,75,1");
290290
expect(htmlRenderOutlineBoxes(outlined, 728)).toEqual([
291291
{ kind: "text", x: 0, y: 0, width: 300, height: 40, lines: 2 },

‎packages/shared/src/htmlRender.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,24 @@ export function htmlRenderFrameHeight(
144144

145145
/**
146146
* One block of a page's outline: `text` with its line count, a `media` element
147-
* or solid shape, a `table` with its row count, or a `panel` (a box with its
148-
* own background or border) that later blocks may sit inside.
147+
* or solid shape, or a `table` with its row count.
149148
*/
150149
export interface HtmlRenderOutlineBox {
151-
readonly kind: "text" | "media" | "table" | "panel";
150+
readonly kind: "text" | "media" | "table";
152151
readonly x: number;
153152
readonly y: number;
154153
readonly width: number;
155154
readonly height: number;
156155
readonly lines: number;
157156
}
158157

159-
const OUTLINE_KINDS = { t: "text", m: "media", g: "table", p: "panel" } as const;
160-
const OUTLINE_LETTERS = { text: "t", media: "m", table: "g", panel: "p" } as const;
158+
const OUTLINE_KINDS = { t: "text", m: "media", g: "table" } as const;
159+
const OUTLINE_LETTERS = { text: "t", media: "m", table: "g" } as const;
161160
// Coordinates travel in 4px units, which keeps the tool result an agent reads short.
162161
const OUTLINE_UNIT = 4;
163162
export const HTML_RENDER_OUTLINE_MAX_BOXES = 48;
164163
// Sizes and line counts are never zero, so a client never divides by one.
165-
const OUTLINE_BOX = "[tmgp]\\d{1,4},\\d{1,4},[1-9]\\d{0,3},[1-9]\\d{0,3},[1-9]\\d{0,2}";
164+
const OUTLINE_BOX = "[tmg]\\d{1,4},\\d{1,4},[1-9]\\d{0,3},[1-9]\\d{0,3},[1-9]\\d{0,2}";
166165
const OUTLINE_PATTERN = new RegExp(
167166
`^${OUTLINE_BOX}(?:;${OUTLINE_BOX}){0,${HTML_RENDER_OUTLINE_MAX_BOXES - 1}}$`,
168167
);

0 commit comments

Comments
 (0)