Skip to content

Commit 275d1d4

Browse files
committed
fix(copilot): checkpoints, user-input; improvement(code): colors
1 parent f444947 commit 275d1d4

File tree

23 files changed

+460
-748
lines changed

23 files changed

+460
-748
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { Button } from '@/components/emcn'
2+
3+
type CheckpointConfirmationVariant = 'restore' | 'discard'
4+
5+
interface CheckpointConfirmationProps {
6+
/** Confirmation variant - 'restore' for reverting, 'discard' for edit with checkpoint options */
7+
variant: CheckpointConfirmationVariant
8+
/** Whether an action is currently processing */
9+
isProcessing: boolean
10+
/** Callback when cancel is clicked */
11+
onCancel: () => void
12+
/** Callback when revert is clicked */
13+
onRevert: () => void
14+
/** Callback when continue is clicked (only for 'discard' variant) */
15+
onContinue?: () => void
16+
}
17+
18+
/**
19+
* Inline confirmation for checkpoint operations
20+
* Supports two variants:
21+
* - 'restore': Simple revert confirmation with warning
22+
* - 'discard': Edit with checkpoint options (revert or continue without revert)
23+
*/
24+
export function CheckpointConfirmation({
25+
variant,
26+
isProcessing,
27+
onCancel,
28+
onRevert,
29+
onContinue,
30+
}: CheckpointConfirmationProps) {
31+
const isRestoreVariant = variant === 'restore'
32+
33+
return (
34+
<div className='mt-[8px] rounded-[4px] border border-[var(--border)] bg-[var(--surface-4)] p-[10px]'>
35+
<p className='mb-[8px] text-[12px] text-[var(--text-primary)]'>
36+
{isRestoreVariant ? (
37+
<>
38+
Revert to checkpoint? This will restore your workflow to the state saved at this
39+
checkpoint.{' '}
40+
<span className='text-[var(--text-error)]'>This action cannot be undone.</span>
41+
</>
42+
) : (
43+
'Continue from a previous message?'
44+
)}
45+
</p>
46+
<div className='flex gap-[8px]'>
47+
<Button
48+
onClick={onCancel}
49+
variant='active'
50+
size='sm'
51+
className='flex-1'
52+
disabled={isProcessing}
53+
>
54+
Cancel
55+
</Button>
56+
<Button
57+
onClick={onRevert}
58+
variant='destructive'
59+
size='sm'
60+
className='flex-1'
61+
disabled={isProcessing}
62+
>
63+
{isProcessing ? 'Reverting...' : 'Revert'}
64+
</Button>
65+
{!isRestoreVariant && onContinue && (
66+
<Button
67+
onClick={onContinue}
68+
variant='tertiary'
69+
size='sm'
70+
className='flex-1'
71+
disabled={isProcessing}
72+
>
73+
Continue
74+
</Button>
75+
)}
76+
</div>
77+
</div>
78+
)
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './checkpoint-confirmation'

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

Lines changed: 0 additions & 56 deletions
This file was deleted.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/checkpoint-discard-modal/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
export * from './checkpoint-discard-modal'
1+
export * from './checkpoint-confirmation'
22
export * from './file-display'
33
export { CopilotMarkdownRenderer } from './markdown-renderer'
4-
export * from './restore-checkpoint-modal'
54
export * from './smooth-streaming'
65
export * from './thinking-block'
76
export * from './usage-limit-actions'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/restore-checkpoint-modal/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 46 deletions
This file was deleted.

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

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@ import { memo, useEffect, useRef, useState } from 'react'
22
import { cn } from '@/lib/core/utils/cn'
33
import { CopilotMarkdownRenderer } from '../markdown-renderer'
44

5-
/**
6-
* Character animation delay in milliseconds
7-
*/
5+
/** Character animation delay in milliseconds */
86
const CHARACTER_DELAY = 3
97

10-
/**
11-
* Props for the StreamingIndicator component
12-
*/
8+
/** Props for the StreamingIndicator component */
139
interface StreamingIndicatorProps {
1410
/** Optional class name for layout adjustments */
1511
className?: string
1612
}
1713

18-
/**
19-
* StreamingIndicator shows animated dots during message streaming
20-
* Used as a standalone indicator when no content has arrived yet
21-
*
22-
* @param props - Component props
23-
* @returns Animated loading indicator
24-
*/
14+
/** Shows animated dots during message streaming when no content has arrived */
2515
export const StreamingIndicator = memo(({ className }: StreamingIndicatorProps) => (
2616
<div className={cn('flex h-[1.25rem] items-center text-muted-foreground', className)}>
2717
<div className='flex space-x-0.5'>
@@ -34,30 +24,20 @@ export const StreamingIndicator = memo(({ className }: StreamingIndicatorProps)
3424

3525
StreamingIndicator.displayName = 'StreamingIndicator'
3626

37-
/**
38-
* Props for the SmoothStreamingText component
39-
*/
27+
/** Props for the SmoothStreamingText component */
4028
interface SmoothStreamingTextProps {
4129
/** Content to display with streaming animation */
4230
content: string
4331
/** Whether the content is actively streaming */
4432
isStreaming: boolean
4533
}
4634

47-
/**
48-
* SmoothStreamingText component displays text with character-by-character animation
49-
* Creates a smooth streaming effect for AI responses
50-
*
51-
* @param props - Component props
52-
* @returns Streaming text with smooth animation
53-
*/
35+
/** Displays text with character-by-character animation for smooth streaming */
5436
export const SmoothStreamingText = memo(
5537
({ content, isStreaming }: SmoothStreamingTextProps) => {
56-
// Initialize with full content when not streaming to avoid flash on page load
5738
const [displayedContent, setDisplayedContent] = useState(() => (isStreaming ? '' : content))
5839
const contentRef = useRef(content)
5940
const timeoutRef = useRef<NodeJS.Timeout | null>(null)
60-
// Initialize index based on streaming state
6141
const indexRef = useRef(isStreaming ? 0 : content.length)
6242
const isAnimatingRef = useRef(false)
6343

@@ -95,7 +75,6 @@ export const SmoothStreamingText = memo(
9575
}
9676
}
9777
} else {
98-
// Streaming ended - show full content immediately
9978
if (timeoutRef.current) {
10079
clearTimeout(timeoutRef.current)
10180
}
@@ -119,7 +98,6 @@ export const SmoothStreamingText = memo(
11998
)
12099
},
121100
(prevProps, nextProps) => {
122-
// Prevent re-renders during streaming unless content actually changed
123101
return (
124102
prevProps.content === nextProps.content && prevProps.isStreaming === nextProps.isStreaming
125103
)

0 commit comments

Comments
 (0)