Skip to content

perf(chat): batch live thinking rendering and bound timer updates - #1

Closed
RaresKeY wants to merge 2 commits into
devfrom
agent/perf-stream-batching
Closed

perf(chat): batch live thinking rendering and bound timer updates#1
RaresKeY wants to merge 2 commits into
devfrom
agent/perf-stream-batching

Conversation

@RaresKeY

@RaresKeY RaresKeY commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Long reasoning streams repeatedly Markdown-parsed the entire cumulative thinking string and replaced its full innerHTML on every delta, while a requestAnimationFrame loop rewrote the elapsed header at display refresh rate. This patch coalesces live thinking to one plain-text DOM commit per 100 ms, performs one rich Markdown render when the block closes, synchronously flushes/cancels terminal paths, and bounds the timer to 250 ms normally or 1000 ms under reduced motion.

Target branch

  • This PR targets dev, not main. All PRs land in dev; main is curated by the maintainer at each release.

Linked Issue

Fork staging: Issues are disabled on this fork. Rendered Issue body: A01-ISSUE.md.

Upstream publication packet uses Fixes #{{ISSUE_NUMBER}} after creating the focused Issue.

Part of odysseus-dev#4644.

Related to odysseus-dev#5588.

Publication sequence

This is slice 5/5 in the recommended performance publication order: A04 → A05 → A03 → A02 → A01. This branch is independently based on dev; it is not a cumulative stack branch.

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

How to Test

node --check static/js/chat.js
node --test tests/live_thinking_scheduler.test.mjs

python -m pytest -q \
  tests/test_live_thinking_scheduler_js.py \
  tests/test_chat_stream_scope.py \
  tests/test_bg_monitor_stream.py \
  tests/test_markdown_rendering_js.py \
  tests/test_streaming_segmenter_js.py \
  tests/test_strip_think.py \
  tests/test_redos_think_blocks.py \
  tests/test_llm_core_streaming.py

git diff --check e4fa4ae5dd1d709ce4168397bd1d200fec1b2494..HEAD

Prepared results:

  • scheduler: 3 passed
  • focused stream/thinking group: 37 passed, 1 warning
  • JavaScript-area group: 202 passed, 4 skipped
  • deterministic browser run: trailing sentinel exactly once, no page errors, bounded live-body mutation activity
  • manual running-app huge-conversation check: no progressive lag
  • final integrated sanity on agent/perf-all-integrated-a04-r2: scheduler 3/3, focused union 25/25, git diff --check clean
  • fork staging CI previously passed CI, CodeQL, Secret scan, Workflow security, Container scan, and Trivy; Dependency Review was blocked only because Dependency Graph was disabled on the fork

Manual reviewer check:

  1. Stream a 50k+ character reasoning block.
  2. Confirm live output remains responsive and line breaks remain visible.
  3. Confirm final Markdown renders correctly.
  4. Confirm terminal/session transitions do not apply delayed rendering to a later session.
  5. Optionally repeat under reduced motion.

Visual / UI changes — REQUIRED if you touched anything that renders

This changes behavioral rendering in the existing thinking block but adds no new styling or component.

  • Screenshot or short clip — running-app behavior has been verified; attach a short long-stream clip or trace before marking the upstream PR ready for review.
  • Style match — no CSS variables, colors, fonts, spacing, icons, or component markup are introduced.
  • No new component patterns. The existing thinking block is reused.
  • I am not an LLM agent submitting a bulk PR. Checked by the human publisher.

Screenshots / clips

Attach the final long-stream evidence before moving the upstream PR out of draft.

Risks and rollback

Open PR odysseus-dev#5857 also touches static/js/chat.js but owns an unrelated streaming-TTS error-scope fix. Rebase narrowly if that or other chat work lands first, then rerun the terminal-path regressions. Rollback is the two focused commits; there is no schema or persistence change.

@RaresKeY RaresKeY changed the title perf(chat): batch live thinking DOM updates perf(chat): batch live thinking rendering and bound timer updates Aug 8, 2026
@RaresKeY
RaresKeY force-pushed the agent/perf-stream-batching branch from 2173761 to 24a50fb Compare August 8, 2026 08:26
@RaresKeY RaresKeY closed this Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant