Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Page card: keep the title while the page's frame is away

luishron123fee08097fe38
diff --git a/src/components/app/AppMessage.compact.test.ts b/src/components/app/AppMessage.compact.test.ts
index ec0aa0abb7..601b75321b 100644
--- a/src/components/app/AppMessage.compact.test.ts
+++ b/src/components/app/AppMessage.compact.test.ts
@@ -127,6 +127,14 @@ describe("a bot's page as a compact card", () => {
expect(card().querySelector("[data-page-title]")).toBeNull();
});
+ it("keeps the title and the card's height while the page is loaded again", async () => {
+ await render(row(payload({ height: 120 })));
+ await pageSays(false);
+ await press(card().querySelector<HTMLButtonElement>("[aria-label='Reload app']")!);
+ expect(card().querySelector("[data-page-title]")!.textContent).toBe("Pricing");
+ expect(card().querySelector<HTMLElement>("[data-app-box]")!.style.height).toBe("164px");
+ });
+
it("shows the preview with the title after a while when the page never says", async () => {
await render(row(payload()));
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 1_600)); });
@@ -162,7 +170,7 @@ describe("a bot's page as a compact card", () => {
expect(card().querySelector("[data-page-fade]")).toBeNull();
});
- it("gives the footer the page's icon on a tile, the title and what it is", async () => {
+ it("gives the footer the page's icon, the title and what it is", async () => {
await render(row(payload()));
const footer = card().querySelector<HTMLElement>("[data-page-footer]")!;
expect(footer.className).toContain("min-h-18");
diff --git a/src/components/app/AppMessage.tsx b/src/components/app/AppMessage.tsx
index 2168fc7da6..ef2c3a2dfb 100644
--- a/src/components/app/AppMessage.tsx
+++ b/src/components/app/AppMessage.tsx
@@ -251,7 +251,8 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
const timer = setTimeout(() => setHeading({ key, opens: false }), drawing ? HEADING_DRAWING_MS : HEADING_WAIT_MS);
return () => clearTimeout(timer);
}, [undecided, drawing, frameKey, message.id, rev]);
- const titled = compact && Boolean(current) && opens === false;
+ // The title stays while the frame is away (the pool took its slot), so the card keeps its height.
+ const titled = compact && opens === false;
// The compact card clips the page at its natural size, so it reads as a preview of the real thing.
const previewHeight = height + (titled ? CARD_TITLE_HEIGHT : 0);
const boxHeight = compact ? Math.min(previewHeight, PAGE_PREVIEW_HEIGHT) : height;
@@ -286,7 +287,7 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {
{...(!room ? { onSelection: setSelection } : {})}
/>
) : (
- <AppPlaceholder height={boxHeight} loading={slot.live} open={slot.live ? undefined : reloadNow} />
+ <AppPlaceholder height={boxHeight - (titled ? CARD_TITLE_HEIGHT : 0)} loading={slot.live} open={slot.live ? undefined : reloadNow} />
)}
{undecided && (
<div data-page-settling className="absolute inset-0 bg-composer">