Skip to content

feat(app-ai-native): add message transitions and stream liveness detection#558

Open
XDfield wants to merge 8 commits into
devfrom
feat/diff-jump-to-file-preview-wrap
Open

feat(app-ai-native): add message transitions and stream liveness detection#558
XDfield wants to merge 8 commits into
devfrom
feat/diff-jump-to-file-preview-wrap

Conversation

@XDfield

@XDfield XDfield commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add intelligent message transition system for smoother UI updates
  • Add stream liveness detection with 30s idle timeout and max reconnect guard (5 retries)
  • Fix SSE content disappearing after completion
  • Refactor WeCom notification channels into webhook and bot types
  • Fix typecheck errors across 3 files

Test plan

  • Verify SSE connection stays alive with normal heartbeat (10s intervals)
  • Verify workspace goes unavailable after 5 consecutive stream failures
  • Verify idle stream (no events for 30s) triggers reconnect
  • Verify typecheck passes: bun typecheck

🤖 Generated with CoStrict

DoSun and others added 8 commits June 17, 2026 17:39
…r payload.error

Adjust error handling logic to check payload.message first before falling back to payload.error, improving error message accuracy.

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
…lur handler

Remove redundant working state validation that was checking and aborting operations. Simplifies the blur event handling flow.

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
…dling

- Add toast and language imports for future error notifications
- Improve parts update logic with proper overlap handling and append logic
- Add state regression prevention for completed/error states
- Enhance session.error handling to support both object and string error formats
- Prepare toast notification infrastructure (commented out)

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
…k and bot types

Split WeCom notification channels into two distinct types:
- wecom-webhook: WeCom group bot via webhook (user-managed)
- wecom-bot: WeCom bot via long connection (system-managed)

Changes include:
- Add comprehensive i18n translations for both channel types (en/zh)
- Refactor notification channels UI to handle separate types
- Add WeComBotChannel type and related service methods
- Extend API with generic channel CRUD operations
- Update channel management logic with proper type handling

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
Fix race condition where AI response content disappears after SSE stream completion.

**Root Cause:**
- loadMessages overwrites local data with server data before SSE fully completes
- 150ms reconcile delay was insufficient for backend to finish writing
- No protection for completed local state being replaced by incomplete server data

**Changes:**
1. Enhanced message merge logic in device-session.tsx:
   - Check message and parts completion status before updating
   - Protect running/completed states from being overwritten
   - Preserve local output when server data is incomplete

2. Improved Parts update logic:
   - Prevent completed status from reverting to running
   - Merge existing output when server data lacks content
   - State-based protection for running→completed transitions

3. Extended reconcile delay (device-session-view.tsx):
   - Increased from 150ms to 1000ms to allow backend completion
   - Reduces probability of fetching incomplete data

**Impact:**
- Fixes reported issue of AI responses disappearing after SSE completion
- Provides more robust state synchronization between client and server
- Better handling of timing-sensitive data updates

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
Implement smooth transitions to eliminate visual flickering during message updates.

**Features:**
1. Smart Content Detection:
   - Auto-detects if content actually changed before triggering animations
   - Compares key message fields (content, role, completion status, error)
   - Compares part states (status, output) to avoid unnecessary updates
   - Only applies transitions to genuinely changed content

2. Smooth Transition Effects:
   - Pure fade-in/fadeout without jarring scaling/movements
   - 300ms transition duration for natural feel
   - Conditional rendering: transitions only when needed
   - Performance optimized with CSS transitions

3. Visual Feedback During Updates:
   - Opacity change (0.6) during active updates
   - Prevents layout shifts with height preservation
   - Background highlight for parts being updated
   - Respects prefers-reduced-motion for accessibility

**New Files:**
- message-transition.css: Transition animations (87 lines)
- message-transition.tsx: Components and hooks (189 lines)

**Integration:**
- Wrapped SessionTurn with MessageTransition in message-timeline.tsx
- Added isUpdating() method to query update state
- Automatic transition application based on content changes

**Benefits:**
- Eliminates visual flickering during loadMessages updates
- Reduces unnecessary re-renders for unchanged content
- Provides subtle but effective visual feedback
- Maintains performance with smart detection

Co-Authored-By: claude-sonnet-4-6 <noreply@costrict.ai>
… guard

Add a 30s idle timeout that monitors all incoming events (including
server.heartbeat) to detect half-open SSE connections. On timeout
the stream is aborted and reconnected via the existing retry path.

Also add max-failures guard (5 retries) that sets workspace status
to "unavailable" when exceeded, preventing infinite reconnect loops.

STREAM_MAX_FAILURES = 5
STREAM_ALIVE_TIMEOUT_MS = 30000

Co-Authored-By: Auto <noreply@costrict.ai>
- Fix Message union comparison in device-session.tsx
- Add "robot" to NotificationChannelType icon union in notification-channels-section.tsx
- Fix onEdit ternary assertion scope in notification-channels-section.tsx
- Fix Icon name cast in notification-channels-section.tsx
- Fix Set generic inference in message-transition.tsx

Co-Authored-By: Auto <noreply@costrict.ai>
@XDfield XDfield force-pushed the feat/diff-jump-to-file-preview-wrap branch from 986cd8f to 310b624 Compare June 17, 2026 09:48
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