Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor AgentChat Component for Improved Code Clarity and Conciseness

Salman-Ahamed754b95eab459
diff --git a/packages/app/src/react/features/ai-chat/pages/agent-chat.tsx b/packages/app/src/react/features/ai-chat/pages/agent-chat.tsx
index d686d30c..597b2a2d 100644
--- a/packages/app/src/react/features/ai-chat/pages/agent-chat.tsx
+++ b/packages/app/src/react/features/ai-chat/pages/agent-chat.tsx
@@ -1,13 +1,3 @@
-/**
- * Agent Chat Component - Professional Implementation
- * Uses new modern hooks with complete type safety and better architecture
- *
- * Architecture:
- * - Separated chat context logic into useAgentChatContext hook
- * - Clean component focused on rendering and UI interactions
- * - All business logic encapsulated in custom hooks
- */
-
import { useEffect, useRef } from 'react';
import { useParams } from 'react-router-dom';
@@ -53,12 +43,8 @@ const AgentChat = () => {
handleFileDrop,
} = useAgentChatContext({
agentId: agentId || '',
- onChatReady: () => {
- chatInputRef.current?.focus(); // Focus input when chat is ready
- },
- onChatCleared: () => {
- chatInputRef.current?.focus(); // Focus input after clearing chat
- },
+ onChatReady: () => chatInputRef.current?.focus(), // Focus input when chat is ready
+ onChatCleared: () => chatInputRef.current?.focus(), // Focus input after clearing chat
});
// ============================================================================
@@ -75,9 +61,7 @@ const AgentChat = () => {
* Auto-focus input when agent is loaded and not disabled
*/
useEffect(() => {
- if (!isLoading.agent && !chatContextValue.inputDisabled) {
- chatInputRef.current?.focus();
- }
+ if (!isLoading.agent && !chatContextValue.inputDisabled) chatInputRef.current?.focus();
}, [isLoading.agent, chatContextValue.inputDisabled]);
// ============================================================================