Owner report (2026-09-25): in the teaching phase a new question arrives collapsed behind the reveal button, but the transcript scrolled up as if it had OPENED — the room it made was the expanded form's height, never shown. Root cause: the expanded state is stale-true from the previous question (nothing resets it when the dock returns to the composer), so the new question's FIRST paint rendered open; the dock measured itself tall and offered that height to the spacer, and the collapse one tick later could never give it back (fold immunity refuses drops while a question pends). Collapsed bar, tall reserve — scroll as-if-opened. Fix (owner-shaped, deliberately minimal): apply the arrival state DURING RENDER, before the first paint (the render-time state adjustment pattern) — revealArrival(wasQuestion) decides how a teach question lands: after the composer → collapsed (the learner reads the teaching first); after ANOTHER question (a queued parallel check) → OPEN — the reading already happened, and the height it already has is the honest height. The paint measures the truth, so the reserve never learns a height that isn't on screen. Probe arrivals are untouched — instant-open at the bottom stays. The old [pendingId] effect keeps only its probe branch. Live-verified on :3001 with a fabricated teach-phase session driven through the real settle/adoption path (zero model calls): composer→teach arrival lands as the 59px bar with the spacer growing 206→211 (+5) and the transcript scrolling only 77px (the new message itself) — the previous behavior jumped the reserve +339px and scrolled 660px; teach-check reveal click still expands (425px) and scrolls to bottom; a queued parallel question arrives open with the reserve unchanged (577→577) and +40px scroll. Pins: tests/reveal-arrival.test.ts — revealArrival(false) = collapsed, revealArrival(true) = open (the owner ruling). 946/946.
21 lines
978 B
TypeScript
21 lines
978 B
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import { revealArrival } from "../components/chat.tsx";
|
|
|
|
/**
|
|
* Teach-question arrival states (owner ruling, scroll-honesty round
|
|
* 2026-09-25). Applied DURING RENDER before the first paint — the bug was
|
|
* the stale expanded=true left by the previous question painting one
|
|
* frame of the open question: the dock measured itself tall, reserved that
|
|
* height permanently (fold immunity refused the give-back), and the
|
|
* transcript scrolled as if the collapsed question had opened.
|
|
*/
|
|
describe("revealArrival — how a teach question lands", () => {
|
|
it("fresh arrival after the composer: collapsed behind the reveal button", () => {
|
|
assert.deepEqual(revealArrival(false), { expanded: false, revealed: false });
|
|
});
|
|
|
|
it("queued behind another question: open — the reading already happened", () => {
|
|
assert.deepEqual(revealArrival(true), { expanded: true, revealed: true });
|
|
});
|
|
}); |