Skip to content

Conversation

@Aaronontheweb
Copy link
Owner

Summary

Adds support for independently animated text elements (spinners, timers, etc.) that appear inline in streaming text and can be replaced or removed later. Implements opt-in tracked segment system with caller-provided IDs.

Key Features

  • Caller-provided IDs: Like HTML div IDs, callers choose segment IDs upfront
  • Opt-in tracking: Regular appends remain untracked (zero overhead), explicit tracked appends enable mutation
  • Replace with untracked: Convert tracked segments to static content and free IDs for reuse
  • Animation support: Spinner segments with 6 styles, custom animated segments via IAnimatedTextSegment
  • Message protocol: Interface-based chat messages for clean separation between ViewModel and Page

Implementation

New Types

  • SegmentId - Integer-based value object for segment identifiers
  • ITextSegment - Base interface for all text segments
  • IAnimatedTextSegment - Interface for animated segments with invalidation events
  • StaticTextSegment - Wrapper for static trackable text
  • SpinnerSegment - Animated spinner with 6 styles (Dots, Line, Arrow, Bounce, Box, Circle)

Modified Components

  • StreamingTextNode - Enhanced with tracked segment support
    • AppendTracked(SegmentId, ITextSegment) - Append tracked segment
    • Remove(SegmentId) - Remove tracked segment
    • Replace(SegmentId, ITextSegment, bool keepTracked) - Replace segment

Demo Updates

  • Streaming chat demo refactored to use message protocol
  • Shows inline spinner while waiting for LLM response
  • Spinner replaced with response text when first chunk arrives

Documentation

  • Added comprehensive "Text Composition and Tracked Segments" section to StreamingTextNode docs
  • Reorganized component sidebar into functional categories (Display, Input, Container, Reactive, Utility)
  • Included real-world chat examples and custom animation implementation guide

Testing

  • 19 new tests for tracked segment functionality
  • All 616 existing tests pass
  • Coverage for AppendTracked, Remove, Replace, disposal, animation, mixed content

Implements opt-in tracked segments for StreamingTextNode that enable inline animations (spinners, timers, etc.) with the ability to replace or remove them later.

Key features:
- Caller-provided SegmentId (like HTML div IDs) - no ID tracking needed
- AppendTracked(id, segment) - append tracked segments with known IDs
- Replace(id, segment, keepTracked) - replace with tracked or untracked content
- Remove(id) - remove tracked segments
- ITextSegment, IAnimatedTextSegment, ICompositeTextSegment interfaces
- SpinnerSegment with 6 animation styles (Dots, Line, Arrow, Bounce, Box, Circle)
- StaticTextSegment for trackable static text
- Single ChatOutput stream handles all operations (append, replace, remove)

Updated streaming demo to show inline spinner that appears after "Assistant:" prefix and disappears when first text chunk arrives.

This architecture enables any inline animated element (timers, progress bars, blinks, highlighters) with minimal overhead for untracked content.
Replaces ChatTextSegment struct with clean message protocol using IChatMessage interface and sealed record types. This eliminates optional field checking in favor of pattern matching.

Message types:
- AppendText - regular text with styling
- AppendTrackedSegment - tracked segments that can be mutated
- RemoveTrackedSegment - remove by ID
- ReplaceTrackedSegment - replace with tracked or untracked content

Benefits:
- Self-describing messages (type indicates intent)
- No optional field checking
- Clean pattern matching in Page
- Better separation of concerns
- More extensible for future message types
Added extensive documentation section covering:
- Tracked vs untracked segments
- Caller-provided IDs (like HTML div IDs)
- Static and animated text segments
- SpinnerSegment with 6 animation styles
- Operations: AppendTracked, Remove, Replace
- ID reuse patterns
- Real-world chat example with thinking indicator
- Custom animated segment implementation
- Performance considerations
- Use cases (spinners, timers, progress bars, etc.)

Organized component sidebar into logical categories:
- Display Components
- Input Components
- Container Components
- Reactive Components
- Utility Components

Updated API Reference with tracked segment methods.
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) December 17, 2025 05:57
@Aaronontheweb Aaronontheweb merged commit a96eafe into dev Dec 17, 2025
7 checks passed
@Aaronontheweb Aaronontheweb deleted the feature/inline-animated-text-segments branch December 17, 2025 05:58
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.

2 participants