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.

Global text area style update 86eumn7dc (#150)

ali-inkco4d57095886e4
diff --git a/packages/app/src/builder-ui/components/Component.class/index.ts b/packages/app/src/builder-ui/components/Component.class/index.ts
index b2316ca2..d18e3288 100644
--- a/packages/app/src/builder-ui/components/Component.class/index.ts
+++ b/packages/app/src/builder-ui/components/Component.class/index.ts
@@ -145,12 +145,13 @@ export class Component extends EventEmitter {
editConfig: {
type: 'textarea',
label: 'Default Value',
- fieldCls: 'min-h-[50px] px-3 py-1 resize-y',
+ fieldCls:
+ 'bg-white border text-gray-900 rounded block w-full outline-none focus:outline-none focus:ring-0 focus:ring-offset-0 focus:ring-shadow-none text-sm font-normal placeholder:text-sm placeholder:font-normal py-2 px-3 transition-all duration-150 ease-in-out border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500',
attributes: {
'data-agent-vars': 'true',
- 'data-auto-size': 'false',
- style: 'height: 34px;',
- }, // 'data-auto-size': 'false' to prevent set auto height initially
+ 'data-auto-size': 'true',
+ rows: '2',
+ }, // Enable auto-size for consistent UX with 2-line default
section: 'Advanced_Options',
hint: 'Value assigned if no specific value provided by user.',
hintPosition: 'after_label',
@@ -3500,6 +3501,9 @@ function addMissingKey({
const actionsWrapper = dialog.querySelector('.__actions');
actionsWrapper?.classList.remove('justify-center');
actionsWrapper?.classList.add('justify-between');
+
+ // Initialize auto-resize for textareas with data-auto-size="true"
+ setTimeout(() => initializeTextareaAutoresize(dialog), 100);
},
},
'auto',
@@ -3514,6 +3518,41 @@ function formatKeyAsClassName(keyName: string) {
return '_comp_message_' + keyName.replace(/\+/g, '_').replace(/\s+/g, '_').toLowerCase();
}
+/**
+ * Simple auto-resize for textareas - let the browser handle scrollbars naturally
+ */
+function initializeTextareaAutoresize(container: HTMLElement = document.body) {
+ const textareas = container.querySelectorAll(
+ 'textarea[data-auto-size="true"]',
+ ) as NodeListOf<HTMLTextAreaElement>;
+
+ textareas.forEach((textarea) => {
+ if (textarea.hasAttribute('data-autoresize-initialized')) return;
+
+ // Mark as initialized
+ textarea.setAttribute('data-autoresize-initialized', 'true');
+
+ // Set simple CSS properties and let browser handle the rest
+ textarea.style.minHeight = '56px'; // 2 rows
+ textarea.style.maxHeight = '176px'; // 8 rows
+ textarea.style.height = '56px'; // Start with 2 rows
+ textarea.style.overflowY = 'auto'; // Let browser show scrollbar when needed
+ textarea.style.resize = 'none';
+ textarea.style.lineHeight = '20px';
+ });
+}
+
+// Global initialization when DOM is ready
+if (typeof window !== 'undefined') {
+ document.addEventListener('DOMContentLoaded', () => {
+ initializeTextareaAutoresize();
+ });
+
+ if (document.readyState !== 'loading') {
+ initializeTextareaAutoresize();
+ }
+}
+
//#region Missing Key Click Handler
function missingKeyMessageClickHandler(keyName: string, event: Event) {
addMissingKey({
diff --git a/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx b/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx
index a7fe0b61..163ee163 100644
--- a/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx
+++ b/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx
@@ -20,6 +20,7 @@ import {
SendIcon,
} from '@react/shared/components/svgs';
import { Button } from '@react/shared/components/ui/newDesign/button';
+import { TextArea } from '@react/shared/components/ui/newDesign/textarea';
import { Spinner } from '@react/shared/components/ui/spinner';
import { EMBODIMENT_TYPE } from '@react/shared/enums';
import { extractError } from '@react/shared/utils/errors';
@@ -374,34 +375,13 @@ const ChatBotDialog = ({
/>
</div> */}
<div>
- <label
- htmlFor="personality"
- className="block text-[#1E1E1E] mb-1 text-base font-normal"
- >
- Personality
- </label>
- <Field
- as="textarea"
- rows={2}
- className="bg-white
- border
- text-gray-900
- rounded
- block
- w-full
- outline-none
- focus:outline-none
- focus:ring-0
- focus:ring-offset-0
- focus:ring-shadow-none
- text-sm
- font-normal
- placeholder:text-sm
- placeholder:font-normal
- mb-2
- border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500"
+ <TextArea
+ label="Personality"
+ labelClassName="block text-[#1E1E1E] mb-1 text-base font-normal"
name="personality"
id="personality"
+ rows={2}
+ maxHeight={136}
onChange={(e) => {
// Check if the new length doesn't exceed the limit
if (e.target.value.length <= MODEL_DESCRIPTION_LIMIT) {
@@ -411,6 +391,8 @@ const ChatBotDialog = ({
onBlur={props.handleBlur}
value={props.values?.personality}
placeholder="Enter chatbot personality"
+ fullWidth
+ className="mb-2"
/>
<div className="text-sm mb-4 text-right">
<span
diff --git a/packages/app/src/react/features/agent-settings/dialogs/ChatGpt.tsx b/packages/app/src/react/features/agent-settings/dialogs/ChatGpt.tsx
index 5a752689..977ee120 100644
--- a/packages/app/src/react/features/agent-settings/dialogs/ChatGpt.tsx
+++ b/packages/app/src/react/features/agent-settings/dialogs/ChatGpt.tsx
@@ -8,13 +8,14 @@ import {
import { mapGptEmbodimentProperties } from '@react/features/agent-settings/utils';
import { CloseIcon } from '@react/shared/components/svgs';
import { Button } from '@react/shared/components/ui/newDesign/button';
+import { TextArea } from '@react/shared/components/ui/newDesign/textarea';
import { Spinner } from '@react/shared/components/ui/spinner';
import { EMBODIMENT_TYPE } from '@react/shared/enums';
import { validateURL } from '@react/shared/utils/utils';
import { errorToast, successToast } from '@src/shared/components/toast';
import { useQueryClient } from '@tanstack/react-query';
import { ErrorMessage, Field, Form, Formik } from 'formik';
-import { Fragment, useEffect, useState } from 'react';
+import { Fragment, useEffect, useRef, useState } from 'react';
interface IFormValues {
humanName: string;
@@ -53,12 +54,72 @@ const ChatGptDialog = ({
const [isSubmitting, setIsSubmitting] = useState(false);
const queryClient = useQueryClient();
+ // Refs for textarea height synchronization
+ const humanDescriptionRef = useRef<HTMLTextAreaElement>(null);
+ const modelDescriptionRef = useRef<HTMLTextAreaElement>(null);
+ const [syncMinHeight, setSyncMinHeight] = useState<string>('56px');
+
+ // Function to synchronize textarea minimum heights
+ const synchronizeTextareaHeights = () => {
+ const humanTextarea = humanDescriptionRef.current;
+ const modelTextarea = modelDescriptionRef.current;
+
+ if (humanTextarea && modelTextarea) {
+ // Get the current computed heights of both textareas
+ const humanHeight = humanTextarea.getBoundingClientRect().height;
+ const modelHeight = modelTextarea.getBoundingClientRect().height;
+
+ // Set minimum height to the larger of the two (with 56px minimum)
+ const maxHeight = Math.max(56, humanHeight, modelHeight);
+ const newMinHeight = `${Math.min(maxHeight, 136)}px`; // Cap at maxHeight limit
+
+ setSyncMinHeight(newMinHeight);
+ }
+ };
+
+ // Reset textarea heights when modal opens/closes
+ const resetTextareaHeights = () => {
+ setSyncMinHeight('56px');
+
+ // Force reset the actual textarea heights after a short delay
+ setTimeout(() => {
+ const humanTextarea = humanDescriptionRef.current;
+ const modelTextarea = modelDescriptionRef.current;
+
+ if (humanTextarea) {
+ humanTextarea.style.height = '56px';
+ }
+ if (modelTextarea) {
+ modelTextarea.style.height = '56px';
+ }
+ }, 0);
+ };
+
+ // Reset heights when modal opens
+ useEffect(() => {
+ if (isOpen) {
+ resetTextareaHeights();
+ }
+ }, [isOpen]);
+
useEffect(() => {
const properties = currentData?.properties;
const _activeData = mapGptEmbodimentProperties(properties, activeAgent);
setActiveData(_activeData);
}, [currentData, activeAgent]);
+ // Synchronize heights when activeData changes or component mounts
+ useEffect(() => {
+ if (activeData && isOpen) {
+ // Check if both description values are empty, if so, reset heights
+ if (!activeData.humanDescription && !activeData.modelDescription) {
+ resetTextareaHeights();
+ } else {
+ setTimeout(synchronizeTextareaHeights, 100);
+ }
+ }
+ }, [activeData, isOpen]);
+
const submitForm = async (data) => {
if (isSubmitting) {
return;
@@ -245,41 +306,28 @@ const ChatGptDialog = ({
</div>
<div className="flex gap-5 justify-between items-center mt-2">
<div className="flex-1 mb-2">
- <label
- htmlFor="humanDescription"
- className="block text-[#1E1E1E] mb-1 text-base font-normal"
- >
- Description for Human:
- </label>
- <Field
- as="textarea"
- rows={2}
- className="bg-white
- border
- text-gray-900
- rounded
- block
- w-full
- outline-none
- focus:outline-none
- focus:ring-0
- focus:ring-offset-0
- focus:ring-shadow-none
- text-sm
- font-normal
- placeholder:text-sm
- placeholder:font-normal
- border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500"
+ <TextArea
+ ref={humanDescriptionRef}
+ label="Description for Human:"
+ labelClassName="block text-[#1E1E1E] mb-1 text-base font-normal"
name="humanDescription"
+ id="humanDescription"
+ rows={2}
+ maxHeight={136}
onChange={(e) => {
// Check if the new length doesn't exceed the limit
if (e.target.value.length <= HUMAN_DESCRIPTION_LIMIT) {
props.handleChange(e);
+ // Synchronize heights after content change
+ setTimeout(synchronizeTextareaHeights, 0);
}
}}
onBlur={props.handleBlur}
value={props.values?.humanDescription}
placeholder="Enter Human Description"
+ fullWidth
+ autoGrow={true}
+ style={{ minHeight: syncMinHeight }}
/>
<div className="text-sm mb-4 text-right">
<span
@@ -300,41 +348,28 @@ const ChatGptDialog = ({
</div>
</div>
<div className="flex-1 mb-2">
- <label
- htmlFor="modelDescription"
- className="block text-[#1E1E1E] mb-1 text-base font-normal"
- >
- Description for Model:
- </label>
- <Field
- as="textarea"
- rows={2}
- className="bg-white
- border
- text-gray-900
- rounded
- block
- w-full
- outline-none
- focus:outline-none
- focus:ring-0
- focus:ring-offset-0
- focus:ring-shadow-none
- text-sm
- font-normal
- placeholder:text-sm
- placeholder:font-normal
- border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500"
+ <TextArea
+ ref={modelDescriptionRef}
+ label="Description for Model:"
+ labelClassName="block text-[#1E1E1E] mb-1 text-base font-normal"
name="modelDescription"
+ id="modelDescription"
+ rows={2}
+ maxHeight={136}
onChange={(e) => {
// Check if the new length doesn't exceed the limit
if (e.target.value.length <= MODEL_DESCRIPTION_LIMIT) {
props.handleChange(e);
+ // Synchronize heights after content change
+ setTimeout(synchronizeTextareaHeights, 0);
}
}}
onBlur={props.handleBlur}
value={props.values?.modelDescription}
placeholder="Enter Model Description"
+ fullWidth
+ autoGrow={true}
+ style={{ minHeight: syncMinHeight }}
/>
<div className="text-sm mb-4 text-right">
<span
diff --git a/packages/app/src/react/features/agent-settings/modals/chatbotCode.modal.tsx b/packages/app/src/react/features/agent-settings/modals/chatbotCode.modal.tsx
index 42259ff2..928675de 100644
--- a/packages/app/src/react/features/agent-settings/modals/chatbotCode.modal.tsx
+++ b/packages/app/src/react/features/agent-settings/modals/chatbotCode.modal.tsx
@@ -1,5 +1,6 @@
import { CloseIcon } from '@react/shared/components/svgs';
import { Button } from '@react/shared/components/ui/newDesign/button';
+import { TextArea } from '@react/shared/components/ui/newDesign/textarea';
import { useRef } from 'react';
import { FaCircleInfo, FaCopy } from 'react-icons/fa6';
type Props = {
@@ -100,16 +101,18 @@ const ChatbotCodeSnippetModal = (props: Props) => {
will occupy the full available space within it.
</p>
)}
- <textarea
+ <TextArea
ref={textareaRef}
readOnly
- className="w-full h-auto resize p-3 mb-4 text-sm text-gray-700 bg-gray-100 rounded dark:bg-gray-900 dark:text-white border-none"
+ className="mb-4 text-sm text-gray-700 bg-gray-100 rounded dark:bg-gray-900 dark:text-white border-none"
rows={12}
value={codeSnippet}
onClick={(e) => {
const target = e.target as HTMLInputElement;
target.select();
}}
+ fullWidth
+ autoGrow={false}
/>
<Button
diff --git a/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx b/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx
index 4c3195ae..11470041 100644
--- a/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx
+++ b/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx
@@ -5,6 +5,7 @@ import useMutateOnboardingData from '@react/features/onboarding/hooks/useMutateO
import { Input } from '@react/shared/components/ui/input';
import { Label } from '@react/shared/components/ui/label';
import { Button } from '@react/shared/components/ui/newDesign/button';
+import { TextArea } from '@react/shared/components/ui/newDesign/textarea';
import {
Select,
SelectContent,
@@ -13,7 +14,6 @@ import {
SelectValue,
} from '@react/shared/components/ui/select';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@react/shared/components/ui/tabs';
-import { Textarea } from '@react/shared/components/ui/textarea';
import { useAppState } from '@react/shared/contexts/AppStateContext';
import { OnboardingTaskType } from '@react/shared/types/onboard.types';
import { UserSettingsKey } from '@src/backend/types/user-data';
@@ -754,9 +754,9 @@ function DeployAgentModal({ userInfo, deploymentSidebarCtx }) {
>
Release Notes
</Label>
- <Textarea
+ <TextArea
name="releaseNotes"
- className="min-h-[100px] bg-[#F9FAFB] border-[#D1D5DB] text-sm text-[#6B7280] resize-vertical"
+ className="bg-[#F9FAFB] border-[#D1D5DB] text-sm text-[#6B7280] resize-vertical"
placeholder="Enter the list of new features, bug fixes, and other changes here."
value={formik.values.releaseNotes}
onChange={formik.handleChange}
diff --git a/packages/app/src/react/features/builder/components/VariablesWidget.tsx b/packages/app/src/react/features/builder/components/VariablesWidget.tsx
index a59f85a2..f1c2ddd2 100644
--- a/packages/app/src/react/features/builder/components/VariablesWidget.tsx
+++ b/packages/app/src/react/features/builder/components/VariablesWidget.tsx
@@ -5,6 +5,7 @@ import * as agentSettingsUtils from '@src/react/features/agents/utils';
import { CloseIcon, GlobalVariableIcon } from '@src/react/shared/components/svgs';
import { Input } from '@src/react/shared/components/ui/input';
import { Button } from '@src/react/shared/components/ui/newDesign/button';
+import { TextArea } from '@src/react/shared/components/ui/newDesign/textarea';
import { Spinner } from '@src/react/shared/components/ui/spinner';
import { errKeys } from '@src/react/shared/constants';
import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
@@ -371,8 +372,12 @@ const VariablesWidget = ({ agentId, workspace }: { agentId: string; workspace: W
return;
}
- textarea.style.height = '40px'; // Reset tominimum height first
- textarea.style.height = `${Math.max(40, textarea.scrollHeight)}px`; // Ensure minimum height of 40px
+ textarea.style.height = '40px'; // Reset to minimum height first
+ const newHeight = Math.max(40, Math.min(textarea.scrollHeight, 154)); // Min 40px, Max 154px
+ textarea.style.height = `${newHeight}px`;
+
+ // Show scrollbar if content exceeds max height
+ textarea.style.overflowY = textarea.scrollHeight > 154 ? 'auto' : 'hidden';
};
const handleClose = () => {
@@ -514,23 +519,25 @@ const VariablesWidget = ({ agentId, workspace }: { agentId: string; workspace: W
</div>
<div className="relative w-1/2">
<div className="relative">
- <textarea
+ <TextArea
ref={(el) => (textareaRefs.current[index] = el)}
placeholder="Value"
value={pair.value}
onChange={(e) => handleInputChange(index, 'value', e.target.value)}
onFocus={(e) => adjustTextareaHeight(e.target, true)}
onBlur={(e) => adjustTextareaHeight(e.target, false)}
- className={`w-full bg-white border text-gray-900 rounded block outline-none focus:outline-none focus:ring-0 focus:ring-offset-0 focus:ring-shadow-none text-sm font-normal placeholder:text-sm placeholder:font-normal ${
+ className={`w-full bg-white border text-gray-900 rounded block outline-none focus:outline-none focus:ring-0 focus:ring-offset-0 focus:ring-shadow-none text-sm font-normal placeholder:text-sm placeholder:font-normal py-2 px-3 ${
pair.error
? '!border-smyth-red focus:border-smyth-red'
: 'border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500'
} pr-10`}
style={{
- height: '40px',
- minHeight: '40px',
+ minHeight: '36px',
lineHeight: '1.25rem',
}}
+ autoGrow={false}
+ maxHeight={154}
+ rows={1}
/>
<button
onClick={() => {
@@ -543,7 +550,6 @@ const VariablesWidget = ({ agentId, workspace }: { agentId: string; workspace: W
>
<IoKeyOutline className="text-[#424242] scale-x-[-1]" />
</button>
- <div className="absolute bottom-[7px] left-2 w-[calc(100%-16px)] h-1 bg-white"></div>
</div>
{showVaultKeys === index && (
<div className="absolute z-50 mt-1 w-full bg-white border rounded-md shadow-lg vault-keys-dropdown">
diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx
index 41aeac15..e9c428bc 100644
--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx
+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx
@@ -1,4 +1,5 @@
import { getFileCategory, getMimeTypeFromUrl } from '@src/react/features/builder/utils';
+import { Spinner } from '@src/react/shared/components/ui/spinner';
import classNames from 'classnames';
import { TextInput } from 'flowbite-react';
import { useEffect, useState } from 'react';
@@ -112,14 +113,8 @@ const PreviewableAsset = ({ asset }: { asset: string }) => {
return (
<div className="mt-5 relative">
{!stateProps.isContentLoaded && (
- <div className="h-1 mt-1">
- <div
- data-role="progress"
- data-type="line"
- data-small="true"
- data-cls-back="bg-gray-300"
- className="file-preloader h-1"
- ></div>
+ <div className="flex justify-center items-center h-8 mt-1">
+ <Spinner size="sm" />
</div>
)}
diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx
index ccb9b99a..de981de3 100644
--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx
+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx
@@ -1,10 +1,10 @@
import PreviewableAsset from '@src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset';
import { useEndpointFormPreview } from '@src/react/features/builder/contexts/endpoint-form-preview-sidebar.context';
+import { TextArea } from '@src/react/shared/components/ui/newDesign/textarea';
import { FEATURE_FLAGS } from '@src/shared/constants/featureflags';
import { PostHog } from '@src/shared/posthog';
import classNames from 'classnames';
-import { Textarea } from 'flowbite-react';
-import { useEffect, useMemo, useRef, useState } from 'react';
+import { useMemo, useRef, useState } from 'react';
import { FaCheck } from 'react-icons/fa';
import { FaRegCopy } from 'react-icons/fa6';
import { FiDownload } from 'react-icons/fi';
@@ -114,13 +114,8 @@ const ResponseView = () => {
const DEBUG_SERVER = mode.props.dbg_url;
- useEffect(() => {
- if (textareaRef.current) {
- // adjust the height of the textarea to the content
- textareaRef.current.style.height = 'auto';
- textareaRef.current.style.height = Math.min(textareaRef.current.scrollHeight, 400) + 'px';
- }
- }, [textareaRef]);
+ // TextArea component now handles auto-grow with maxHeight prop
+ // Removed redundant useEffect that conflicted with TextArea's internal logic
const extractPreviewableAssets = (content: string) => {
const pattern =
@@ -190,12 +185,15 @@ const ResponseView = () => {
<PreviewableAsset key={asset} asset={asset} />
))}
<div className="mt-5 relative">
- <Textarea
+ <TextArea
ref={textareaRef}
readOnly
- className=" text-gray-800 resize-none"
+ className="text-gray-800 resize-none"
defaultValue={seralizeResponse(lastResponse?.response)}
rows={10}
+ maxHeight={220}
+ autoGrow={true}
+ fullWidth
/>
{/* )} */}
{/* copy and download btns */}
diff --git a/packages/app/src/react/features/embodiments/llm-embodiment-modal.tsx b/packages/app/src/react/features/embodiments/llm-embodiment-modal.tsx
index 6765d48e..cafa7eb9 100644
--- a/packages/app/src/react/features/embodiments/llm-embodiment-modal.tsx
+++ b/packages/app/src/react/features/embodiments/llm-embodiment-modal.tsx
@@ -4,6 +4,7 @@ import React, { useRef, useState } from 'react';
import { CopyKeyIcon, DeleteKeyIcon, InfoIcon } from '../../shared/components/svgs';
import { Input } from '../../shared/components/ui/input';
import { Button } from '../../shared/components/ui/newDesign/button';
+import { TextArea } from '../../shared/components/ui/newDesign/textarea';
import {
Select,
SelectContent,
@@ -13,7 +14,6 @@ import {
} from '../../shared/components/ui/select';
import { Spinner } from '../../shared/components/ui/spinner';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../shared/components/ui/tabs';
-import { Textarea } from '../../shared/components/ui/textarea';
import type { Agent } from '../agents/types/agents.types';
import ModalHeaderEmbodiment from './modal-header-embodiment';
@@ -450,7 +450,7 @@ const LlmEmbodimentModal: React.FC<LlmEmbodimentModalProps> = ({
</div>
</div>
{/* Code block: white background, gray border, grows up to 400px, scrolls if needed */}
- <Textarea
+ <TextArea
ref={codeRef}
value={codeSample.code}
readOnly
diff --git a/packages/app/src/react/features/vault/components/api-keys.tsx b/packages/app/src/react/features/vault/components/api-keys.tsx
index 8b47826b..d0a3f405 100644
--- a/packages/app/src/react/features/vault/components/api-keys.tsx
+++ b/packages/app/src/react/features/vault/components/api-keys.tsx
@@ -14,7 +14,7 @@ import {
import { Input } from '@src/react/shared/components/ui/input';
import { Label } from '@src/react/shared/components/ui/label';
import { Button as CustomButton } from '@src/react/shared/components/ui/newDesign/button';
-import { Textarea } from '@src/react/shared/components/ui/textarea';
+import { TextArea } from '@src/react/shared/components/ui/newDesign/textarea';
import { errorToast, successToast } from '@src/shared/components/toast';
import classNames from 'classnames';
import { Tooltip } from 'flowbite-react';
@@ -287,7 +287,7 @@ export const UpdateApiKeyDialog: FC<UpdateApiKeyDialogProps> = ({
Key <span className="text-red-500">*</span>
</Label>
- <Textarea
+ <TextArea
id="key"
value={formData.key}
onChange={(e) => handleInputChange('key', e.target.value)}
diff --git a/packages/app/src/react/features/vault/components/create-enterprise-modal.tsx b/packages/app/src/react/features/vault/components/create-enterprise-modal.tsx
index d8a05035..ad64f52b 100644
--- a/packages/app/src/react/features/vault/components/create-enterprise-modal.tsx
+++ b/packages/app/src/react/features/vault/components/create-enterprise-modal.tsx
@@ -21,6 +21,7 @@ import {
import { Input } from '@src/react/shared/components/ui/input';
import { Label } from '@src/react/shared/components/ui/label';
import { Button as CustomButton } from '@src/react/shared/components/ui/newDesign/button';
+import { TextArea } from '@src/react/shared/components/ui/newDesign/textarea';
import {
Select,
SelectContent,
@@ -29,7 +30,6 @@ import {
SelectValue,
} from '@src/react/shared/components/ui/select';
import { Spinner } from '@src/react/shared/components/ui/spinner';
-import { Textarea } from '@src/react/shared/components/ui/textarea';
import {
CUSTOM_LLM_FEATURES,
CUSTOM_LLM_PROVIDERS,
@@ -544,12 +544,10 @@ const JsonCredentialsField = ({ form }) => (
<Label htmlFor="settings.jsonCredentials" className="text-right">
JSON Credentials <span className="text-red-500">*</span>
</Label>
- <Textarea
+ <TextArea
id="settings.jsonCredentials"
{...form.register('settings.jsonCredentials')}
- className={`min-h-[100px] ${
- form.formState.errors.settings?.jsonCredentials ? 'border-red-500' : ''
- }`}
+ className={`${form.formState.errors.settings?.jsonCredentials ? 'border-red-500' : ''}`}
fullWidth
/>
{form.formState.errors.settings?.jsonCredentials && (
diff --git a/packages/app/src/react/features/vault/components/create-oauth-connection-modal.tsx b/packages/app/src/react/features/vault/components/create-oauth-connection-modal.tsx
index b0178bc8..99c71e57 100644
--- a/packages/app/src/react/features/vault/components/create-oauth-connection-modal.tsx
+++ b/packages/app/src/react/features/vault/components/create-oauth-connection-modal.tsx
@@ -9,6 +9,7 @@ import {
import { Input } from '@src/react/shared/components/ui/input';
import { Label } from '@src/react/shared/components/ui/label';
import { Button as CustomButton } from '@src/react/shared/components/ui/newDesign/button'; // Your custom button
+import { TextArea } from '@src/react/shared/components/ui/newDesign/textarea';
import {
Select,
SelectContent,
@@ -16,7 +17,6 @@ import {
SelectTrigger,
SelectValue,
} from '@src/react/shared/components/ui/select';
-import { Textarea } from '@src/react/shared/components/ui/textarea';
import { OAuthServicesRegistry } from '@src/shared/helpers/oauth/oauth-services.helper';
import {
OAUTH_SERVICES,
@@ -421,12 +421,11 @@ export function CreateOAuthConnectionModal({
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="scope">Scopes</Label>
<div className="col-span-3">
- <Textarea
+ <TextArea
id="scope"
name="scope"
value={formData.scope || ''}
onChange={handleChange}
- className="min-h-[70px] h-[70px] resize-none"
placeholder="Enter scopes separated by space"
disabled={isProcessing}
fullWidth={true}
diff --git a/packages/app/src/react/features/vault/components/user-models.tsx b/packages/app/src/react/features/vault/components/user-models.tsx
index d426bf04..6247703a 100644
--- a/packages/app/src/react/features/vault/components/user-models.tsx
+++ b/packages/app/src/react/features/vault/components/user-models.tsx
@@ -113,7 +113,6 @@ function SetupModal({ isOpen, onClose, model, existingKey, isEdit }: SetupModalP
// Validate length on every change, but not emptiness
validateApiKey(e.target.value, false);
}}
- className="min-h-[80px]"
error={!!apiKeyError}
errorMessage={apiKeyError}
fullWidth
diff --git a/packages/app/src/react/shared/components/ui/newDesign/textarea.tsx b/packages/app/src/react/shared/components/ui/newDesign/textarea.tsx
index 817e9b58..20012150 100644
--- a/packages/app/src/react/shared/components/ui/newDesign/textarea.tsx
+++ b/packages/app/src/react/shared/components/ui/newDesign/textarea.tsx
@@ -1,122 +1,229 @@
import { cn } from '@react/shared/utils/general';
import { Tooltip } from 'flowbite-react';
import { Info } from 'lucide-react';
-import React from 'react';
+import React, { useEffect, useRef } from 'react';
import { BiExpandAlt } from 'react-icons/bi';
import { FaCircleExclamation } from 'react-icons/fa6';
type CustomTextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
+ /** Placeholder text for the textarea */
placeholder?: string;
+ /** Name attribute for the textarea */
name?: string;
+ /** Current value of the textarea */
value?: string;
+ /** Change event handler */
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
+ /** Callback for expand button click */
onExpand?: () => void;
+ /** Whether textarea should take full width */
fullWidth?: boolean;
+ /** ID attribute for the textarea */
id?: string;
+ /** Whether the textarea is disabled */
disabled?: boolean;
+ /** Whether the textarea is required */
required?: boolean;
+ /** Label text */
label?: string;
+ /** Additional CSS classes for label */
labelClassName?: string;
+ /** Sub-label text shown below main label */
subLabel?: string;
+ /** Example text shown after label */
labelExample?: string;
+ /** Additional CSS classes for textarea */
className?: string;
+ /** Whether there's an error state */
error?: boolean;
+ /** Error message to display */
errorMessage?: string;
+ /** Number of visible rows (default: 2) */
rows?: number;
+ /** Tooltip content for info icon */
infoTooltip?: React.ReactNode;
+ /** Enable auto-grow functionality (default: true) */
+ autoGrow?: boolean;
+ /** Maximum height in pixels before scrolling (default: 200) */
+ maxHeight?: number;
};
-export function TextArea({
- placeholder,
- className,
- name,
- onChange,
- onExpand,
- value,
- fullWidth,
- id,
- disabled,
- required,
- label,
- labelClassName,
- subLabel,
- labelExample,
- error,
- errorMessage,
- rows = 3,
- infoTooltip,
- ...props
-}: CustomTextAreaProps) {
- return (
- <div className={`${fullWidth ? 'w-full' : ''}`}>
- {label && (
- <div className={cn(`text-gray-700 mb-1 text-sm font-normal flex items-center ${labelClassName}`)}>
- {label} {required && <span className="text-red-500 mr-1">*</span>}{' '}
- <span className="italic text-sm text-gray-500">{labelExample}</span>
- {!!infoTooltip && (
- <Tooltip className="w-52 text-center" content={infoTooltip}>
- <Info className="w-4 h-4 ml-2" />
- </Tooltip>
- )}
- </div>
- )}
+/**
+ * Enhanced TextArea component with auto-grow functionality
+ *
+ * Features:
+ * - Defaults to 2 lines height for consistent UX
+ * - Auto-grows vertically as content increases
+ * - Respects min-height constraints from existing CSS classes
+ * - Shows scrollbar when maxHeight is reached
+ * - Smooth transitions for height changes
+ * - Support for labels, error states, tooltips, and expand functionality
+ *
+ * @example
+ * ```tsx
+ * <TextArea
+ * label="Description"
+ * placeholder="Enter description..."
+ * value={value}
+ * onChange={handleChange}
+ * autoGrow={true}
+ * maxHeight={300}
+ * />
+ * ```
+ */
+export const TextArea = React.forwardRef<HTMLTextAreaElement, CustomTextAreaProps>(
+ (
+ {
+ placeholder,
+ className,
+ name,
+ onChange,
+ onExpand,
+ value,
+ fullWidth,
+ id,
+ disabled,
+ required,
+ label,
+ labelClassName,
+ subLabel,
+ labelExample,
+ error,
+ errorMessage,
+ rows = 2,
+ infoTooltip,
+ autoGrow = true, // Default to auto-grow enabled
+ maxHeight = 176, // Default max height for 8 rows: (20px line-height × 8) + (8px padding × 2) = 176px
+ ...props
+ },
+ ref,
+ ) => {
+ const internalRef = useRef<HTMLTextAreaElement>(null);
+
+ // Auto-grow functionality
+ const adjustHeight = (element: HTMLTextAreaElement) => {
+ if (!autoGrow) return;
+
+ // For empty content, reset to minimum height immediately
+ if (!element.value || element.value.trim() === '') {
+ const computedStyle = window.getComputedStyle(element);
+ const minHeight = parseInt(computedStyle.minHeight) || 56; // Default 2-row minimum
+ element.style.height = `${minHeight}px`;
+ element.style.overflowY = 'hidden';
+ return;
+ }
+
+ // Reset height to auto to get the correct scrollHeight
+ element.style.height = 'auto';
+
+ // Get the computed min-height to respect CSS constraints
+ const computedStyle = window.getComputedStyle(element);
+ const minHeight = parseInt(computedStyle.minHeight) || 56;
+
+ // Calculate the new height, respecting both minHeight and maxHeight
+ const contentHeight = element.scrollHeight;
+ const newHeight = Math.max(minHeight, Math.min(contentHeight, maxHeight));
+
+ // Set the new height
+ element.style.height = `${newHeight}px`;
+ element.style.overflowY = contentHeight > maxHeight ? 'auto' : 'hidden';
+ };
+
+ // Auto-grow effect
+ useEffect(() => {
+ const textarea = internalRef.current;
+ if (textarea && autoGrow) {
+ adjustHeight(textarea);
+ }
+ }, [value, autoGrow, maxHeight]);
+
+ // Handle both internal ref and forwarded ref
+ useEffect(() => {
+ if (typeof ref === 'function') {
+ ref(internalRef.current);
+ } else if (ref) {
+ ref.current = internalRef.current;
+ }
+ }, [ref]);
- {subLabel && <p className="text-sm text-gray-500 mb-2 mt-0.5">{subLabel}</p>}
- <div className={`relative ${fullWidth ? 'w-full' : 'w-fit'}`}>
- <textarea
- name={name}
- id={id}
- rows={rows}
- className={`
- bg-white
- border
- text-gray-900
- rounded
- block
- w-full
- outline-none
- focus:outline-none
- focus:ring-0
- focus:ring-offset-0
- focus:ring-shadow-none
- text-sm
- font-normal
- placeholder:text-sm
- placeholder:font-normal
- py-2
- px-3
- ${
+ // Enhanced onChange handler to trigger auto-grow
+ const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
+ if (autoGrow) {
+ // Delay to allow React to update the value
+ setTimeout(() => adjustHeight(event.target), 0);
+ }
+
+ // Call the original onChange if provided
+ if (onChange) {
+ onChange(event);
+ }
+ };
+ return (
+ <div className={`${fullWidth ? 'w-full' : ''}`}>
+ {label && (
+ <div
+ className={cn(
+ `text-gray-700 mb-1 text-sm font-normal flex items-center ${labelClassName}`,
+ )}
+ >
+ {label} {required && <span className="text-red-500 mr-1">*</span>}{' '}
+ <span className="italic text-sm text-gray-500">{labelExample}</span>
+ {!!infoTooltip && (
+ <Tooltip className="w-52 text-center" content={infoTooltip}>
+ <Info className="w-4 h-4 ml-2" />
+ </Tooltip>
+ )}
+ </div>
+ )}
+
+ {subLabel && <p className="text-sm text-gray-500 mb-2 mt-0.5">{subLabel}</p>}
+ <div className={`relative ${fullWidth ? 'w-full' : 'w-fit'}`}>
+ <textarea
+ ref={internalRef}
+ name={name}
+ id={id}
+ rows={autoGrow ? undefined : rows} // Don't set rows if auto-grow is enabled
+ className={cn(
+ 'resize-none bg-white border text-gray-900 rounded block w-full outline-none focus:outline-none focus:ring-0 focus:ring-offset-0 focus:ring-shadow-none text-sm font-normal placeholder:text-sm placeholder:font-normal py-2 px-3 transition-all duration-150 ease-in-out',
error
? '!border-[#C50F1F] focus:border-[#C50F1F]'
- : 'border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500'
- }
- ${disabled ? 'text-gray-400 border-gray-200' : ''}
- ${className || ''}
- `}
- placeholder={placeholder}
- onChange={onChange}
- value={value}
- disabled={disabled}
- required={required}
- {...props}
- />
- {onExpand && (
- <button
- type="button"
- onClick={onExpand}
- className="absolute bottom-2 right-2 text-gray-500 hover:text-gray-700 opacity-50 hover:opacity-100 transition-opacity"
- aria-label="Maximize behavior textarea"
- >
- <BiExpandAlt className="fa-md" />
- </button>
+ : 'border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500',
+ disabled ? 'text-gray-400 border-gray-200' : '',
+ // resize-none is now applied by default in base classes above
+ className,
+ )}
+ placeholder={placeholder}
+ onChange={handleChange}
+ value={value}
+ disabled={disabled}
+ required={required}
+ style={{
+ minHeight: autoGrow ? '56px' : undefined, // Exact height for 2 lines
+ maxHeight: autoGrow ? `${maxHeight}px` : undefined, // Max height before scrolling
+ lineHeight: '20px', // Fixed line height matching leading-5
+ }}
+ {...props}
+ />
+ {onExpand && (
+ <button
+ type="button"
+ onClick={onExpand}
+ className="absolute bottom-2 right-2 text-gray-500 hover:text-gray-700 opacity-50 hover:opacity-100 transition-opacity"
+ aria-label="Maximize behavior textarea"
+ >
+ <BiExpandAlt className="fa-md" />
+ </button>
+ )}
+ </div>
+ {error && errorMessage && (
+ <div className="flex items-start mt-[2px]">
+ <FaCircleExclamation className="text-red-500 mr-1 w-[10px] h-[10px] mt-[3px]" />
+ <p className="text-[12px] text-red-500 font-normal">{errorMessage}</p>
+ </div>
)}
</div>
- {error && errorMessage && (
- <div className="flex items-start mt-[2px]">
- <FaCircleExclamation className="text-red-500 mr-1 w-[10px] h-[10px] mt-[3px]" />
- <p className="text-[12px] text-red-500 font-normal">{errorMessage}</p>
- </div>
- )}
- </div>
- );
-}
+ );
+ },
+);
+
+TextArea.displayName = 'TextArea';
diff --git a/packages/app/src/react/shared/components/ui/textarea.tsx b/packages/app/src/react/shared/components/ui/textarea.tsx
deleted file mode 100644
index 3c89d55f..00000000
--- a/packages/app/src/react/shared/components/ui/textarea.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import * as React from 'react';
-
-import { cn } from '@react/shared/utils/general';
-import { FaCircleExclamation } from 'react-icons/fa6';
-
-export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
- error?: boolean;
- fullWidth?: boolean;
- label?: string;
- required?: boolean;
- labelExample?: string;
- errorMessage?: string;
-}
-
-const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
- ({ className, error, fullWidth, label, required, labelExample, errorMessage, ...props }, ref) => {
- return (
- <div className={`${fullWidth ? 'w-full' : ''}`}>
- {label && (
- <div className="text-gray-700 mb-1 text-sm font-normal">
- {label} {required && <span className="text-red-500 mr-1">*</span>}{' '}
- <span className="italic text-sm text-gray-500">{labelExample}</span>
- </div>
- )}
- <div className={`relative ${fullWidth ? 'w-full' : 'w-fit'}`}>
- <textarea
- className={cn(
- `h-9 w-full bg-white
- border
- text-gray-900
- rounded
- block
- outline-none
- focus:outline-none
- focus:ring-0
- focus:ring-offset-0
- focus:ring-shadow-none
- text-sm
- font-normal
- placeholder:text-sm
- placeholder:font-normal
- px-[10px]`,
- error
- ? '!border-[#C50F1F] focus:border-[#C50F1F]'
- : 'border-gray-300 border-b-gray-500 focus:border-b-2 focus:border-b-blue-500 focus-visible:border-b-2 focus-visible:border-b-blue-500',
- className,
- )}
- ref={ref}
- {...props}
- />
- </div>
- {error && errorMessage && (
- <div className="flex items-start mt-[2px]">
- <FaCircleExclamation className="text-red-500 mr-1 w-[10px] h-[10px] mt-[3px]" />
- <p className="text-[12px] text-red-500 font-normal">{errorMessage}</p>
- </div>
- )}
- </div>
- );
- },
-);
-Textarea.displayName = 'Textarea';
-
-export { Textarea };
diff --git a/packages/app/static/css/smyth-builder-override.css b/packages/app/static/css/smyth-builder-override.css
index 3b413ae4..5cb7ecff 100644
--- a/packages/app/static/css/smyth-builder-override.css
+++ b/packages/app/static/css/smyth-builder-override.css
@@ -582,7 +582,7 @@
}
/* Show title tooltip on hover (no JS) */
-.right-sidebar .right-sidebar-title .title:hover [role="tooltip"] {
+.right-sidebar .right-sidebar-title .title:hover [role='tooltip'] {
opacity: 1 !important;
visibility: visible !important;
}
@@ -1070,8 +1070,12 @@ code.language-plan.done::before {
font-weight: normal;
line-height: 1.25rem;
outline: none;
- min-height: 80px;
- transition: border-bottom-color 0.3s ease-in-out;
+ min-height: 56px !important; /* 2 row minimum height */
+ max-height: 176px !important; /* 8 row maximum height */
+ transition: all 0.15s ease-in-out;
+ resize: none !important;
+ overflow: hidden;
+ overflow-y: auto !important;
}
.dlg-form .textarea textarea:focus,
@@ -1272,4 +1276,4 @@ body.locked nav #builder-button svg {
/* Inspect button icon hover state - ensure it works when debug is off */
#cmp-inspect-btn:hover svg path {
stroke: white !important;
-}
\ No newline at end of file
+}
diff --git a/packages/app/static/css/smyth-global.css b/packages/app/static/css/smyth-global.css
index 2648e813..3f1dc533 100644
--- a/packages/app/static/css/smyth-global.css
+++ b/packages/app/static/css/smyth-global.css
@@ -1460,3 +1460,35 @@ html {
background-color: #c2d8fc !important;
/* smythos-blue-100 */
}
+
+/* Hide textarea resize handles completely across all browsers */
+textarea::-webkit-resizer {
+ display: none !important;
+ visibility: hidden !important;
+ opacity: 0 !important;
+ width: 0 !important;
+ height: 0 !important;
+}
+
+textarea::-moz-resizer {
+ display: none !important;
+ visibility: hidden !important;
+ opacity: 0 !important;
+ width: 0 !important;
+ height: 0 !important;
+}
+
+/* Ensure no resize handles appear on any textarea elements */
+textarea.resize-none,
+textarea[class*='resize-none'] {
+ resize: none !important;
+}
+
+textarea.resize-none::-webkit-resizer,
+textarea[class*='resize-none']::-webkit-resizer {
+ display: none !important;
+ visibility: hidden !important;
+ opacity: 0 !important;
+ width: 0 !important;
+ height: 0 !important;
+}