Skip to content

Self-improving AI Employees for everyone

feat(ui): Wave 10.G.1 — ParameterRenderer widget gaps

trohitgde876037adc0
diff --git a/client/src/adapters/nodeSpecToDescription.ts b/client/src/adapters/nodeSpecToDescription.ts
index 1eb045b3..8b5a863c 100644
--- a/client/src/adapters/nodeSpecToDescription.ts
+++ b/client/src/adapters/nodeSpecToDescription.ts
@@ -96,9 +96,14 @@ type InodeType = INodeProperties['type'];
*/
function mapPropertyType(prop: JsonSchemaProperty): InodeType {
if (prop.enum && prop.enum.length > 0) return 'options';
- if (prop.uiHints?.editor === 'code') return 'code';
- if (prop.uiHints?.editor === 'json') return 'json';
- if (prop.uiHints?.widget === 'file' || prop.format === 'binary') return 'file';
+ // Pydantic Field(json_schema_extra={"editor": "code"}) lands at the
+ // property top-level; nested ``uiHints: {...}`` is the alternate
+ // location. Check both so authors can use either.
+ const editor = (prop as any).editor ?? prop.uiHints?.editor;
+ if (editor === 'code') return 'code';
+ if (editor === 'json') return 'json';
+ const widget = (prop as any).widget ?? prop.uiHints?.widget;
+ if (widget === 'file' || prop.format === 'binary') return 'file';
if (prop.format === 'date-time' || prop.format === 'date') return 'dateTime';
// anyOf([T, null]) is the Pydantic Optional[T] pattern — take the non-null branch.
if (prop.anyOf) {
diff --git a/client/src/components/ParameterRenderer.tsx b/client/src/components/ParameterRenderer.tsx
index 397fda0d..233202e5 100644
--- a/client/src/components/ParameterRenderer.tsx
+++ b/client/src/components/ParameterRenderer.tsx
@@ -11,6 +11,8 @@ import { useAppTheme } from '../hooks/useAppTheme';
import { API_CONFIG } from '../config/api';
import { useWebSocket } from '../contexts/WebSocketContext';
import { useApiKeys } from '../hooks/useApiKeys';
+import { Input as ShadcnInput } from './ui/input';
+import { shouldShowParameter } from '../utils/parameterVisibility';
// Map node types to provider keys for AI model nodes
import { AI_MODEL_PROVIDER_MAP } from '../nodeDefinitions/aiModelNodes';
@@ -910,23 +912,35 @@ const FixedCollectionRenderer: React.FC<{
backgroundColor: theme.colors.background,
padding: '12px'
}}>
- {option.values?.map((valueParam: any) => (
- <ParameterRenderer
- key={valueParam.name}
- parameter={valueParam}
- value={optionValue[valueParam.name]}
- onChange={(newValue) => {
- onChange({
- ...currentValue,
- [option.name]: {
- ...optionValue,
- [valueParam.name]: newValue
- }
- });
- }}
- allParameters={allParameters}
- />
- ))}
+ {option.values?.map((valueParam: any) => {
+ // Wave 10.G.1: propagate `displayOptions.show` into nested
+ // fixedCollection renders. Without this, sub-parameters with
+ // conditional visibility render unconditionally inside the
+ // collection, showing fields whose gate isn't satisfied.
+ // The visibility context is the merged {allParameters, option
+ // sub-values}, so a `show: {<siblingInCollection>: [...]}`
+ // can gate on sibling values too.
+ if (!shouldShowParameter(valueParam, { ...allParameters, ...optionValue })) {
+ return null;
+ }
+ return (
+ <ParameterRenderer
+ key={valueParam.name}
+ parameter={valueParam}
+ value={optionValue[valueParam.name]}
+ onChange={(newValue) => {
+ onChange({
+ ...currentValue,
+ [option.name]: {
+ ...optionValue,
+ [valueParam.name]: newValue,
+ },
+ });
+ }}
+ allParameters={allParameters}
+ />
+ );
+ })}
</div>
</div>
);
@@ -970,7 +984,7 @@ const ParameterRenderer: React.FC<ParameterRendererProps> = ({
const [nodeParameters, setNodeParameters] = useState<Record<string, any>>({});
const { selectedNode } = useAppStore();
- const { getNodeParameters } = useWebSocket();
+ const { getNodeParameters, sendRequest } = useWebSocket();
const { getStoredApiKey, hasStoredKey, getStoredModels, getProviderDefaults } = useApiKeys();
// Don't render hidden parameters
@@ -1126,26 +1140,44 @@ const ParameterRenderer: React.FC<ParameterRendererProps> = ({
const nodeType = selectedNode.data?.nodeType || selectedNode.type;
const nodeDef = nodeType ? nodeDefinitions[nodeType] : null;
- if (nodeDef?.methods?.loadOptions?.[parameter.typeOptions.loadOptionsMethod]) {
- const loadMethod = nodeDef.methods.loadOptions[parameter.typeOptions.loadOptionsMethod];
+ let rawOptions: Array<{ value: any; name?: string; label?: string }> = [];
+ const method = parameter.typeOptions.loadOptionsMethod;
- // Create context for the load method
+ if (nodeDef?.methods?.loadOptions?.[method]) {
+ // Legacy frontend-defined loader (rare — most nodes are slimmed).
+ const loadMethod = nodeDef.methods.loadOptions[method];
const context = {
- getCurrentNodeParameter: (paramName: string) => allParamsResolved[paramName]
+ getCurrentNodeParameter: (paramName: string) => allParamsResolved[paramName],
};
+ rawOptions = await loadMethod.call(context);
+ } else {
+ // Wave 10.G.1: dispatch to backend loader via the unified
+ // `load_options` WS handler (server/routers/websocket.py:281).
+ // Every non-WhatsApp loadOptionsMethod goes through here now —
+ // Google Workspace (gmailLabels / googleCalendarList / etc.),
+ // Android services, and any future backend-registered loader.
+ try {
+ const res = await sendRequest<{ options: Array<{ value: any; label?: string }> }>(
+ 'load_options',
+ { method, params: { node_id: selectedNode.id, ...allParamsResolved } },
+ );
+ rawOptions = res?.options ?? [];
+ } catch (err) {
+ console.error(`[ParameterRenderer] backend load_options(${method}) failed:`, err);
+ }
+ }
- // Call the load method with context
- const options = await loadMethod.call(context);
- setDynamicOptions(options);
-
- // Also update the DynamicParameterService for consistency
- DynamicParameterService.updateParameterOptions(selectedNode.id, parameter.name, options);
+ // Backend returns `{value, label}`; INodePropertyOption wants
+ // `{name, value}`. Normalise while preserving the original label.
+ const options = rawOptions.map(o => ({
+ name: o.name ?? o.label ?? String(o.value),
+ value: o.value,
+ }));
- // Auto-select first option if current value is empty and options are available
- if (options.length > 0 && (!currentValue || currentValue === '')) {
- console.log(`[ParameterRenderer] Auto-selecting first option for ${parameter.name}:`, options[0].value);
- onChange(options[0].value);
- }
+ setDynamicOptions(options);
+ DynamicParameterService.updateParameterOptions(selectedNode.id, parameter.name, options);
+ if (options.length > 0 && (!currentValue || currentValue === '')) {
+ onChange(options[0].value);
}
} catch (error) {
console.error('Error loading dynamic options:', error);
@@ -1331,7 +1363,13 @@ const ParameterRenderer: React.FC<ParameterRendererProps> = ({
// Check if this is a code editor
const isCodeEditor = (parameter as any).typeOptions?.editor === 'code';
- if (shouldUseTextarea) {
+ // Wave 10.G.1: `password: true` must win over multi-row textarea —
+ // a multi-line field (e.g. rows:1 + password:true) used to render as
+ // plain textarea because the textarea branch below never checked
+ // `isPassword`. Downgrade to `<input type="password">` in that case.
+ if (shouldUseTextarea && isPassword) {
+ // fall through to the non-textarea branch so masking is honoured.
+ } else if (shouldUseTextarea) {
// Use CodeEditor for code editing
if (isCodeEditor) {
// Show loading state while parameters are being fetched
@@ -2104,6 +2142,40 @@ const ParameterRenderer: React.FC<ParameterRendererProps> = ({
/>
);
+ case 'code': {
+ // Wave 10.G.1: dedicated widget for Pydantic fields tagged
+ // `json_schema_extra={"editor": "code"}`. Before this case the
+ // adapter mapped them to INodeProperties.type='code' but the
+ // switch had no handler — they rendered as
+ // "Unsupported parameter type: code".
+ const codeLanguage = (parameter as any).typeOptions?.editorLanguage || 'python';
+ if (isLoadingParameters) {
+ return (
+ <div className="flex items-center justify-center rounded-md border border-border bg-muted text-muted-foreground text-sm min-h-[200px]">
+ Loading code...
+ </div>
+ );
+ }
+ return (
+ <CodeEditor
+ value={currentValue || parameter.default || ''}
+ onChange={onChange}
+ language={codeLanguage}
+ placeholder={parameter.placeholder}
+ />
+ );
+ }
+
+ case 'dateTime':
+ // shadcn Input — see client/src/components/ui/input.tsx
+ return (
+ <ShadcnInput
+ type="datetime-local"
+ value={currentValue || parameter.default || ''}
+ onChange={(e) => onChange(e.target.value)}
+ />
+ );
+
default:
return <div style={{ color: theme.colors.error, fontSize: '14px', padding: '8px 12px', backgroundColor: `${theme.colors.error}15`, border: `1px solid ${theme.colors.error}30`, borderRadius: '6px' }}>Unsupported parameter type: {parameter.type}</div>;
}
diff --git a/client/src/components/parameterPanel/MiddleSection.tsx b/client/src/components/parameterPanel/MiddleSection.tsx
index ca3b7959..fddcb339 100644
--- a/client/src/components/parameterPanel/MiddleSection.tsx
+++ b/client/src/components/parameterPanel/MiddleSection.tsx
@@ -39,6 +39,7 @@ import { INodeTypeDescription, INodeProperties } from '../../types/INodeProperti
import { ExecutionResult } from '../../services/executionService';
import { Edge } from 'reactflow';
import { SKILL_NODE_TYPES, skillNodes } from '../../nodeDefinitions/skillNodes';
+import { shouldShowParameter } from '../../utils/parameterVisibility';
// Tool node types that support schema editing
const TOOL_NODE_TYPES = ['androidTool', 'calculatorTool', 'currentTimeTool', 'duckduckgoSearch'];
@@ -90,29 +91,8 @@ interface MiddleSectionProps {
executionResults?: ExecutionResult[];
}
-const shouldShowParameter = (param: INodeProperties, allParameters: Record<string, any>): boolean => {
- if (!param.displayOptions?.show) {
- return true;
- }
-
- const showConditions = param.displayOptions.show;
-
- for (const [paramName, allowedValues] of Object.entries(showConditions)) {
- const currentValue = allParameters[paramName];
-
- if (Array.isArray(allowedValues)) {
- if (!allowedValues.includes(currentValue)) {
- return false;
- }
- } else {
- if (currentValue !== allowedValues) {
- return false;
- }
- }
- }
-
- return true;
-};
+// shouldShowParameter moved to utils/parameterVisibility for sharing
+// with ParameterRenderer's nested fixedCollection/collection recursion.
const MiddleSection: React.FC<MiddleSectionProps> = ({
nodeId,
diff --git a/client/src/utils/parameterVisibility.ts b/client/src/utils/parameterVisibility.ts
new file mode 100644
index 00000000..9045378f
--- /dev/null
+++ b/client/src/utils/parameterVisibility.ts
@@ -0,0 +1,29 @@
+import type { INodeProperties } from '../types/INodeProperties';
+
+/**
+ * Wave 10.G.1: shared displayOptions visibility evaluator.
+ *
+ * Extracted from MiddleSection so ParameterRenderer can apply the same
+ * logic inside nested fixedCollection / collection recursions — the
+ * previous behaviour rendered nested sub-parameters unconditionally
+ * even when their `displayOptions.show` conditions weren't met.
+ *
+ * Contract: `param.displayOptions.show` is an AND-combined map of
+ * { paramName: allowedValue | allowedValue[] }. All conditions must
+ * hold against `allParameters` for the param to render.
+ */
+export const shouldShowParameter = (
+ param: INodeProperties,
+ allParameters: Record<string, any>,
+): boolean => {
+ if (!param.displayOptions?.show) return true;
+ for (const [name, allowed] of Object.entries(param.displayOptions.show)) {
+ const current = allParameters[name];
+ if (Array.isArray(allowed)) {
+ if (!allowed.includes(current)) return false;
+ } else if (current !== allowed) {
+ return false;
+ }
+ }
+ return true;
+};