Keep the opening of long interviewer captions

Merged
JA
4d ago
+564-37

While Jim's turn revealed, paceInterviewerCaption passed it through captionWindow, which keeps only the most recent whole sentences that fit in 160 characters, so a long question lost its opening sentence until the reveal finished. 3ab26df already keeps a completed turn whole; this extends that to the reveal. The bar already scrolls past max-height: min(40vh, 20rem) (4.5rem in the compact card during the ending wait), so the reveal now renders the whole turn so far and follows the newest words. Whether it follows is a per-turn flag that only the candidate's scrolling changes: scrolling up to reread stops it and scrolling back to the end resumes it, while the bar shrinking, growing taller or reopening under the reveal does not. Candidate captions keep their 160-character window and 12 s timeout.

The bar's last resting position is recorded by each tick and by the scroll listener, and a later position counts as the candidate's scroll unless it is min(recorded, scrollHeight - clientHeight), where a clamp leaves the bar. Each tick checks this before writing, so a scroll whose event is still queued is not written over. Each new turn starts following, so its first tick scrolls a short opening to the top and the separate scrollTop = 0 reset is removed as redundant. docs/avatar-contract.md required the window during the reveal, so its Captions and Checks sections change with the code.

Validation, on Windows (MSYS2 UCRT64) at 7d67d49 plus this commit: node --test tests/browser/captions.test.js passes 47 of 47, and three of those fail on an unmodified tree as shown in #479. node --test --test-name-pattern="Jim" tests/browser/editor-pipeline.test.js runs both Chromium caption tests and passes 2 of 2. ./scripts/test.sh does not run cleanly on this Windows machine: the Rust test build, the Python script suites and one Node loader fail in lanes this change does not touch, and the commentflow, ruff, shfmt and jq lanes are skipped because those tools are not installed. CI on Linux is the full check for this PR.

Left for a follow-up: the comment above captionWindow at web/lib.js:1608 still says the caption bar holds one line, which has not been true since 3ab26df. captionWindow itself was out of scope in #479, since candidate captions still use it.

Screenshots, from headless Chromium on the interview page with the sample problem and the avatar hidden, while a long Jim turn is about 85% revealed.

A turn that fits the bar. Before, the bar shows only the last sentences and the opening question is gone; after, the whole turn so far is shown.
captions-short-before-after

A turn longer than the bar. Before, only the last sentence is left; after, the bar follows the newest words with the "Live CC:" label and the Unclear button pinned at the top, and scrolling up shows the opening question.
captions-long-before-after

Close #479