Repository navigation
Add a word-by-word typewriter reveal for finished AI answers - #36
Conversation
A completed answer appeared all at once, which felt abrupt. Reveal it client-side word by word once it has fully arrived (bounded total reveal time so long answers don't drag), honoring prefers-reduced-motion. This is a presentation-only change: the worker still generates and returns the whole answer in one piece, there is no token streaming from the backend. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10fed59d91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let reduced=false;try{reduced=matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){} | ||
| if(reduced){container.replaceChildren(md(fullText));return} | ||
| const chunks=fullText.split(/(\s+)/).filter(Boolean);const delay=Math.max(8,Math.min(40,900/Math.max(chunks.length,1))); | ||
| let shown="";for(const c of chunks){shown+=c;container.replaceChildren(md(shown));scrollLog();await sleep(delay)}} |
There was a problem hiding this comment.
Prevent a background reveal from scrolling the selected channel
If an answer finishes and the user switches to another channel while this reveal is running, each remaining iteration calls scrollLog() on the global log, repeatedly jumping the newly selected channel to the bottom and preventing the user from scrolling it until the reveal ends. Long answers can take several seconds at the minimum 8 ms per word/space chunk; stop or guard the reveal when its view is no longer active.
Useful? React with 👍 / 👎.
Summary
prefers-reduced-motion(renders instantly if set).Test plan
pytest -q(247 passed, 3 skipped — no backend touched)ruff check --select E9,F63,F7,F82 .node --checkon the extracted script block🤖 Generated with Claude Code