From 65cf08f3414720414e0535b5f45ba99bc4b998ab Mon Sep 17 00:00:00 2001 From: m4air Date: Wed, 16 Sep 2026 19:04:51 -0700 Subject: [PATCH] test: update reflow tail and generated mobile payload expectations --- .../terminal-webview-payload-hash.test.ts | 4 ++-- .../terminal-search-long-wrapped-line.test.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mobile/src/terminal/terminal-webview-payload-hash.test.ts b/mobile/src/terminal/terminal-webview-payload-hash.test.ts index c8060314e03..3a6001d138b 100644 --- a/mobile/src/terminal/terminal-webview-payload-hash.test.ts +++ b/mobile/src/terminal/terminal-webview-payload-hash.test.ts @@ -6,8 +6,8 @@ import { XTERM_HTML } from './terminal-webview-html' // uncovered region ships silently. A diff here means the emitted WebView source changed — // update these values only when that change is deliberate, and only after checking the // document still runs. Refactors that merely move slice boundaries must leave them alone. -const EXPECTED_SHA256 = '942889f8127b6f61e43eaa1c1273d67fcc62c5f58c7a66a7209348815d050d3d' -const EXPECTED_LENGTH = 732644 +const EXPECTED_SHA256 = 'a10f26ac720c96c14472574b955b30e816667b0a15dfe4e0b0ce11641691506b' +const EXPECTED_LENGTH = 732650 describe('terminal WebView payload', () => { it('composes the expected document', () => { diff --git a/src/renderer/src/components/terminal-search-long-wrapped-line.test.ts b/src/renderer/src/components/terminal-search-long-wrapped-line.test.ts index 28be8b5fc7a..b6494871484 100644 --- a/src/renderer/src/components/terminal-search-long-wrapped-line.test.ts +++ b/src/renderer/src/components/terminal-search-long-wrapped-line.test.ts @@ -32,7 +32,7 @@ import { safeFind } from './terminal-search-safe-find' * anything that is not the decoration error. */ -/** Reaches the ring behind the public buffer API to pin the negative-index state reflow leaves. */ +/** Checks retained rows outside the public buffer bounds. */ type RingBufferProbe = { _core: { buffer: { lines: { _array: unknown[] } } } } @@ -282,15 +282,22 @@ describe('terminal search inside one very long wrapped line', () => { for (let i = 0; i < 20; i++) { await write(terminal, `line ${i}\r\n`) } - // Narrowing a pane reflows the buffer, which leaves the ring holding entries at negative - // indices, so `getLine(-1)` answers with a stale wrapped line instead of undefined. The rewind - // has to stop at row 0 or it walks backwards forever and hangs the renderer. + // Reflow must retain the searchable tail without keeping evicted rows at negative indices. terminal.resize(15, 5) await write(terminal, '') expect(terminal.buffer.active.getLine(0)?.isWrapped).toBe(true) expect( - Object.keys((terminal as unknown as RingBufferProbe)._core.buffer.lines._array) - ).toContain('-1') + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: This real pinned xterm instance uses the CircularList backing array asserted below. + Object.keys((terminal as unknown as RingBufferProbe)._core.buffer.lines._array).filter( + (key) => Number(key) < 0 + ) + ).toEqual([]) + const retainedLines = Array.from({ length: terminal.buffer.active.length }, (_, index) => + terminal.buffer.active.getLine(index)?.translateToString(true) + ) + expect(retainedLines.filter((line) => line?.startsWith('line '))).toEqual( + Array.from({ length: 20 }, (_, index) => `line ${index}`) + ) const startedAt = performance.now() const found = safeFind((term, options) => search.findNext(term, options), NEEDLE, {