Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor(AIResultModal): Tailwind-only rewrite inside existing Modal
trohitge29004e72ab1
diff --git a/client/src/components/ui/AIResultModal.tsx b/client/src/components/ui/AIResultModal.tsxindex 21f0a6dc..e319cd7f 100644--- a/client/src/components/ui/AIResultModal.tsx+++ b/client/src/components/ui/AIResultModal.tsx@@ -1,6 +1,8 @@import React from 'react';+import { Copy } from 'lucide-react';import Modal from './Modal';-import { useAppTheme } from '../../hooks/useAppTheme';+import { Button } from '@/components/ui/button';+import { Card } from '@/components/ui/card';import { copyToClipboard, formatTimestamp } from '../../utils/formatters';interface AIResultModalProps {@@ -21,184 +23,80 @@ interface AIResultModalProps {} | null;}+interface UsageStatProps {+ value: number;+ label: string;+}++const UsageStat: React.FC<UsageStatProps> = ({ value, label }) => (+ <Card className="p-2 text-center">+ <div className="text-base font-semibold text-foreground">{value}</div>+ <div className="text-xs text-muted-foreground">{label}</div>+ </Card>+);+const AIResultModal: React.FC<AIResultModalProps> = ({ isOpen, onClose, result }) => {- const theme = useAppTheme();if (!result) return null;return (<ModalisOpen={isOpen}onClose={onClose}- title="🤖 AI Execution Result"+ title="AI Execution Result"maxWidth="800px"maxHeight="90vh">- <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>+ <div className="flex h-full flex-col">{/* Header Info */}- <div style={{- padding: theme.spacing.lg,- borderBottom: `1px solid ${theme.colors.border}`,- backgroundColor: theme.colors.backgroundAlt,- }}>- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: theme.spacing.sm }}>+ <div className="border-b border-border bg-muted p-4">+ <div className="mb-2 flex items-start justify-between"><div>- <h3 style={{- margin: 0,- fontSize: theme.fontSize.lg,- fontWeight: theme.fontWeight.semibold,- color: theme.colors.text- }}>+ <h3 className="m-0 text-base font-semibold text-foreground">{result.nodeName} Result</h3>- <p style={{- margin: `${theme.spacing.xs} 0 0 0`,- fontSize: theme.fontSize.sm,- color: theme.colors.textSecondary- }}>+ <p className="mt-1 mb-0 text-sm text-muted-foreground">Model: {result.model} | {formatTimestamp(result.timestamp)}</p></div>- <button+ <Button+ size="sm"onClick={() => copyToClipboard(result.response, 'Response copied to clipboard!')}- style={{- padding: `${theme.spacing.xs} ${theme.spacing.sm}`,- backgroundColor: theme.colors.focus,- color: 'white',- border: 'none',- borderRadius: theme.borderRadius.sm,- fontSize: theme.fontSize.sm,- cursor: 'pointer',- display: 'flex',- alignItems: 'center',- gap: theme.spacing.xs- }}- onMouseEnter={(e) => e.currentTarget.style.backgroundColor = '#2563eb'}- onMouseLeave={(e) => e.currentTarget.style.backgroundColor = theme.colors.focus}>- 📋 Copy Response- </button>+ <Copy className="h-3.5 w-3.5" />+ Copy Response+ </Button></div>-+{/* Usage Stats */}{result.usage && (- <div style={{- display: 'grid',- gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))',- gap: theme.spacing.sm,- marginTop: theme.spacing.sm,- }}>- <div style={{- padding: theme.spacing.sm,- backgroundColor: theme.colors.background,- borderRadius: theme.borderRadius.sm,- textAlign: 'center'- }}>- <div style={{ fontSize: theme.fontSize.lg, fontWeight: theme.fontWeight.semibold, color: theme.colors.text }}>- {result.usage.promptTokens}- </div>- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textSecondary }}>- Prompt Tokens- </div>- </div>- <div style={{- padding: theme.spacing.sm,- backgroundColor: theme.colors.background,- borderRadius: theme.borderRadius.sm,- textAlign: 'center'- }}>- <div style={{ fontSize: theme.fontSize.lg, fontWeight: theme.fontWeight.semibold, color: theme.colors.text }}>- {result.usage.completionTokens}- </div>- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textSecondary }}>- Completion Tokens- </div>- </div>- <div style={{- padding: theme.spacing.sm,- backgroundColor: theme.colors.background,- borderRadius: theme.borderRadius.sm,- textAlign: 'center'- }}>- <div style={{ fontSize: theme.fontSize.lg, fontWeight: theme.fontWeight.semibold, color: theme.colors.text }}>- {result.usage.totalTokens}- </div>- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textSecondary }}>- Total Tokens- </div>- </div>+ <div className="mt-2 grid grid-cols-[repeat(auto-fit,minmax(120px,1fr))] gap-2">+ <UsageStat value={result.usage.promptTokens} label="Prompt Tokens" />+ <UsageStat value={result.usage.completionTokens} label="Completion Tokens" />+ <UsageStat value={result.usage.totalTokens} label="Total Tokens" /></div>)}</div>{/* Response Content */}- <div style={{- flex: 1,- padding: theme.spacing.lg,- overflowY: 'auto'- }}>- <h4 style={{- margin: `0 0 ${theme.spacing.md} 0`,- fontSize: theme.fontSize.base,- fontWeight: theme.fontWeight.medium,- color: theme.colors.text- }}>- Response:- </h4>- <div style={{- padding: theme.spacing.lg,- backgroundColor: theme.colors.backgroundAlt,- border: `1px solid ${theme.colors.border}`,- borderRadius: theme.borderRadius.md,- fontSize: theme.fontSize.base,- lineHeight: '1.6',- color: theme.colors.text,- whiteSpace: 'pre-wrap',- fontFamily: 'system-ui, -apple-system, sans-serif',- maxHeight: '400px',- overflowY: 'auto'- }}>+ <div className="flex-1 overflow-y-auto p-4">+ <h4 className="m-0 mb-3 text-base font-medium text-foreground">Response:</h4>+ <div className="max-h-[400px] overflow-y-auto rounded-md border border-border bg-muted p-4 font-sans text-base leading-relaxed whitespace-pre-wrap text-foreground">{result.response}</div></div>{/* Footer */}- <div style={{- padding: theme.spacing.lg,- borderTop: `1px solid ${theme.colors.border}`,- backgroundColor: theme.colors.backgroundAlt,- display: 'flex',- justifyContent: 'space-between',- alignItems: 'center'- }}>- <div style={{ fontSize: theme.fontSize.xs, color: theme.colors.textSecondary }}>+ <div className="flex items-center justify-between border-t border-border bg-muted p-4">+ <div className="text-xs text-muted-foreground">{result.finishReason && `Finish reason: ${result.finishReason}`}</div>- <button- onClick={onClose}- style={{- padding: `${theme.spacing.sm} ${theme.spacing.lg}`,- backgroundColor: theme.colors.background,- border: `1px solid ${theme.colors.border}`,- borderRadius: theme.borderRadius.sm,- fontSize: theme.fontSize.sm,- cursor: 'pointer',- transition: 'all 0.2s ease'- }}- onMouseEnter={(e) => {- e.currentTarget.style.backgroundColor = theme.colors.backgroundAlt;- e.currentTarget.style.borderColor = theme.colors.borderHover;- }}- onMouseLeave={(e) => {- e.currentTarget.style.backgroundColor = theme.colors.background;- e.currentTarget.style.borderColor = theme.colors.border;- }}- >+ <Button variant="outline" onClick={onClose}>Close- </button>+ </Button></div></div></Modal>);};-export default AIResultModal;\ No newline at end of file+export default AIResultModal;