Pi extension that shows a live elapsed timer on collapsed thinking blocks.
thinking-timer.ts-- the entire extension, single filepackage.json-- pi package manifest
- Monkey-patches
AssistantMessageComponent.updateContent()(once, guarded by a Symbol) - Listens to
message_updateforthinking_start/thinking_delta/thinking_endstream events - Records start times in a Map, finalizes durations on end
- A 100ms
setIntervalticker updates label Text nodes while thinking is active - State is stored on
globalThisso the patch (which survives/reload) can find fresh state
- The patch must never throw -- all patched code is wrapped in try/catch
- State uses a globalThis key so
/reloadreplaces the state object cleanly - The Symbol-guarded patch persists across reloads (prototype mutation is permanent)
- Labels map stores references to rendered Text components for the ticker to update between re-renders
pi -e ./thinking-timer.tsUse a model with thinking enabled and collapse the thinking block with Ctrl+T.