Skip to content

Commit 3629c4c

Browse files
committed
Fix loading indicators
1 parent 23fdbbf commit 3629c4c

File tree

15 files changed

+80
-63
lines changed

15 files changed

+80
-63
lines changed

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { z } from 'zod'
77
import { getSession } from '@/lib/auth'
88
import { generateChatTitle } from '@/lib/copilot/chat-title'
99
import { getCopilotModel } from '@/lib/copilot/config'
10-
import { COPILOT_MODEL_IDS, COPILOT_REQUEST_MODES } from '@/lib/copilot/models'
1110
import { SIM_AGENT_API_URL_DEFAULT, SIM_AGENT_VERSION } from '@/lib/copilot/constants'
11+
import { COPILOT_MODEL_IDS, COPILOT_REQUEST_MODES } from '@/lib/copilot/models'
1212
import {
1313
authenticateCopilotRequestSessionOnly,
1414
createBadRequestResponse,

apps/sim/app/api/copilot/chat/update-messages/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { createLogger } from '@sim/logger'
44
import { and, eq } from 'drizzle-orm'
55
import { type NextRequest, NextResponse } from 'next/server'
66
import { z } from 'zod'
7+
import { COPILOT_MODES } from '@/lib/copilot/models'
78
import {
89
authenticateCopilotRequestSessionOnly,
910
createInternalServerErrorResponse,
1011
createNotFoundResponse,
1112
createRequestTracker,
1213
createUnauthorizedResponse,
1314
} from '@/lib/copilot/request-helpers'
14-
import { COPILOT_MODES } from '@/lib/copilot/models'
1515

1616
const logger = createLogger('CopilotChatUpdateAPI')
1717

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/smooth-streaming.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import { memo, useEffect, useRef, useState } from 'react'
2+
import { cn } from '@/lib/core/utils/cn'
23
import CopilotMarkdownRenderer from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/markdown-renderer'
34

45
/**
56
* Character animation delay in milliseconds
67
*/
78
const CHARACTER_DELAY = 3
89

10+
/**
11+
* Props for the StreamingIndicator component
12+
*/
13+
interface StreamingIndicatorProps {
14+
/** Optional class name for layout adjustments */
15+
className?: string
16+
}
17+
918
/**
1019
* StreamingIndicator shows animated dots during message streaming
1120
* Used as a standalone indicator when no content has arrived yet
1221
*
22+
* @param props - Component props
1323
* @returns Animated loading indicator
1424
*/
15-
export const StreamingIndicator = memo(() => (
16-
<div className='flex h-[1.25rem] items-center text-muted-foreground'>
25+
export const StreamingIndicator = memo(({ className }: StreamingIndicatorProps) => (
26+
<div className={cn('flex h-[1.25rem] items-center text-muted-foreground', className)}>
1727
<div className='flex space-x-0.5'>
1828
<div className='h-1 w-1 animate-bounce rounded-full bg-muted-foreground [animation-delay:0ms] [animation-duration:1.2s]' />
1929
<div className='h-1 w-1 animate-bounce rounded-full bg-muted-foreground [animation-delay:150ms] [animation-duration:1.2s]' />

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/thinking-block.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ export function ThinkingBlock({
387387
isExpanded ? 'mt-1.5 max-h-[150px] opacity-100' : 'max-h-0 opacity-0'
388388
)}
389389
>
390-
<SmoothThinkingText content={cleanContent} isStreaming={isStreaming && !hasFollowingContent} />
390+
<SmoothThinkingText
391+
content={cleanContent}
392+
isStreaming={isStreaming && !hasFollowingContent}
393+
/>
391394
</div>
392395
</div>
393396
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/copilot-message.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,9 @@ const CopilotMessage: FC<CopilotMessageProps> = memo(
493493
{/* Content blocks in chronological order */}
494494
{memoizedContentBlocks}
495495

496-
{/* Streaming indicator always at bottom during streaming */}
497-
{isStreaming && <StreamingIndicator />}
496+
{isStreaming && (
497+
<StreamingIndicator className={!hasVisibleContent ? 'mt-1' : undefined} />
498+
)}
498499

499500
{message.errorType === 'usage_limit' && (
500501
<div className='flex gap-1.5'>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/hooks/use-checkpoint-management.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,7 @@ export function useCheckpointManagement(
183183
} finally {
184184
setIsProcessingDiscard(false)
185185
}
186-
}, [
187-
messageCheckpoints,
188-
revertToCheckpoint,
189-
message,
190-
messages,
191-
onEditModeChange,
192-
onCancelEdit,
193-
])
186+
}, [messageCheckpoints, revertToCheckpoint, message, messages, onEditModeChange, onCancelEdit])
194187

195188
/**
196189
* Cancels checkpoint discard and clears pending edit

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-context-management.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export function useContextManagement({ message, initialContexts }: UseContextMan
8181
// Check for slash command tokens or mention tokens based on kind
8282
const isSlashCommand = c.kind === 'slash_command'
8383
const prefix = isSlashCommand ? '/' : '@'
84-
const tokenPattern = new RegExp(`(^|\\s)${escapeRegex(prefix)}${escapeRegex(c.label)}(\\s|$)`)
84+
const tokenPattern = new RegExp(
85+
`(^|\\s)${escapeRegex(prefix)}${escapeRegex(c.label)}(\\s|$)`
86+
)
8587
return tokenPattern.test(message)
8688
})
8789
return filtered.length === prev.length ? prev : filtered

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,10 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
735735
variant='outline'
736736
onClick={handleOpenMentionMenuWithAt}
737737
title='Insert @'
738-
className={cn('cursor-pointer rounded-[6px] p-[4.5px]', disabled && 'cursor-not-allowed')}
738+
className={cn(
739+
'cursor-pointer rounded-[6px] p-[4.5px]',
740+
disabled && 'cursor-not-allowed'
741+
)}
739742
>
740743
<AtSign className='h-3 w-3' strokeWidth={1.75} />
741744
</Badge>
@@ -744,7 +747,10 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
744747
variant='outline'
745748
onClick={handleOpenSlashMenu}
746749
title='Insert /'
747-
className={cn('cursor-pointer rounded-[6px] p-[4.5px]', disabled && 'cursor-not-allowed')}
750+
className={cn(
751+
'cursor-pointer rounded-[6px] p-[4.5px]',
752+
disabled && 'cursor-not-allowed'
753+
)}
748754
>
749755
<span className='flex h-3 w-3 items-center justify-center font-medium text-[11px] leading-none'>
750756
/

apps/sim/lib/copilot/api.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { createLogger } from '@sim/logger'
2-
import type {
3-
CopilotMode,
4-
CopilotModelId,
5-
CopilotTransportMode,
6-
} from '@/lib/copilot/models'
2+
import type { CopilotMode, CopilotModelId, CopilotTransportMode } from '@/lib/copilot/models'
73

84
const logger = createLogger('CopilotAPI')
95

apps/sim/lib/copilot/models.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ export type CopilotTransportMode = (typeof COPILOT_TRANSPORT_MODES)[number]
3333

3434
export const COPILOT_REQUEST_MODES = ['ask', 'build', 'plan', 'agent'] as const
3535
export type CopilotRequestMode = (typeof COPILOT_REQUEST_MODES)[number]
36-

0 commit comments

Comments
 (0)