"""Temporary runtime probe. Run in an isolated checkout; restore the source afterwards.

Start the real web app, create three completed Codex turns, enable legacy Plan mode,
select GPT-6.1-Sol High, then ask for a 20-step proposed plan (2-3 sentences per step).
Read globalThis.issue24120Probe in the browser while the proposed plan streams.
Every recorded row is an invocation of the full deriveMessagesTimelineRows function.
"""
from pathlib import Path
p = Path('apps/web/src/components/chat/MessagesTimeline.logic.ts')
s = p.read_text()
needle = '}): MessagesTimelineRow[] {\n  const timelineEntries = timelineRowEntries(input.timelineEntries);'
assert s.count(needle) == 1
replacement = '''}): MessagesTimelineRow[] {
  const probe = Reflect.get(globalThis, "issue24120Probe") ?? [];
  probe.push({ at: Date.now(), entries: JSON.stringify(input.timelineEntries) });
  Reflect.set(globalThis, "issue24120Probe", probe);
  const timelineEntries = timelineRowEntries(input.timelineEntries);'''
p.write_text(s.replace(needle, replacement, 1))
