Re-entering a running task can surface the current round twice around
the attach window: REST backfill / locally archived messages and the
attach replay both carry the round's opening (decoded ids are freshly
generated, so key-based dedupe is impossible), which visually wedges the
round's user input into the middle of the streaming output. Cut history
at the live stream's first timestamped message - the active round is
sourced from the live stream only.
Two probabilistic duplication vectors (decoded message ids are freshly
generated per decode, so duplicates cannot be deduped by key):
- loadEarlier guarded re-entry with async React state; the auto-prefill
effect and the inverted list's initial onEndReached could both pass the
guard in the same frame and fetch the same cursor page twice. Guard
with a ref (synchronous).
- In cursorless sessions, handleSend archives the previous live round
locally, then the REST fallback seeded a cursor that still covered the
archived rounds, so paging up re-fetched them. Track archived round
count, skip that many when seeding, drop stale seeds, and stop hc
re-seeding once local archives exist.
Review-driven batch on top of the math feature:
- Ask-card custom answer: scroll the card above the keyboard on input
focus (inverted-list scrollToIndex, viewPosition 0).
- Inline math boundaries: closing-$ guard switched to a negated class so
bold-wrapped/operator-adjacent formulas (**$E=mc^2$**, $a$-$b$) and
han-adjacent Chinese phrasing render; CJK/full-width punctuation
excluded from $-content to kill currency false positives.
- Clamp MathJax output size (rule-bomb guard), reject empty $$ blocks,
clamp throttle elapsed against clock steps, and gate O(n^2) slicing in
the inline tokenizer behind a first-char check.
- Streaming perf: stable body root key + content-hash node keys keep
top-level formulas mounted across re-parses; TeX->SVG and parsed-AST
LRU caches; memoized markdown style object.
- Android: scale inline formulas into the fixed line box and drop the
baseline shift (CustomLineHeightSpan overlaps oversized inline views).
- handleSend snapshots the disconnect() return so throttled tail chunks
are archived; effect cleanup also disconnects the newRound client;
failPendingToolCalls replaces message objects so memoized tool cards
observe the status flip.
- Swap @babel/plugin-transform-dynamic-import to the ^7 line (the ^8
line is Babel-8/ESM-only and breaks installs and jest on older Node).
Replaying long conversations emits hundreds of per-chunk state updates,
driving back-to-back commits whose passive-effect flushes keep React's
nested-update counter climbing (Maximum update depth exceeded warning).
Throttle TaskStreamClient.emit with a leading+trailing 50ms window
(flushed on disconnect so terminal states still land), and key the
context-usage effect on primitive values instead of the per-emit
contextUsage object identity.