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.

Enhance APICall component with expandable fields for headers and proxy URLs

Muhammad Hamza Khana8cdc72a369a
diff --git a/packages/app/src/builder-ui/components/APICall.class.ts b/packages/app/src/builder-ui/components/APICall.class.ts
index 80ca3691..5679630b 100644
--- a/packages/app/src/builder-ui/components/APICall.class.ts
+++ b/packages/app/src/builder-ui/components/APICall.class.ts
@@ -133,6 +133,7 @@ export class APICall extends Component {
},
headers: {
type: 'textarea',
+ expandable: true,
label: 'Headers',
readonly: true,
help: 'Add keys the service needs, like Authorization or Content-Type.<br /><a href="${SMYTHOS_DOCS_URL}/agent-studio/components/advanced/api-call/?utm_source=studio&utm_medium=tooltip&utm_campaign=api-call&utm_content=url#step-2-add-headers-and-body" target="_blank" class="text-blue-600 hover:text-blue-800">See header usage</a>',
@@ -341,6 +342,7 @@ export class APICall extends Component {
},
proxy: {
type: 'textarea',
+ expandable: true,
label: 'Proxy URLs',
section: 'Advanced',
help: 'Send calls through a proxy if your network or vendor asks for it.',
diff --git a/packages/app/src/builder-ui/ui/form/fields.ts b/packages/app/src/builder-ui/ui/form/fields.ts
index 6eaad0a0..33c13872 100644
--- a/packages/app/src/builder-ui/ui/form/fields.ts
+++ b/packages/app/src/builder-ui/ui/form/fields.ts
@@ -798,12 +798,9 @@ async function handleExpandTextarea(
// This is used to hide the "Add Key" option in the vault dropdown
modalTextarea.setAttribute('data-vault-from-modal', 'true');
- // Create vault button for modal (always create, show/hide dynamically)
+ // Create vault button for modal
const modalVaultButton = createVaultButton();
textareaWrapper.appendChild(modalVaultButton);
-
- // Initially hide the vault button
- modalVaultButton.style.display = 'none';
}
// Add other action buttons from the original textarea
@@ -924,11 +921,20 @@ async function handleExpandTextarea(
// Remove any existing click handlers and add the vault handler
vaultButton.replaceWith(vaultButton.cloneNode(true));
const newVaultButton = dialogElm.querySelector('.vault-action-btn') as HTMLButtonElement;
- // Create custom vault handler that targets the modal textarea
+ // Create custom vault handler that targets the modal textarea with toggle functionality
newVaultButton.addEventListener('click', async (event) => {
event.preventDefault();
event.stopPropagation();
+ // Check if dropdown is already open
+ const existingDropdown = document.getElementById('vault-keys-dropdown-menu');
+
+ // If dropdown exists, close it (toggle off)
+ if (existingDropdown) {
+ existingDropdown.remove();
+ return;
+ }
+
// Debug: Check the form group and target field
const formGroup = newVaultButton.closest('.form-group');
const targetField = formGroup?.querySelector('[data-vault]');
@@ -1011,7 +1017,8 @@ async function handleExpandTextarea(
}, 1000);
});
- // Show/hide vault button based on condition (following main textarea pattern)
+ // Show/hide vault button based on condition (e.g., content type)
+ // Only show the vault button when the appropriate conditions are met
const shouldShowVault = shouldShowVaultButton(vaultCondition, contentType);
if (shouldShowVault) {
newVaultButton.style.display = 'inline-block';
@@ -1078,6 +1085,12 @@ async function handleExpandTextarea(
onCloseClick(dialogElm: HTMLElement) {
const modalTextareaInDialog = dialogElm.querySelector('textarea') as TextAreaWithEditor;
+ const existingDropdown = document.getElementById('vault-keys-dropdown-menu');
+ if (existingDropdown) {
+ // Dropdown is open, close it (toggle off)
+ existingDropdown.remove();
+ }
+
if (modalTextareaInDialog) {
syncTextareaValues(modalTextareaInDialog, originalTextarea, hasCodeEditor);
}
diff --git a/packages/app/src/builder-ui/utils/component.utils/index.ts b/packages/app/src/builder-ui/utils/component.utils/index.ts
index 736dcbe4..ba64a688 100644
--- a/packages/app/src/builder-ui/utils/component.utils/index.ts
+++ b/packages/app/src/builder-ui/utils/component.utils/index.ts
@@ -189,13 +189,19 @@ export async function handleVaultBtn(event: MouseEvent): Promise<void> {
const vaultBtn = event.target as HTMLButtonElement;
const formGroup = vaultBtn.closest('.form-group') as HTMLElement;
+ // Check if dropdown already exists (toggle functionality)
+ const existingDropdown = document.getElementById('vault-keys-dropdown-menu');
+ if (existingDropdown) {
+ // Dropdown is open, close it (toggle off)
+ existingDropdown.remove();
+ return;
+ }
+
vaultBtn.disabled = true;
handleVaultBtn['loading'] = true;
- let dropdown = document.getElementById('vault-keys-dropdown-menu');
- if (dropdown) dropdown.remove();
-
- dropdown = document.createElement('div');
+ // Create new dropdown
+ const dropdown = document.createElement('div');
dropdown.id = 'vault-keys-dropdown-menu';
const contentElm = document.createElement('div');