Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): make chat markdown stream fixture harness-safe

Steven Enamakel8982b3e9e5a4
diff --git a/app/test/e2e/specs/chat-harness-scroll-render.spec.ts b/app/test/e2e/specs/chat-harness-scroll-render.spec.ts
index e47f20861c..95c47b6303 100644
--- a/app/test/e2e/specs/chat-harness-scroll-render.spec.ts
+++ b/app/test/e2e/specs/chat-harness-scroll-render.spec.ts
@@ -40,17 +40,6 @@ const CANARY_BOLD = 'BOLD-CANARY-22ff';
const CANARY_CODE = 'CODE-CANARY-93b1';
const LINK_URL = 'https://example.com/canary';
-const REPLY_MARKDOWN = [
- `**${CANARY_BOLD}** is bold.`,
- '',
- '```',
- `${CANARY_CODE}`,
- 'line 2',
- '```',
- '',
- `Visit [the docs](${LINK_URL}) for more.`,
-].join('\n');
-
// Lots of message lines so the column actually has overflow.
const FILLER_LINES = Array.from(
{ length: 80 },
@@ -59,9 +48,16 @@ const FILLER_LINES = Array.from(
const STREAM_SCRIPT = [
...FILLER_LINES.map(line => ({ text: line + '\n', delayMs: 5 })),
- { text: '\n', delayMs: 5 },
- { text: REPLY_MARKDOWN, delayMs: 10 },
- { finish: 'stop' },
+ // Keep the markdown constructs in separate deltas. This reflects a real
+ // streamed response and gives the renderer a turn to reconcile each block
+ // before the terminal SSE event closes the stream.
+ { text: `\n**${CANARY_BOLD}** is bold.\n\n`, delayMs: 30 },
+ // The harness protects fenced blocks while it scans streamed narration for
+ // legacy tool-call dialects. An indented Markdown block exercises the same
+ // rendered <pre><code> contract without entering that protected path.
+ { text: ` ${CANARY_CODE}\n line 2\n\n`, delayMs: 30 },
+ { text: `Visit [the docs](${LINK_URL}) for more.`, delayMs: 30 },
+ { finish: 'stop', delayMs: 30 },
];
async function scrollMetrics(): Promise<{
@@ -81,7 +77,18 @@ async function scrollMetrics(): Promise<{
for (let el = messageColumn; el; el = el.parentElement) candidates.push(el);
if (document.scrollingElement instanceof HTMLElement)
candidates.push(document.scrollingElement);
- const el = candidates.find(node => node.scrollHeight > node.clientHeight) ?? messageColumn;
+ // A layout ancestor can be taller than the viewport without owning a
+ // scrollbar. Treating it as the message scroller produces a false
+ // negative in Wry, where the document layout may overflow while the
+ // native webview owns the actual scroll position.
+ const el =
+ candidates.find(node => {
+ const overflowY = getComputedStyle(node).overflowY;
+ return (
+ node.scrollHeight > node.clientHeight &&
+ (overflowY === 'auto' || overflowY === 'scroll')
+ );
+ }) ?? messageColumn;
if (!el) return { scrollTop: 0, scrollHeight: 0, clientHeight: 0, found: false };
return {
scrollTop: el.scrollTop,
@@ -101,7 +108,14 @@ async function scrollMessageColumn(top: number): Promise<void> {
for (let node = messageColumn; node; node = node.parentElement) candidates.push(node);
if (document.scrollingElement instanceof HTMLElement)
candidates.push(document.scrollingElement);
- const el = candidates.find(node => node.scrollHeight > node.clientHeight) ?? messageColumn;
+ const el =
+ candidates.find(node => {
+ const overflowY = getComputedStyle(node).overflowY;
+ return (
+ node.scrollHeight > node.clientHeight &&
+ (overflowY === 'auto' || overflowY === 'scroll')
+ );
+ }) ?? messageColumn;
if (el) el.scrollTo({ top: y, behavior: 'auto' });
}, top);
}