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:
@@ -62,6 +62,30 @@ export function dwellFor(page: Page) {
|
||||
return page.message.role === 'user' ? Math.min(3000, Math.max(1400, 900 + n * 60)) : Math.min(8000, Math.max(2400, 1500 + n * 150));
|
||||
}
|
||||
|
||||
// How long the current line has stayed. It counts real time, not frames: busy frames (a new turn's crossfade,
|
||||
// ink, the room) never stretch a stay. One frame counts at most STALL, so a stall (sleep, debugger) is not
|
||||
// reading; a hidden page restarts the count from its return.
|
||||
export const STALL = 1000;
|
||||
export class ReadingClock {
|
||||
key = ''; dwell = 0; total = 0;
|
||||
private last = 0;
|
||||
// True once the line on screen has stayed its time while reading runs. Same key = same line: a growing stream
|
||||
// or a re-render never restarts it.
|
||||
tick(now: number, page: Page | undefined, running: boolean): boolean {
|
||||
const dt = this.last ? Math.min(STALL, Math.max(0, now - this.last)) : 0; this.last = now;
|
||||
if (!page) return false;
|
||||
if (page.key !== this.key) { this.key = page.key; this.dwell = 0; this.total = dwellFor(page); }
|
||||
if (running && this.dwell < this.total) this.dwell = Math.min(this.total, this.dwell + dt);
|
||||
return running && this.dwell >= this.total;
|
||||
}
|
||||
get progress() { return this.total ? this.dwell / this.total : 0; }
|
||||
// You moved or resumed: the line you land on gets its full time.
|
||||
restart() { this.dwell = 0; }
|
||||
forget() { this.key = ''; }
|
||||
// Page hidden: the gap until it is seen again is not reading time.
|
||||
pause() { this.last = 0; }
|
||||
}
|
||||
|
||||
// Reading position as a character offset inside one message, so a re-chunk (resize, keyboard) keeps your place.
|
||||
export interface Anchor { mi: number; offset: number }
|
||||
export function anchorOf(pages: Page[], cursor: number): Anchor | null {
|
||||
|
||||
Reference in New Issue
Block a user