fix(agent-chat): time the live turn instead of its old prompt

Closed
TE
6d ago
+184-13

Leo reported a Session status screenshot reading “Thinking 118h 21m 48s”.

A resumed live turn could retain a prompt from days earlier as its opener, and the working line counted from that prompt. The transcript now uses the active turn_started timestamp, or the active summary's turn.startedAt when the start record is outside the newest page. It preserves that timestamp while older history folds and applies the existing peer clock correction once.

turn_end and turn_result clear the live start and settle the working state. A stale running summary cannot restart an already-ended turn; a summary naming a newer turn can start it normally. Session reset and replay clear the tracked start/end. The existing one-second display tick stops when the live row unmounts or its running state ends, and its effect cleanup clears the interval; this change adds no timer or animation loop.

Validation completed at reviewed head 17a11aa0e29539703b2316e14a2cd95f040ecf2c: 24 focused resumed-start/summary-order/terminal/paused-queue/render tests pass locally. Red-first commits are preserved (d3e0ffbd7ea9b6, ef6e1d8b58fab5, 30d2596f371938). Review (Codex gpt-6-astra xhigh): SHIP at 17a11aa0e29539703b2316e14a2cd95f040ecf2c. Independent review receipt. Exact-head hosted run40519824308 completed SUCCESS at 2026-10-27T14:26:17Z (source17a11aa0, snapshot5e042c1e, tree211fa88e). Its script checks the failing-before/green-after discriminator, lifecycle coverage, typecheck and four real light/dark gallery captures of the same118-hour-oldprompt/current26-secondturn fixture. The completed run's four captures were recovered from job 122243570913, decoded and SHA-256 verified. They are fixture-only images of the same transcript state; no private machine or account content is present.

ThemeBase (118h)Head (26s)
DarkBase dark thinking timerHead dark thinking timer
LightBase light thinking timerHead light thinking timer

Capture source: exact hosted run source 17a11aa0e29539703b2316e14a2cd95f040ecf2c, followed by clean base merge 4dff38df530dfe101300c4791d6373054ff31721 and the current lifecycle repairs; these captures show the earlier timer fixture, rather than a new capture of the final head. SHA-256: base dark abc8edfd3643380ed1ffbe9179a2e52df9cb0a49a9057e3e18aa4cc0d8261fc6, base light a30f9f79d86d2b3a01fd9839a04ca3a71a7958f3e85d008f376459d933c5de78, head dark 9cf7f48f9662b42fe34160c0d07b0917905e3c26811bc87efb5bc2d18bc04440, head light 907ecc9c730675b74ac37591d6bce202dedb9b8a0b320cf7025755ea079bdf.

Overlap reconciled: #24259's current change is token accounting only; its owner disclaimed timer scope. This PR changes only the live timer's data flow and lifecycle.

Final review repair at 74f0d16bbbed6d461ca5e7f548a2dab36a451e51: compact above-answer duration uses the live start; the highest observed live start and turn id survive out-of-order summaries and history rebuilds. Snapshot, Continue In, harness switching, queued-send decisions and Stop use the same live-running predicate. A stale terminal event cannot clear the newer turn's timer, Stop grace, permissions or stream state; matching terminal events clean up normally. The existing authoritative idle/paused session behavior on cached-tail restore is preserved.

The reordered-summary regression fails on reviewed head 4dff38df530dfe101300c4791d6373054ff31721 and passes after repair. The final focused suite passes 25 tests / 72 assertions; formatting, lint, typecheck and prepush checks pass. Review (Astra xhigh): SHIP at 74f0d16bbbed6d461ca5e7f548a2dab36a451e51. The independent final review inspected the complete six-file feature diff and the repair deltas; it did not rerun the supplied checks.

Agent session: agent session