mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 18:22:38 +00:00
* fix(app): cap oversized assistant messages A single assistant message can expand into enough rendered Markdown nodes to crash the renderer. Limit the Markdown input while preserving the complete timeline value and report its full byte size. * fix(app): bound oversized stream processing Cap the render input before paced reveal and defer full-message byte counting until completion. Reuse the existing grapheme boundary policy so capped text never ends in a partial glyph. * fix(app): preserve capped text without segmentation Hermes lacks Intl.Segmenter, while the shared reveal boundary intentionally returns zero without it. Keep that contract and fall back locally to a surrogate-safe 32K prefix.
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { expect, test } from "../support/fixtures";
|
|
import { getUtf8ByteLength } from "../../src/components/assistant-message-render-limit";
|
|
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
|
|
|
test("caps a newline-heavy assistant message before rendering markdown", async ({ page }) => {
|
|
const hiddenTail = "HIDDEN_OVERSIZED_MESSAGE_TAIL";
|
|
const response = `${"x\n".repeat(16_000)}${hiddenTail}`;
|
|
const agent = await seedMockAgentWorkspace({
|
|
repoPrefix: "assistant-message-render-limit-",
|
|
title: "Assistant message render limit",
|
|
initialPrompt: "Render the configured oversized response.",
|
|
featureValues: { mockAssistantResponse: response },
|
|
});
|
|
|
|
try {
|
|
await agent.client.waitForFinish(agent.agentId, 30_000);
|
|
await openAgentRoute(page, agent);
|
|
|
|
const assistantMessage = page.getByTestId("assistant-message").last();
|
|
await expect(assistantMessage).toBeVisible({ timeout: 30_000 });
|
|
await expect(assistantMessage).not.toContainText(hiddenTail);
|
|
|
|
const notice = assistantMessage.getByTestId("assistant-message-capped-notice");
|
|
await expect(notice).toBeVisible();
|
|
await expect(notice).toHaveText(
|
|
`This message was capped (${getUtf8ByteLength(response)} bytes).`,
|
|
);
|
|
await expect(notice).toHaveCSS("font-style", "italic");
|
|
} finally {
|
|
await agent.cleanup();
|
|
}
|
|
});
|