Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor(credentials): drop residual useAppTheme + opacity-arithmetic from panels/sections
trohitg9c5100acc543
diff --git a/client/src/assets/icons/index.ts b/client/src/assets/icons/index.tsindex 0f5c9aec..809b081d 100644--- a/client/src/assets/icons/index.ts+++ b/client/src/assets/icons/index.ts@@ -95,7 +95,10 @@ export const isImageIcon = (resolved: string): boolean =>* `ICON_LIBRARIES` — no per-brand hardcoding, names come from the* package's own exports.*/-export type LibraryIcon = React.FC<{ size?: number }>;+// Both lucide and lobehub icon components accept `size` (px) and+// `className` (Tailwind sizing). Widening here lets call sites compose+// with `h-6 w-6` instead of pixel literals.+export type LibraryIcon = React.FC<{ size?: number; className?: string }>;type LibraryResolver = (brand: string) => LibraryIcon | null;diff --git a/client/src/components/credentials/catalogueAdapter.ts b/client/src/components/credentials/catalogueAdapter.tsindex cfdfac63..d753f014 100644--- a/client/src/components/credentials/catalogueAdapter.ts+++ b/client/src/components/credentials/catalogueAdapter.ts@@ -49,29 +49,38 @@ import type {// emoji / plain text → <span>// ============================================================================+// IconProps mirrors lucide-react's prop shape: both size (px) and+// className are accepted and forwarded. Call sites prefer className so+// sizing flows from Tailwind tokens (h-6 w-6) instead of pixel literals.interface IconProps {- size: number;+ size?: number;+ className?: string;}// Fallback for providers whose icon_ref cannot be resolved — renders a// circle with the provider initial, so the palette never shows nothing.+// `size` is a px hint used only when the parent doesn't constrain via+// className; the wrapper sizes itself from className when present.const fallbackIcon = (initial: string): React.FC<IconProps> => {- const Comp: React.FC<IconProps> = ({ size }) =>+ const Comp: React.FC<IconProps> = ({ size = 16, className }) =>React.createElement('div',{- style: {- width: size,- height: size,- borderRadius: '50%',- background: 'rgba(128,128,128,0.2)',- color: 'currentColor',- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- fontSize: Math.max(10, size * 0.55),- fontWeight: 600,- },+ className,+ style: className+ ? undefined+ : {+ width: size,+ height: size,+ borderRadius: '50%',+ background: 'rgba(128,128,128,0.2)',+ color: 'currentColor',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ fontSize: Math.max(10, size * 0.55),+ fontWeight: 600,+ },},initial,);@@ -84,28 +93,35 @@ export function resolveIconRef(iconRef: string | undefined, providerId: string):const LibIcon = resolveLibraryIcon(iconRef);if (LibIcon) {- const Comp: React.FC<IconProps> = ({ size }) => React.createElement(LibIcon, { size });+ const Comp: React.FC<IconProps> = ({ size, className }) =>+ React.createElement(LibIcon, { size, className });return Comp;}const resolved = resolveIcon(iconRef);if (resolved && isImageIcon(resolved)) {- const Comp: React.FC<IconProps> = ({ size }) =>+ const Comp: React.FC<IconProps> = ({ size = 16, className }) =>React.createElement('img', {src: resolved,- width: size,- height: size,alt: '',- style: { display: 'block' },+ className,+ width: className ? undefined : size,+ height: className ? undefined : size,+ style: className ? undefined : { display: 'block' },});return Comp;}if (resolved) {- const Comp: React.FC<IconProps> = ({ size }) =>+ const Comp: React.FC<IconProps> = ({ size = 16, className }) =>React.createElement('span',- { style: { fontSize: size, lineHeight: 1, display: 'inline-block' } },+ {+ className,+ style: className+ ? undefined+ : { fontSize: size, lineHeight: 1, display: 'inline-block' },+ },resolved,);return Comp;diff --git a/client/src/components/credentials/panels/ApiKeyPanel.tsx b/client/src/components/credentials/panels/ApiKeyPanel.tsxindex 2312c65a..6549026d 100644--- a/client/src/components/credentials/panels/ApiKeyPanel.tsx+++ b/client/src/components/credentials/panels/ApiKeyPanel.tsx@@ -10,17 +10,13 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';import { Badge } from '@/components/ui/badge';import { Alert, AlertDescription } from '@/components/ui/alert';import ApiKeyInput from '../../ui/ApiKeyInput';-import { useAppTheme } from '../../../hooks/useAppTheme';import { useCredentialPanel } from '../useCredentialPanel';import { ProviderDefaultsSection, LlmUsageSection, ApiUsageSection } from '../sections';import type { ProviderConfig } from '../types';const ApiKeyPanel: React.FC<{ config: ProviderConfig; visible: boolean }> = ({ config, visible }) => {- const theme = useAppTheme();const panel = useCredentialPanel(config, visible);- const color = (theme.colors as any)[config.color] ?? config.color;const field = config.fields?.[0];- const iconSize = parseInt(theme.iconSize.md);const [inputValue, setInputValue] = useState('');// Direct local flag — same pattern as main repo's validKeys[id].@@ -50,9 +46,12 @@ const ApiKeyPanel: React.FC<{ config: ProviderConfig; visible: boolean }> = ({ c<div className="flex items-center gap-3"><divclassName="flex h-12 w-12 items-center justify-center rounded-lg"- style={{ backgroundColor: `${color}15` }}+ // config.color is per-provider brand metadata (data-driven,+ // same carve-out as canvas nodeColor); CSS color-mix keeps+ // the math in CSS rather than as JS string concat.+ style={{ backgroundColor: `color-mix(in srgb, ${config.color} 8%, transparent)` }}>- <config.icon size={iconSize} />+ <config.icon className="h-6 w-6" /></div><CardTitle className="text-lg">{config.name}</CardTitle></div>diff --git a/client/src/components/credentials/panels/OAuthPanel.tsx b/client/src/components/credentials/panels/OAuthPanel.tsxindex dfba9297..26c25fba 100644--- a/client/src/components/credentials/panels/OAuthPanel.tsx+++ b/client/src/components/credentials/panels/OAuthPanel.tsx@@ -4,7 +4,6 @@*/import React from 'react';-import { useAppTheme } from '../../../hooks/useAppTheme';import { useCredentialPanel } from '../useCredentialPanel';import { useProviderStatus } from '../hooks';import { OAuthConnect } from '../primitives';@@ -12,7 +11,6 @@ import { ApiUsageSection } from '../sections';import type { ProviderConfig } from '../types';const OAuthPanel: React.FC<{ config: ProviderConfig; visible: boolean }> = ({ config, visible }) => {- const theme = useAppTheme();const panel = useCredentialPanel(config, visible);const status = useProviderStatus(config.statusHook);const connected = !!status?.connected;@@ -22,7 +20,7 @@ const OAuthPanel: React.FC<{ config: ProviderConfig; visible: boolean }> = ({ co<OAuthConnectconfig={config} form={panel.form} connected={connected}stored={panel.stored} loading={panel.loading} error={panel.error}- icon={<config.icon size={parseInt(theme.iconSize.md)} />}+ icon={<config.icon className="h-6 w-6" />}onSaveCredentials={() => {const missing = config.fields?.find(f => f.required && !panel.form.getFieldValue(f.key)?.trim());if (missing) { panel.setError(`${missing.label} is required`); return; }diff --git a/client/src/components/credentials/sections/ProviderDefaultsSection.tsx b/client/src/components/credentials/sections/ProviderDefaultsSection.tsxindex 3542c741..f135bf42 100644--- a/client/src/components/credentials/sections/ProviderDefaultsSection.tsx+++ b/client/src/components/credentials/sections/ProviderDefaultsSection.tsx@@ -38,7 +38,6 @@ import {AccordionItem,AccordionTrigger,} from '@/components/ui/accordion';-import { useAppTheme } from '../../../hooks/useAppTheme';import { useApiKeys, type ProviderDefaults, type ModelConstraints } from '../../../hooks/useApiKeys';const formSchema = z.object({@@ -58,7 +57,6 @@ interface Props {}const ProviderDefaultsSection: React.FC<Props> = ({ providerId }) => {- const theme = useAppTheme();const { getProviderDefaults, saveProviderDefaults, getStoredModels, getModelConstraints, isConnected } = useApiKeys();const [models, setModels] = useState<string[]>([]);@@ -128,16 +126,6 @@ const ProviderDefaultsSection: React.FC<Props> = ({ providerId }) => {const canThink = constraints?.supports_thinking;const fixedTemp = constraints?.is_reasoning_model && tempMin === tempMax;- const chipStyle = useMemo(- () =>- (bg: string): React.CSSProperties => ({- backgroundColor: `${bg}20`,- borderColor: `${bg}50`,- color: bg,- }),- [],- );-const numberOnChange =(field: { onChange: (v: number | undefined) => void }) =>(e: React.ChangeEvent<HTMLInputElement>) => {@@ -192,23 +180,23 @@ const ProviderDefaultsSection: React.FC<Props> = ({ providerId }) => {{constraints && (<div className="flex flex-wrap items-center gap-1.5">{maxOut != null && (- <Badge style={chipStyle(theme.dracula.green)}>+ <Badge variant="success">Max Output: {maxOut.toLocaleString()}</Badge>)}{constraints.context_length != null && (- <Badge style={chipStyle(theme.dracula.cyan)}>+ <Badge variant="info">Context: {constraints.context_length.toLocaleString()}</Badge>)}- <Badge style={chipStyle(theme.dracula.purple)}>+ <Badge variant="secondary">Temp: {tempMin}-{tempMax}</Badge>{canThink && (- <Badge style={chipStyle(theme.dracula.orange)}>Thinking: {thinkType}</Badge>+ <Badge variant="warning">Thinking: {thinkType}</Badge>)}{constraints.is_reasoning_model && (- <Badge style={chipStyle(theme.dracula.pink)}>Reasoning</Badge>+ <Badge variant="outline">Reasoning</Badge>)}</div>)}@@ -360,17 +348,8 @@ const ProviderDefaultsSection: React.FC<Props> = ({ providerId }) => {<Buttontype="submit"disabled={!isDirty || loading}- variant="outline"+ variant={isDirty ? 'default' : 'outline'}className="w-full"- style={- isDirty- ? {- backgroundColor: `${theme.dracula.green}25`,- borderColor: `${theme.dracula.green}60`,- color: theme.dracula.green,- }- : undefined- }>{loading && <Loader2 className="h-4 w-4 animate-spin" />}Save Defaultsdiff --git a/client/src/components/credentials/sections/RateLimitSection.tsx b/client/src/components/credentials/sections/RateLimitSection.tsxindex 6b853697..a169825f 100644--- a/client/src/components/credentials/sections/RateLimitSection.tsx+++ b/client/src/components/credentials/sections/RateLimitSection.tsx@@ -31,7 +31,6 @@ import {AccordionItem,AccordionTrigger,} from '@/components/ui/accordion';-import { useAppTheme } from '../../../hooks/useAppTheme';import { useWebSocket, type RateLimitConfig, type RateLimitStats } from '../../../contexts/WebSocketContext';const formSchema = z.object({@@ -64,7 +63,6 @@ const numberOnChange =};const RateLimitSection: React.FC = () => {- const theme = useAppTheme();const { getWhatsAppRateLimitConfig, setWhatsAppRateLimitConfig, unpauseWhatsAppRateLimit } = useWebSocket();const [stats, setStats] = useState<RateLimitStats | null>(null);const [loading, setLoading] = useState(false);@@ -290,17 +288,8 @@ const RateLimitSection: React.FC = () => {<Buttontype="submit"disabled={!isDirty || loading}- variant="outline"+ variant={isDirty ? 'default' : 'outline'}className="w-full"- style={- isDirty- ? {- backgroundColor: `${theme.dracula.green}25`,- borderColor: `${theme.dracula.green}60`,- color: theme.dracula.green,- }- : undefined- }>{loading && <Loader2 className="h-4 w-4 animate-spin" />}Save Changesdiff --git a/client/src/components/credentials/types.ts b/client/src/components/credentials/types.tsindex 26831472..ee9a4b66 100644--- a/client/src/components/credentials/types.ts+++ b/client/src/components/credentials/types.ts@@ -83,7 +83,11 @@ export interface ProviderConfig {/** Theme color key (resolved via theme.colors[color] at render). */color: string;kind: PanelKind;- icon: FC<{ size: number }>;+ /** Provider icon. lucide-react icons + the in-house brand icons both+ * accept `size` and `className`; call sites prefer `className` so+ * sizing flows from Tailwind tokens (`h-6 w-6`) instead of hardcoded+ * pixel values. */+ icon: FC<{ size?: number; className?: string }>;/** Credential input fields. */fields?: FieldDef[];