Skip to content

Commit 404367f

Browse files
authored
refactor(tarko-agent-ui): remove redundant motion animations (#1530)
1 parent 4873fb8 commit 404367f

File tree

27 files changed

+211
-563
lines changed

27 files changed

+211
-563
lines changed
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import React from 'react';
2-
import { motion } from 'framer-motion';
32

43
interface LoadingSpinnerProps {
54
size?: number;
65
className?: string;
76
}
87

9-
export const LoadingSpinner: React.FC<LoadingSpinnerProps> = ({
10-
size = 8,
11-
className = 'border-blue-500 border-t-transparent'
12-
}) => (
13-
<motion.div
14-
animate={{ rotate: 360 }}
15-
transition={{ duration: 1, repeat: Infinity, ease: 'linear' }}
16-
className={`w-${size} h-${size} border-2 rounded-full ${className}`}
17-
/>
18-
);
8+
export const LoadingSpinner: React.FC<LoadingSpinnerProps> = ({
9+
size = 8,
10+
className = 'border-blue-500 border-t-transparent',
11+
}) => <div className={`w-${size} h-${size} border-2 rounded-full animate-spin ${className}`} />;

multimodal/tarko/agent-ui/src/sdk/dialog/ConfirmDialog.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { Dialog } from '@headlessui/react';
3-
import { motion } from 'framer-motion';
43
import { FiAlertTriangle, FiX } from 'react-icons/fi';
54

65
interface ConfirmDialogProps {
@@ -73,33 +72,27 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
7372
</div>
7473
</div>
7574

76-
<motion.button
77-
whileHover={{ scale: 1.1 }}
78-
whileTap={{ scale: 0.9 }}
75+
<button
7976
onClick={onClose}
80-
className="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700"
77+
className="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-all hover:scale-110 active:scale-90"
8178
>
8279
<FiX size={18} />
83-
</motion.button>
80+
</button>
8481
</div>
8582

8683
<div className="mt-6 flex justify-end gap-3">
87-
<motion.button
88-
whileHover={{ scale: 1.02 }}
89-
whileTap={{ scale: 0.98 }}
84+
<button
9085
onClick={onClose}
91-
className="px-4 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 rounded-lg text-sm font-medium transition-colors"
86+
className="px-4 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95"
9287
>
9388
{cancelText}
94-
</motion.button>
95-
<motion.button
96-
whileHover={{ scale: 1.02 }}
97-
whileTap={{ scale: 0.98 }}
89+
</button>
90+
<button
9891
onClick={onConfirm}
99-
className={`px-4 py-2 ${typeStyles.confirmButton} rounded-lg text-sm font-medium transition-colors`}
92+
className={`px-4 py-2 ${typeStyles.confirmButton} rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95`}
10093
>
10194
{confirmText}
102-
</motion.button>
95+
</button>
10396
</div>
10497
</Dialog.Panel>
10598
</div>

multimodal/tarko/agent-ui/src/sdk/markdown-renderer/components/Image.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { motion } from 'framer-motion';
32

43
interface ImageProps {
54
src?: string;
@@ -22,13 +21,11 @@ export const InteractiveImage: React.FC<ImageProps> = ({
2221
};
2322

2423
return (
25-
<motion.img
26-
className="max-w-full h-auto my-6 rounded-lg cursor-pointer"
24+
<img
25+
className="max-w-full h-auto my-6 rounded-lg cursor-pointer transition-transform duration-200 hover:scale-[1.01]"
2726
src={src}
2827
alt={alt}
2928
onClick={handleClick}
30-
whileHover={{ scale: 1.01 }}
31-
transition={{ duration: 0.2 }}
3229
/>
3330
);
3431
};

multimodal/tarko/agent-ui/src/standalone/chat/Message/components/ActionButton.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@ export const ActionButton: React.FC<ActionButtonProps> = ({
9797
};
9898

9999
return (
100-
<motion.button
100+
<button
101101
onClick={onClick}
102-
className={`flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-xl hover:scale-[1.01] active:scale-[0.99] border text-left group w-full ${getStatusColorClasses()} ${getHoverColorClasses()}`}
103-
initial={{ opacity: 0 }}
104-
animate={{ opacity: 1 }}
105-
transition={{ duration: 0.5 }}
102+
className={`flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-xl hover:scale-[1.01] active:scale-[0.99] border text-left group w-full transition-all ${getStatusColorClasses()} ${getHoverColorClasses()}`}
106103
>
107104
<div className="flex-shrink-0 w-5 h-5 flex items-center justify-center">{icon}</div>
108105

@@ -144,6 +141,6 @@ export const ActionButton: React.FC<ActionButtonProps> = ({
144141
/>
145142
)}
146143
</div>
147-
</motion.button>
144+
</button>
148145
);
149146
};

multimodal/tarko/agent-ui/src/standalone/chat/Message/components/ReportFileEntry.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { motion } from 'framer-motion';
32
import { FiFileText, FiBookOpen, FiChevronRight } from 'react-icons/fi';
43
import { useSession } from '@/common/hooks/useSession';
54

@@ -28,11 +27,9 @@ export const ReportFileEntry: React.FC<ReportFileEntryProps> = ({ title, timesta
2827
};
2928

3029
return (
31-
<motion.div
32-
whileHover={{ y: -2, backgroundColor: 'rgba(0, 0, 0, 0.01)' }}
33-
whileTap={{ scale: 0.98 }}
30+
<div
3431
onClick={handleClick}
35-
className="mt-3 p-3 bg-white dark:bg-gray-800 rounded-xl border border-gray-100/40 dark:border-gray-700/20 cursor-pointer flex items-center gap-3 group"
32+
className="mt-3 p-3 bg-white dark:bg-gray-800 rounded-xl border border-gray-100/40 dark:border-gray-700/20 cursor-pointer flex items-center gap-3 group transition-all duration-200 hover:-translate-y-0.5 hover:bg-gray-50/50 dark:hover:bg-gray-750/50 active:scale-98"
3633
>
3734
<div className="w-10 h-10 flex-shrink-0 rounded-lg bg-accent-50 dark:bg-accent-900/20 flex items-center justify-center border border-accent-100/40 dark:border-accent-800/30">
3835
<FiBookOpen className="text-accent-600 dark:text-accent-400" size={18} />
@@ -51,6 +48,6 @@ export const ReportFileEntry: React.FC<ReportFileEntryProps> = ({ title, timesta
5148
className="text-gray-400 dark:text-gray-500 opacity-0 group-hover:opacity-100 transition-opacity"
5249
size={16}
5350
/>
54-
</motion.div>
51+
</div>
5552
);
5653
};

multimodal/tarko/agent-ui/src/standalone/chat/Message/components/SkeletonLoader.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { motion } from 'framer-motion';
32

43
interface SkeletonLoaderProps {
54
lines?: number;
@@ -20,24 +19,18 @@ export const SkeletonLoader: React.FC<SkeletonLoaderProps> = ({
2019
)}
2120
<div className="flex-1 space-y-3">
2221
{Array.from({ length: lines }).map((_, index) => (
23-
<motion.div
22+
<div
2423
key={index}
25-
initial={{ opacity: 0, width: '0%' }}
26-
animate={{ opacity: 1, width: '100%' }}
27-
transition={{
28-
delay: index * 0.2,
29-
duration: 0.8,
30-
ease: 'easeOut',
31-
}}
32-
className="space-y-2"
24+
className="space-y-2 animate-in fade-in duration-800"
25+
style={{ animationDelay: `${index * 0.2}s` }}
3326
>
3427
<div
3528
className="h-3 bg-gray-200 dark:bg-gray-700 rounded"
3629
style={{
3730
width: index === lines - 1 ? '75%' : '100%',
3831
}}
3932
/>
40-
</motion.div>
33+
</div>
4134
))}
4235
</div>
4336
</div>
@@ -73,13 +66,7 @@ export const TypewriterLoader: React.FC<TypewriterLoaderProps> = ({
7366
return (
7467
<div className={`font-mono ${className}`}>
7568
{displayText}
76-
<motion.span
77-
animate={{ opacity: [1, 0] }}
78-
transition={{ duration: 0.5, repeat: Infinity, repeatType: 'reverse' }}
79-
className="ml-1"
80-
>
81-
|_
82-
</motion.span>
69+
<span className="ml-1 animate-pulse">|_</span>
8370
</div>
8471
);
8572
};

multimodal/tarko/agent-ui/src/standalone/chat/Message/components/ToggleButton.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { motion } from 'framer-motion';
32
import { FiChevronDown, FiChevronUp } from 'react-icons/fi';
43

54
interface ToggleButtonProps {
@@ -23,13 +22,12 @@ export const ToggleButton: React.FC<ToggleButtonProps> = ({
2322
icon,
2423
children,
2524
}) => (
26-
<motion.button
27-
whileHover={{ x: 3 }}
25+
<button
2826
onClick={onToggle}
29-
className="flex items-center text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 py-1 px-2 mt-1 rounded-lg hover:bg-gray-50/70 dark:hover:bg-gray-700/20 transition-all duration-200"
27+
className="flex items-center text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 py-1 px-2 mt-1 rounded-lg hover:bg-gray-50/70 dark:hover:bg-gray-700/20 transition-all duration-200 hover:translate-x-1"
3028
>
3129
{isExpanded ? <FiChevronUp className="mr-1.5" /> : <FiChevronDown className="mr-1.5" />}
3230
{icon}
3331
{children}
34-
</motion.button>
32+
</button>
3533
);

multimodal/tarko/agent-ui/src/standalone/chat/MessageInput/ChatInput.tsx

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useRef, useEffect } from 'react';
22
import { FiSend, FiRefreshCw, FiImage, FiSquare, FiX } from 'react-icons/fi';
3-
import { motion, AnimatePresence } from 'framer-motion';
3+
import { AnimatePresence, motion } from 'framer-motion';
44
import { ConnectionStatus } from '@/common/types';
55
import { ChatCompletionContentPart } from '@tarko/agent-interface';
66
import { useSession } from '@/common/hooks/useSession';
@@ -409,21 +409,19 @@ export const ChatInput: React.FC<ChatInputProps> = ({
409409
{/* File upload button */}
410410
{showAttachments && (
411411
<div className="absolute left-3 bottom-3 flex items-center gap-2">
412-
<motion.button
413-
whileHover={{ scale: 1.05 }}
414-
whileTap={{ scale: 0.95 }}
412+
<button
415413
type="button"
416414
onClick={handleFileUpload}
417415
disabled={isDisabled || isProcessing}
418-
className={`p-2 rounded-full transition-colors ${
416+
className={`p-2 rounded-full transition-all duration-200 hover:scale-105 active:scale-95 ${
419417
isDisabled || isProcessing
420418
? 'text-gray-300 dark:text-gray-600 cursor-not-allowed'
421419
: 'text-gray-400 hover:text-accent-500 hover:bg-gray-50 dark:hover:bg-gray-700/30 dark:text-gray-400'
422420
}`}
423421
title="Attach image (or paste directly)"
424422
>
425423
<FiImage size={18} />
426-
</motion.button>
424+
</button>
427425

428426
<input
429427
type="file"
@@ -445,11 +443,9 @@ export const ChatInput: React.FC<ChatInputProps> = ({
445443
initial={{ opacity: 0, scale: 0.8 }}
446444
animate={{ opacity: 1, scale: 1 }}
447445
exit={{ opacity: 0, scale: 0.8 }}
448-
whileTap={{ scale: 0.9 }}
449-
whileHover={{ scale: 1.05 }}
450446
type="button"
451447
onClick={onReconnect}
452-
className="absolute right-3 bottom-3 p-2 rounded-full text-gray-500 hover:bg-gray-50 dark:hover:bg-gray-700/30 dark:text-gray-400 transition-all duration-200"
448+
className="absolute right-3 bottom-3 p-2 rounded-full text-gray-500 hover:bg-gray-50 dark:hover:bg-gray-700/30 dark:text-gray-400 transition-all duration-200 hover:scale-105 active:scale-90"
453449
title="Try to reconnect"
454450
>
455451
<FiRefreshCw
@@ -464,16 +460,14 @@ export const ChatInput: React.FC<ChatInputProps> = ({
464460
animate={{ opacity: 1 }}
465461
exit={{ opacity: 0 }}
466462
transition={{ duration: 0.2 }}
467-
whileTap={{ scale: 0.95 }}
468-
whileHover={{ scale: 1.02 }}
469463
type="button"
470464
onClick={handleAbort}
471465
disabled={isAborting}
472-
className={`absolute right-3 bottom-3 w-10 h-10 rounded-full flex items-center justify-center ${
466+
className={`absolute right-3 bottom-3 w-10 h-10 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-105 active:scale-95 ${
473467
isAborting
474468
? 'bg-gradient-to-r from-indigo-100 via-purple-100 to-pink-100 dark:from-indigo-800/30 dark:via-purple-800/30 dark:to-pink-800/30 text-indigo-400 dark:text-indigo-500 cursor-not-allowed border-2 border-indigo-200 dark:border-indigo-700/50'
475469
: 'bg-gradient-to-r from-indigo-50 via-purple-50 to-pink-50 hover:from-indigo-100 hover:via-purple-100 hover:to-pink-100 dark:from-indigo-900/20 dark:via-purple-900/20 dark:to-pink-900/20 dark:hover:from-indigo-900/30 dark:hover:via-purple-900/30 dark:hover:to-pink-900/30 text-indigo-600 dark:text-indigo-400 border-2 border-indigo-200 dark:border-indigo-700/50'
476-
} transition-all duration-200 shadow-sm bg-[length:200%_200%] animate-border-flow`}
470+
} shadow-sm bg-[length:200%_200%] animate-border-flow`}
477471
title="Stop generation"
478472
>
479473
{isAborting ? (
@@ -488,15 +482,13 @@ export const ChatInput: React.FC<ChatInputProps> = ({
488482
initial={{ opacity: 0, scale: 0.8 }}
489483
animate={{ opacity: 1, scale: 1 }}
490484
exit={{ opacity: 0, scale: 0.8 }}
491-
whileTap={{ scale: 0.9 }}
492-
whileHover={{ scale: 1.05 }}
493485
type="submit"
494486
disabled={isMessageEmpty(contextualState.input, uploadedImages) || isDisabled}
495-
className={`absolute right-3 bottom-3 p-3 rounded-full ${
487+
className={`absolute right-3 bottom-3 p-3 rounded-full transition-all duration-200 hover:scale-105 active:scale-90 ${
496488
isMessageEmpty(contextualState.input, uploadedImages) || isDisabled
497489
? 'bg-gray-100 dark:bg-gray-700 text-gray-400 cursor-not-allowed'
498490
: 'bg-gradient-to-r from-indigo-500 to-purple-500 dark:from-indigo-400 dark:via-purple-400 dark:to-pink-400 text-white dark:text-gray-900 shadow-sm'
499-
} transition-all duration-200`}
491+
}`}
500492
>
501493
<FiSend size={18} />
502494
</motion.button>
@@ -510,34 +502,22 @@ export const ChatInput: React.FC<ChatInputProps> = ({
510502
{showHelpText && (
511503
<div className="flex justify-center mt-2 text-xs">
512504
{connectionStatus && !connectionStatus.connected ? (
513-
<motion.span
514-
initial={{ opacity: 0.7 }}
515-
animate={{ opacity: 1 }}
516-
className="text-red-500 dark:text-red-400 flex items-center font-medium"
517-
>
505+
<span className="text-red-500 dark:text-red-400 flex items-center font-medium animate-in fade-in duration-300">
518506
{connectionStatus.reconnecting
519507
? 'Attempting to reconnect...'
520508
: 'Server disconnected. Click the button to reconnect.'}
521-
</motion.span>
509+
</span>
522510
) : isProcessing ? (
523-
<motion.span
524-
initial={{ opacity: 0.7 }}
525-
whileHover={{ opacity: 1 }}
526-
className="text-accent-500 dark:text-accent-400 flex items-center"
527-
>
511+
<span className="text-accent-500 dark:text-accent-400 flex items-center animate-in fade-in duration-300">
528512
<span className="typing-indicator mr-2">
529513
<span></span>
530514
<span></span>
531515
<span></span>
532516
</span>
533517
Agent is processing your request...
534-
</motion.span>
518+
</span>
535519
) : (
536-
<motion.span
537-
initial={{ opacity: 0.7 }}
538-
whileHover={{ opacity: 1 }}
539-
className="text-gray-500 dark:text-gray-400 transition-opacity"
540-
>
520+
<span className="text-gray-500 dark:text-gray-400 transition-opacity hover:opacity-100 animate-in fade-in duration-300">
541521
{contextualSelectorEnabled ? (
542522
<>
543523
Use @ to reference files/folders • Ctrl+Enter to send • You can also paste images
@@ -546,7 +526,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
546526
) : (
547527
<>Use Ctrl+Enter to quickly send • You can also paste images directly</>
548528
)}
549-
</motion.span>
529+
</span>
550530
)}
551531
</div>
552532
)}

0 commit comments

Comments
 (0)