feat: add syncing banner and smart scroll behavior for chat thread

Implement two key UX improvements:

1. Syncing banner with visibility tracking:
   - New useSyncingState hook manages syncing state with safety timeout
   - Banner shows when SSE connects/reconnects
   - Auto-hides after 10s to prevent stuck spinner
   - Smart visibility detection to suppress banner when returning from background

2. Smart scroll behavior for chat thread:
   - Only auto-scrolls when user is near bottom (<120px threshold)
   - Shows "X new messages" indicator when user is reading history
   - Smooth scroll to bottom with indicator button
   - Resets state on session change

Files:
- New: useSyncingState hook for syncing state management
- New: SyncingBanner component for non-blocking indicator
- Modified: App.tsx integrates syncing with SSE handling
- Modified: HappyThread implements smart scroll with dynamic autoScroll
- Modified: index.css adds spinner and bounce-in animations
This commit is contained in:
weishu
2025-12-24 14:05:55 +08:00
parent 61ae777c3d
commit 6d401fb9ec
5 changed files with 244 additions and 10 deletions
+33
View File
@@ -195,3 +195,36 @@ html[data-theme="dark"] .shiki span {
.animate-slide-up {
animation: slide-up 0.3s ease-out;
}
/* Syncing spinner animation */
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.animate-spin {
animation: spin 1s linear infinite;
}
/* New messages indicator bounce animation */
@keyframes bounce-in {
0% {
transform: translateX(-50%) scale(0.8);
opacity: 0;
}
50% {
transform: translateX(-50%) scale(1.05);
}
100% {
transform: translateX(-50%) scale(1);
opacity: 1;
}
}
.animate-bounce-in {
animation: bounce-in 0.3s ease-out;
}