Skip to content

Conversation

@hawkticehurst
Copy link
Member

@hawkticehurst hawkticehurst commented Jan 14, 2026

Resolves #287175

Adds a smooth blur-to-focus animation effect for new tokens as they stream in during chat responses.

Changes:

  • New chatStreamingAnimation.ts module that tokenizes incoming markdown content and applies staggered animation delays to new characters
  • CSS animation using opacity and blur transitions (0.35s duration with cubic-bezier easing)
  • New chat.streamingTokenAnimation setting (enabled by default) to toggle the feature
  • Respects prefers-reduced-motion for accessibility
  • Handles special elements (links, inline code, math formulas, widgets) as single animated units
  • Skips animation for code blocks, completed responses, and already-rendered content –– this will be revisited in the future
  • Tracks animated content viaWeakMap to avoid re-animating on DOM re-renders
chat-motion.mov

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a visual animation feature that creates a blur-to-focus effect for tokens as they stream into chat responses, enhancing the user experience during live AI responses.

Changes:

  • New streaming token animation module with character-by-character tokenization and staggered animation delays
  • Configuration setting chat.streamingTokenAnimation (default: true) to control the feature
  • CSS animations with accessibility support via prefers-reduced-motion media query

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/constants.ts Adds StreamingTokenAnimation configuration constant
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts Implements dynamic CSS class toggling based on configuration changes
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatMarkdownPart.css Defines blur-to-focus keyframe animation and responsive styles
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatStreamingAnimation.ts Core animation logic including DOM tokenization, node classification, and animation application
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts Integrates streaming animation into markdown rendering pipeline
src/vs/workbench/contrib/chat/browser/chat.contribution.ts Registers user-facing configuration setting

Comment on lines +267 to +293
export function applyStreamingAnimation(
domNode: HTMLElement,
element: IChatResponseViewModel,
enabled: boolean
): void {
if (!enabled || element.isCanceled) {
return;
}

const previouslyAnimatedLength = animatedTextLengths.get(element) ?? 0;
const currentTextLength = domNode.textContent?.length ?? 0;
const isLoadingCompletedResponse = element.isComplete && previouslyAnimatedLength === 0;

if (isLoadingCompletedResponse) {
// Mark as fully animated so we don't re-check on future renders
animatedTextLengths.set(element, currentTextLength);
return;
}

if (currentTextLength <= previouslyAnimatedLength) {
return; // No new content
}

const { newTokens, totalTextLength } = tokenizeChatMarkdownDomForStreaming(domNode, element);
applyStaggeredAnimationDelays(newTokens);
animatedTextLengths.set(element, totalTextLength);
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new streaming animation functionality lacks test coverage. The tokenization logic, node classification, and wrapping behavior in chatStreamingAnimation.ts are testable and should have unit tests, similar to other chat content parts like chatTodoListWidget.test.ts and chatInlineAnchorWidget.test.ts. Consider adding tests for edge cases such as handling elements that span the previously-animated boundary, proper skipping of code blocks, and correct handling of animatable widgets.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roblourens / @justschen what do you think on this one? I'm not familiar with the testing patterns we have for this part of the codebase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably copilot could write some reasonable ones :)

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.

Add streaming token animations to chat

3 participants