Skip to content

Commit 1a8b817

Browse files
committed
user input animation
1 parent 4d4d53d commit 1a8b817

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
44
import { createLogger } from '@sim/logger'
55
import { useParams, useRouter } from 'next/navigation'
6-
import { Skeleton } from '@/components/emcn'
76
import { PanelLeft } from '@/components/emcn/icons'
87
import { getDocumentIcon } from '@/components/icons/document-icons'
98
import { useSession } from '@/lib/auth/auth-client'
@@ -46,23 +45,6 @@ function FileAttachmentPill({ mediaType, filename }: FileAttachmentPillProps) {
4645
)
4746
}
4847

49-
const SKELETON_LINE_COUNT = 4
50-
51-
function ChatSkeleton({ children }: { children: React.ReactNode }) {
52-
return (
53-
<div className='flex h-full flex-col bg-[var(--bg)]'>
54-
<div className='min-h-0 flex-1 overflow-hidden px-6 py-4'>
55-
<div className='mx-auto max-w-[42rem] space-y-[10px] pt-3'>
56-
{Array.from({ length: SKELETON_LINE_COUNT }).map((_, i) => (
57-
<Skeleton key={i} className='h-[16px]' style={{ width: `${120 + (i % 4) * 48}px` }} />
58-
))}
59-
</div>
60-
</div>
61-
<div className='flex-shrink-0 px-[24px] pb-[16px]'>{children}</div>
62-
</div>
63-
)
64-
}
65-
6648
interface HomeProps {
6749
chatId?: string
6850
}
@@ -77,6 +59,8 @@ export function Home({ chatId }: HomeProps = {}) {
7759
const templateRef = useRef<HTMLDivElement>(null)
7860
const baseInputHeightRef = useRef<number | null>(null)
7961

62+
const [isInputEntering, setIsInputEntering] = useState(false)
63+
8064
const createWorkflowFromLandingSeed = useCallback(
8165
async (seed: LandingWorkflowSeed) => {
8266
try {
@@ -150,7 +134,7 @@ export function Home({ chatId }: HomeProps = {}) {
150134

151135
const wasSendingRef = useRef(false)
152136

153-
const { isLoading: isLoadingHistory } = useChatHistory(chatId)
137+
useChatHistory(chatId)
154138
const { mutate: markRead } = useMarkTaskRead(workspaceId)
155139

156140
const [isResourceCollapsed, setIsResourceCollapsed] = useState(true)
@@ -177,7 +161,6 @@ export function Home({ chatId }: HomeProps = {}) {
177161
const {
178162
messages,
179163
isSending,
180-
isReconnecting,
181164
sendMessage,
182165
stopGeneration,
183166
resolvedChatId,
@@ -245,6 +228,11 @@ export function Home({ chatId }: HomeProps = {}) {
245228
(text: string, fileAttachments?: FileAttachmentForApi[], contexts?: ChatContext[]) => {
246229
const trimmed = text.trim()
247230
if (!trimmed && !(fileAttachments && fileAttachments.length > 0)) return
231+
232+
if (initialViewInputRef.current) {
233+
setIsInputEntering(true)
234+
}
235+
248236
sendMessage(trimmed || 'Analyze the attached file(s).', fileAttachments, contexts)
249237
},
250238
[sendMessage]
@@ -339,22 +327,7 @@ export function Home({ chatId }: HomeProps = {}) {
339327
return () => ro.disconnect()
340328
}, [hasMessages])
341329

342-
if (chatId && (isLoadingHistory || isReconnecting)) {
343-
return (
344-
<ChatSkeleton>
345-
<UserInput
346-
onSubmit={handleSubmit}
347-
isSending={isSending}
348-
onStopGeneration={stopGeneration}
349-
isInitialView={false}
350-
userId={session?.user?.id}
351-
onContextAdd={handleContextAdd}
352-
/>
353-
</ChatSkeleton>
354-
)
355-
}
356-
357-
if (!hasMessages) {
330+
if (!hasMessages && !chatId) {
358331
return (
359332
<div className='h-full overflow-y-auto bg-[var(--bg)] [scrollbar-gutter:stable]'>
360333
<div className='flex min-h-full flex-col items-center justify-center px-[24px] pb-[2vh]'>
@@ -451,7 +424,10 @@ export function Home({ chatId }: HomeProps = {}) {
451424
</div>
452425
</div>
453426

454-
<div className='flex-shrink-0 px-[24px] pb-[16px]'>
427+
<div
428+
className={`flex-shrink-0 px-[24px] pb-[16px]${isInputEntering ? ' animate-slide-in-bottom' : ''}`}
429+
onAnimationEnd={isInputEntering ? () => setIsInputEntering(false) : undefined}
430+
>
455431
<div className='mx-auto max-w-[42rem]'>
456432
<QueuedMessages
457433
messageQueue={messageQueue}

apps/sim/tailwind.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ export default {
176176
from: { transform: 'translateX(40px)' },
177177
to: { transform: 'translateX(0)' },
178178
},
179+
'slide-in-bottom': {
180+
from: { opacity: '0', transform: 'translateY(20px)' },
181+
to: { opacity: '1', transform: 'translateY(0)' },
182+
},
179183
},
180184
animation: {
181185
'caret-blink': 'caret-blink 1.25s ease-out infinite',
@@ -188,6 +192,7 @@ export default {
188192
'stream-fade-in-delayed': 'stream-fade-in 300ms ease-out 1.5s forwards',
189193
'thinking-block': 'thinking-block 1.6s ease-in-out infinite',
190194
'slide-in-right': 'slide-in-right 350ms ease-out forwards',
195+
'slide-in-bottom': 'slide-in-bottom 400ms cubic-bezier(0.16, 1, 0.3, 1)',
191196
},
192197
},
193198
},

0 commit comments

Comments
 (0)