HEL-824: land verified fixes on 4321aeb (small-screen first-press, real-time reading clock)

- 6 modified + handoff JSON per CHANGES-HEL-824.json, all hashes verified against git 4321aeb and package bytes
- rework_browser_check: skip full-text sheet at micro height (<420px design hides the control); migrate stale 返回日子 selector to 结束交谈 · 回到日子
- fresh run evidence: web build 25/25 unit tests, backend 142/142 (py3.12), all four browser checks PASS incl. new compact first-press and 700ms slow-frame sections (slow_frames_new_turn_to_reply_s=2.32s), layout regression 320/390/1024/1600 both themes

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
白栖知
2026-10-24 07:39:26 +08:00
co-authored by multica-agent
parent 4321aebfdc
commit cef8ae5581
38 changed files with 368 additions and 32 deletions
+41 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { anchorOf, chunks, cursorAt, graphemes, groupTurns, pagesOf, type ShownMessage } from '../src/chat/reading';
import { anchorOf, chunks, cursorAt, dwellFor, graphemes, groupTurns, pagesOf, ReadingClock, STALL, type ShownMessage } from '../src/chat/reading';
import { Camera, FACE, springStep } from '../src/stage/camera';
const desk = { width: 900, font: 23, compact: false }, phone = { width: 370, font: 18, compact: false }, squat = { width: 300, font: 16, compact: true };
@@ -62,6 +62,46 @@ describe('reading position survives a re-chunk', () => {
});
});
describe('reading clock (HEL-824: stop, then a new turn at once)', () => {
const turn = (live?: ShownMessage['live']) => pagesOf({ key: 'b', items: [msg('u', 'user', '新轮', { turnId: 'b' }), msg('c', 'companion', LONG, { turnId: 'b', live })] }, phone);
// Frames `gap` ms apart (rAF time, always > 0) until the line is due; returns the wall time it took.
const due = (clock: ReadingClock, gap: number, start = 1000) => { const first = turn()[0]; let t = start; clock.tick(t, first, true); while (!clock.tick(t += gap, first, true)) if (t - start > 60000) return Infinity; return t - start; };
it('your line stays its designed time at any frame rate (100 ms per frame used to stretch 1.4 s to about 14 s)', () => {
const total = dwellFor(turn()[0]);
expect(total).toBe(1400);
for (const gap of [16, 100, 250, 700, 1000]) {
const took = due(new ReadingClock(), gap);
expect(took).toBeGreaterThanOrEqual(total);
expect(took).toBeLessThan(total + gap);
}
});
it('a growing or finished reply never restarts the line on screen', () => {
const clock = new ReadingClock(), seen: number[] = [];
let t = 1000;
for (const live of ['generating', 'generating', undefined] as const) for (let i = 0; i < 40; i++) { clock.tick(t += 16, turn(live)[0], true); seen.push(clock.progress); }
expect(seen.every((p, i) => i === 0 || p >= seen[i - 1])).toBe(true);
expect(clock.progress).toBe(1);
});
it('a new line, review or resume starts fresh; holds and hidden time are not reading', () => {
const clock = new ReadingClock(), [mine, hers] = turn();
clock.tick(1000, mine, true); clock.tick(1350, mine, true);
expect(clock.progress).toBe(.25);
clock.tick(6000, mine, false); // held (hover, selection, open sheet) or paused
expect(clock.progress).toBe(.25);
clock.pause(); clock.tick(61000, mine, true); // back from a hidden page
expect(clock.progress).toBe(.25);
clock.tick(91000, mine, true); // one stalled frame counts at most STALL
expect(clock.dwell).toBe(350 + STALL);
clock.tick(91016, hers, true); // next line: starts from its own first frame
expect(clock.key).toBe(hers.key);
expect(clock.dwell).toBe(16);
clock.tick(91032, hers, true); clock.restart();
expect(clock.progress).toBe(0);
clock.forget(); clock.tick(91048, hers, true);
expect(clock.dwell).toBe(16);
});
});
describe('one room, one camera', () => {
it('starts on the room still and lands exactly on the approved talk composition', () => {
for (const [w, h] of [[1600, 1000], [1024, 768], [390, 844], [320, 568]]) {