Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor(client): Wave 2 Phase 5a - ActionButton cva helper
trohitg8a68c09590d3
diff --git a/client/src/ParameterPanel.tsx b/client/src/ParameterPanel.tsxindex 90a8d114..559677b2 100644--- a/client/src/ParameterPanel.tsx+++ b/client/src/ParameterPanel.tsx@@ -8,6 +8,7 @@ import { ExecutionService, ExecutionResult } from './services/executionService';import { useAppTheme } from './hooks/useAppTheme';import { CalendarClock, PlayCircle } from 'lucide-react';import { SKILL_NODE_TYPES } from './nodeDefinitions/skillNodes';+import { ActionButton } from './components/ui/action-button';const ParameterPanel: React.FC = () => {const theme = useAppTheme();@@ -156,128 +157,53 @@ const ParameterPanel: React.FC = () => {return <span>{icon}</span>;};- // Action button style helper - Dracula theme for visibility- const actionButtonStyle = (color: string, isDisabled = false): React.CSSProperties => ({- height: '32px',- padding: '0 14px',- display: 'flex',- alignItems: 'center',- gap: '6px',- backgroundColor: isDisabled ? `${theme.colors.primary}15` : `${color}25`,- color: isDisabled ? theme.colors.primary : color,- border: `1px solid ${isDisabled ? `${theme.colors.primary}40` : `${color}60`}`,- borderRadius: theme.borderRadius.sm,- fontSize: '13px',- fontWeight: 600,- cursor: isDisabled ? 'not-allowed' : 'pointer',- transition: `all ${theme.transitions.fast}`,- fontFamily: 'system-ui, sans-serif',- });-// Header actions with node name and buttons in middle areaconst headerActions = (- <div style={{- display: 'flex',- gap: '16px',- alignItems: 'center'- }}>- {/* Node Name */}- <div style={{- display: 'flex',- alignItems: 'center',- gap: '8px',- fontSize: '15px',- fontWeight: 600,- color: theme.colors.text,- fontFamily: 'system-ui, sans-serif'- }}>+ <div className="flex items-center gap-4">+ <div className="flex items-center gap-2 text-[15px] font-semibold text-foreground">{renderIcon(nodeDefinition.icon)}<span>{nodeDefinition.displayName}</span>{hasUnsavedChanges && <span style={{ color: theme.accent.orange }}>*</span>}</div>-- {/* Buttons: Run, Save, Cancel */}- <div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>- {/* Run Button - hide for monitor nodes since they show live data */}+ <div className="flex items-center gap-2">{canExecute && !hideRunButton && !isMonitorNode && (- <button- style={actionButtonStyle(theme.dracula.green, isExecuting)}+ <ActionButton+ tone="green"onClick={handleRun}disabled={isExecuting}title={isExecuting ? 'Execution in progress...' : 'Execute this node'}- onMouseEnter={(e) => {- if (!isExecuting) {- e.currentTarget.style.backgroundColor = `${theme.dracula.green}40`;- }- }}- onMouseLeave={(e) => {- if (!isExecuting) {- e.currentTarget.style.backgroundColor = `${theme.dracula.green}25`;- }- }}><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor">- <path d="M8 5v14l11-7z"/>+ <path d="M8 5v14l11-7z" /></svg>{isExecuting ? 'Running...' : 'Run'}- </button>+ </ActionButton>)}-- {/* Save Button */}- <button- style={actionButtonStyle(theme.dracula.purple, !hasUnsavedChanges)}- onClick={handleSave}- disabled={!hasUnsavedChanges}- onMouseEnter={(e) => {- if (hasUnsavedChanges) {- e.currentTarget.style.backgroundColor = `${theme.dracula.purple}40`;- }- }}- onMouseLeave={(e) => {- if (hasUnsavedChanges) {- e.currentTarget.style.backgroundColor = `${theme.dracula.purple}25`;- }- }}- >+ <ActionButton tone="purple" onClick={handleSave} disabled={!hasUnsavedChanges}><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">- <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>- <polyline points="17 21 17 13 7 13 7 21"/>- <polyline points="7 3 7 8 15 8"/>+ <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" />+ <polyline points="17 21 17 13 7 13 7 21" />+ <polyline points="7 3 7 8 15 8" /></svg>Save- </button>-- {/* Cancel/Stop Button */}- <button- style={actionButtonStyle(theme.dracula.pink, false)}+ </ActionButton>+ <ActionButton+ tone="pink"onClick={async () => {if (isWaiting && selectedNode) {- // Cancel the event wait for trigger nodes - don't close modal, let execution complete- console.log('[ParameterPanel] Cancelling event wait:', {- nodeId: selectedNode.id,- waiterId: nodeStatus?.data?.waiter_id,- nodeStatus- });const result = await cancelEventWait(selectedNode.id, nodeStatus?.data?.waiter_id);console.log('[ParameterPanel] Cancel result:', result);- // Don't call handleCancel() - let the execution complete with cancelled statereturn;}handleCancel();}}- onMouseEnter={(e) => {- e.currentTarget.style.backgroundColor = `${theme.dracula.pink}40`;- }}- onMouseLeave={(e) => {- e.currentTarget.style.backgroundColor = `${theme.dracula.pink}25`;- }}><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" /></svg>{isWaiting ? 'Stop' : 'Cancel'}- </button>+ </ActionButton></div></div>);diff --git a/client/src/components/LocationParameterPanel.tsx b/client/src/components/LocationParameterPanel.tsxindex 601b8741..b682e6d8 100644--- a/client/src/components/LocationParameterPanel.tsx+++ b/client/src/components/LocationParameterPanel.tsx@@ -4,6 +4,7 @@ import LocationPanelLayout from './parameterPanel/LocationPanelLayout';import { useParameterPanel } from '../hooks/useParameterPanel';import { ExecutionService } from '../services/executionService';import { useAppTheme } from '../hooks/useAppTheme';+import { ActionButton } from './ui/action-button';const LocationParameterPanel: React.FC = () => {const theme = useAppTheme();@@ -60,74 +61,31 @@ const LocationParameterPanel: React.FC = () => {return null;}- // Action button style helper - matches main ParameterPanel- const actionButtonStyle = (color: string, isDisabled = false): React.CSSProperties => ({- height: '32px',- padding: '0 14px',- display: 'flex',- alignItems: 'center',- gap: '6px',- backgroundColor: isDisabled ? `${theme.colors.primary}15` : `${color}25`,- color: isDisabled ? theme.colors.primary : color,- border: `1px solid ${isDisabled ? `${theme.colors.primary}40` : `${color}60`}`,- borderRadius: theme.borderRadius.sm,- fontSize: '13px',- fontWeight: 600,- cursor: isDisabled ? 'not-allowed' : 'pointer',- transition: `all ${theme.transitions.fast}`,- });-// Header actions with node name and buttons in middle areaconst headerActions = (- <div style={{- display: 'flex',- gap: '16px',- alignItems: 'center'- }}>- {/* Node Name */}- <div style={{- display: 'flex',- alignItems: 'center',- gap: '8px',- fontSize: '15px',- fontWeight: 600,- color: theme.colors.text- }}>+ <div className="flex items-center gap-4">+ <div className="flex items-center gap-2 text-[15px] font-semibold text-foreground"><span>{nodeDefinition.icon}</span><span>{nodeDefinition.displayName}</span>{hasUnsavedChanges && <span style={{ color: theme.accent.orange }}>*</span>}</div>-- {/* Buttons: Run, Save, Cancel */}- <div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>- {/* Run Button */}+ <div className="flex items-center gap-2">{canExecute && (- <button- style={actionButtonStyle(theme.dracula.green, isExecuting)}+ <ActionButton+ tone="green"onClick={handleRun}disabled={isExecuting}title={isExecuting ? 'Execution in progress...' : 'Execute this node'}>{isExecuting ? 'Running...' : 'Run'}- </button>+ </ActionButton>)}-- {/* Save Button */}- <button- style={actionButtonStyle(theme.dracula.purple, !hasUnsavedChanges)}- onClick={handleSave}- disabled={!hasUnsavedChanges}- >+ <ActionButton tone="purple" onClick={handleSave} disabled={!hasUnsavedChanges}>Save- </button>-- {/* Cancel Button */}- <button- style={actionButtonStyle(theme.dracula.pink, false)}- onClick={handleCancel}- >+ </ActionButton>+ <ActionButton tone="pink" onClick={handleCancel}>Cancel- </button>+ </ActionButton></div></div>);diff --git a/client/src/components/ui/SettingsPanel.tsx b/client/src/components/ui/SettingsPanel.tsxindex dc9a2c53..af0bce45 100644--- a/client/src/components/ui/SettingsPanel.tsx+++ b/client/src/components/ui/SettingsPanel.tsx@@ -3,6 +3,7 @@ import { toast } from 'sonner';import { HelpCircle } from 'lucide-react';import { Button } from '@/components/ui/button';+import { ActionButton } from '@/components/ui/action-button';import { Switch } from '@/components/ui/switch';import { Slider } from '@/components/ui/slider';import { Input } from '@/components/ui/input';@@ -147,113 +148,46 @@ const SettingsPanel: React.FC<SettingsPanelProps> = ({color: theme.colors.text,};- // Button style helper following ParameterPanel pattern- const actionButtonStyle = (color: string, isDisabled = false): React.CSSProperties => ({- display: 'flex',- alignItems: 'center',- gap: '6px',- padding: '6px 12px',- backgroundColor: isDisabled ? `${theme.colors.primary}15` : `${color}25`,- color: isDisabled ? theme.colors.primary : color,- border: `1px solid ${isDisabled ? `${theme.colors.primary}40` : `${color}60`}`,- borderRadius: theme.borderRadius.sm,- fontSize: '13px',- fontWeight: 600,- cursor: isDisabled ? 'not-allowed' : 'pointer',- transition: `all ${theme.transitions.fast}`,- fontFamily: 'system-ui, sans-serif',- });-// Header actions with title and buttonsconst headerActions = (- <div style={{- display: 'flex',- gap: '16px',- alignItems: 'center'- }}>- {/* Title */}- <div style={{- display: 'flex',- alignItems: 'center',- gap: '8px',- fontSize: '15px',- fontWeight: 600,- color: theme.colors.text,- fontFamily: 'system-ui, sans-serif'- }}>+ <div className="flex items-center gap-4">+ <div className="flex items-center gap-2 text-[15px] font-semibold text-foreground"><span>{'\u2699'}</span><span>Settings</span></div>-- {/* Buttons: Reset, Save, Close */}- <div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>- {/* Reset Button */}- <button- style={actionButtonStyle(theme.dracula.orange, isSaving)}+ <div className="flex items-center gap-2">+ <ActionButton+ tone="orange"onClick={handleReset}disabled={isSaving}title="Reset to default settings"- onMouseEnter={(e) => {- if (!isSaving) {- e.currentTarget.style.backgroundColor = `${theme.dracula.orange}40`;- }- }}- onMouseLeave={(e) => {- if (!isSaving) {- e.currentTarget.style.backgroundColor = `${theme.dracula.orange}25`;- }- }}><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">- <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>- <path d="M3 3v5h5"/>+ <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />+ <path d="M3 3v5h5" /></svg>Reset- </button>-- {/* Save Button */}- <button- style={actionButtonStyle(theme.dracula.green, isSaving)}+ </ActionButton>+ <ActionButton+ tone="green"onClick={handleSave}disabled={isSaving}title="Save settings"- onMouseEnter={(e) => {- if (!isSaving) {- e.currentTarget.style.backgroundColor = `${theme.dracula.green}40`;- }- }}- onMouseLeave={(e) => {- if (!isSaving) {- e.currentTarget.style.backgroundColor = `${theme.dracula.green}25`;- }- }}><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">- <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>- <polyline points="17 21 17 13 7 13 7 21"/>- <polyline points="7 3 7 8 15 8"/>+ <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" />+ <polyline points="17 21 17 13 7 13 7 21" />+ <polyline points="7 3 7 8 15 8" /></svg>{isSaving ? 'Saving...' : 'Save'}- </button>-- {/* Close Button */}- <button- style={actionButtonStyle(theme.dracula.pink, false)}- onClick={onClose}- title="Close settings"- onMouseEnter={(e) => {- e.currentTarget.style.backgroundColor = `${theme.dracula.pink}40`;- }}- onMouseLeave={(e) => {- e.currentTarget.style.backgroundColor = `${theme.dracula.pink}25`;- }}- >+ </ActionButton>+ <ActionButton tone="pink" onClick={onClose} title="Close settings"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" /></svg>Close- </button>+ </ActionButton></div></div>);diff --git a/client/src/components/ui/action-button.tsx b/client/src/components/ui/action-button.tsxnew file mode 100644index 00000000..fe6710b4--- /dev/null+++ b/client/src/components/ui/action-button.tsx@@ -0,0 +1,60 @@+/**+ * ActionButton — colored "soft" toolbar button shared by the parameter+ * panel, location panel, settings header, and top toolbar. Replaces a+ * 14-line `actionButtonStyle(color, isDisabled)` style helper that was+ * copy-pasted across 4 files.+ *+ * The dracula palette is fixed (CSS vars, not arbitrary hex) so we use+ * a CVA `tone` variant and let Tailwind compile the static class names.+ * Disabled state automatically swaps tone to muted via `disabled:`+ * utility classes.+ */++import * as React from 'react';+import { cva, type VariantProps } from 'class-variance-authority';+import { cn } from '@/lib/utils';++export const actionButtonVariants = cva(+ // Base: 32px tall pill with icon-text gap, semibold, focus ring, smooth hover.+ // Disabled state is handled per-tone (different opacity/colors).+ 'inline-flex h-8 items-center gap-1.5 rounded-md border px-3.5 text-[13px] font-semibold transition-all outline-none select-none disabled:cursor-not-allowed focus-visible:ring-2 focus-visible:ring-ring/40',+ {+ variants: {+ tone: {+ green:+ 'border-dracula-green/60 bg-dracula-green/15 text-dracula-green hover:bg-dracula-green/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ purple:+ 'border-dracula-purple/60 bg-dracula-purple/15 text-dracula-purple hover:bg-dracula-purple/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ pink:+ 'border-dracula-pink/60 bg-dracula-pink/15 text-dracula-pink hover:bg-dracula-pink/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ cyan:+ 'border-dracula-cyan/60 bg-dracula-cyan/15 text-dracula-cyan hover:bg-dracula-cyan/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ orange:+ 'border-dracula-orange/60 bg-dracula-orange/15 text-dracula-orange hover:bg-dracula-orange/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ yellow:+ 'border-dracula-yellow/60 bg-dracula-yellow/15 text-dracula-yellow hover:bg-dracula-yellow/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ red:+ 'border-dracula-red/60 bg-dracula-red/15 text-dracula-red hover:bg-dracula-red/25 disabled:border-primary/40 disabled:bg-primary/10 disabled:text-primary',+ },+ },+ defaultVariants: { tone: 'cyan' },+ },+);++export type ActionButtonTone = NonNullable<VariantProps<typeof actionButtonVariants>['tone']>;++export interface ActionButtonProps+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,+ VariantProps<typeof actionButtonVariants> {}++export const ActionButton = React.forwardRef<HTMLButtonElement, ActionButtonProps>(+ ({ className, tone, ...props }, ref) => (+ <button+ ref={ref}+ type={props.type ?? 'button'}+ className={cn(actionButtonVariants({ tone }), className)}+ {...props}+ />+ ),+);+ActionButton.displayName = 'ActionButton';