webviews tests type-check again: the rail's stream test and the New Tab direct-client cast (base web lint red)

Closed
TE
12d ago
+5-4

Base web lint is red: vp check fails with four type errors, three in webviews/test/thread-minimap-stream.test.tsx and one in webviews/test/new-tab-composer-layout.test.tsx. A type-check red stops the checks behind it, so this goes first.

ErrorLineCause
TS4104270countReads(previous.turns): the helper took a mutable T[], but #24058 made MinimapTurns.turns a readonly MinimapTurn[]
TS2769304expect([...large.result.turns]).toEqual(large.fresh.turns): toEqual wants the receiver's mutable type, and got the readonly list
TS2769343the same, with minimapTurns(next.next, "s").turns
TS2749new-tab-composer-layout 186as AcpmuxDirectClient & {…}: the name is bound by destructuring a dynamic import, so only its value is in scope. From #24488 (17444b7e)

Sources: #24058 (this lane's own PR, squashed as 50826464) added both the readonly types and the minimap test; #24488 (17444b7e) added the New Tab cast. The base autofix ea5f81f0 only reformatted the file.

Fix, test-only:

  • countReads takes readonly T[]. It redefines each index in place with Object.defineProperty, which the type doesn't forbid.
  • Both toEqual calls compare two copies.
  • The New Tab test names the class's instance type through a top-level import type { AcpmuxDirectClient as DirectClient } and casts to Pick<DirectClient, "sessionCommands"> & { typed(…) }. (InstanceType<typeof AcpmuxDirectClient> doesn't work: the constructor is private.) The type import is erased, so the module still loads lazily after the test sets up the DOM globals.

No assertion changes and no product code.

Red: base web lint (fast) job 120407319880 at 5ee63d4de6, "Found 4 errors" (the first three were already red in job 120399820048 at 415ee799b4).

The branch also has an empty commit with a Sidebar-Look: no visual change trailer: fast gates fetch the PR head as a shallow cut, so the sidebar check's diff-tree --root lists the whole tree and asks for a trailer on a PR that touches no sidebar file.
Green: this PR's web lint (fast) and react-apps-check.

Agent session: Air-Blue

šŸ¤– Generated with Claude Code

Leo: "Two fast-gate bugs from composer-scroll-2 must be fixed and landed."

Changelog

none

Agent session: huge-blue