Skip to content

feat: setup url autofill for dynamic parameters #17739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 16, 2025
Prev Previous commit
Next Next commit
fix: updates for PR review
  • Loading branch information
jaaydenh committed May 15, 2025
commit 6711e28aa7e982d83b98eae48a7ba13b6bb00301
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ export const MultiSelectCombobox = forwardRef<
})}
{/* Avoid having the "Search" Icon */}
<CommandPrimitive.Input
id={inputProps?.id}
{...inputProps}
ref={inputRef}
value={inputValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import * as Yup from "yup";
export interface DynamicParameterProps {
parameter: PreviewParameter;
value?: string;
onChange: (value: string) => Promise<void>;
onChange: (value: string) => void;
disabled?: boolean;
isPreset?: boolean;
autofill: boolean;
Expand Down Expand Up @@ -203,7 +203,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({
interface DebouncedParameterFieldProps {
parameter: PreviewParameter;
value?: string;
onChange: (value: string) => Promise<void>;
onChange: (value: string) => void;
disabled?: boolean;
id: string;
}
Expand Down Expand Up @@ -239,12 +239,12 @@ const DebouncedParameterField: FC<DebouncedParameterFieldProps> = ({
className="max-w-2xl"
value={localValue}
onChange={(e) => {
setLocalValue(e.target.value);
}}
onInput={(e) => {
const target = e.currentTarget;
target.style.height = "auto";
target.style.maxHeight = "700px";
target.style.height = `${target.scrollHeight}px`;

setLocalValue(e.target.value);
}}
disabled={disabled}
placeholder={parameter.styling?.placeholder}
Expand Down Expand Up @@ -290,7 +290,7 @@ const DebouncedParameterField: FC<DebouncedParameterFieldProps> = ({
interface ParameterFieldProps {
parameter: PreviewParameter;
value?: string;
onChange: (value: string) => Promise<void>;
onChange: (value: string) => void;
disabled?: boolean;
id: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CreateWorkspacePageExperimental: FC = () => {

const [currentResponse, setCurrentResponse] =
useState<DynamicParametersResponse | null>(null);
const [wsResponseId, setWSResponseId] = useState<number>(-1);
const wsResponseId = useRef<number>(-1);
const ws = useRef<WebSocket | null>(null);
const [wsError, setWsError] = useState<Error | null>(null);
const initialParamsSentRef = useRef(false);
Expand Down Expand Up @@ -88,23 +88,17 @@ const CreateWorkspacePageExperimental: FC = () => {
const realizedVersionId =
customVersionId ?? templateQuery.data?.active_version_id;

const autofillParameters = useMemo(
() => getAutofillParameters(searchParams),
[searchParams],
);
const autofillParameters = getAutofillParameters(searchParams);

const sendMessage = useCallback((formValues: Record<string, string>) => {
setWSResponseId((prevId) => {
const request: DynamicParametersRequest = {
id: prevId + 1,
id: wsResponseId.current + 1,
inputs: formValues,
};
if (ws.current && ws.current.readyState === WebSocket.OPEN) {
ws.current.send(JSON.stringify(request));
return prevId + 1;
wsResponseId.current = wsResponseId.current + 1;
}
return prevId;
});
}, []);

// On sends all initial parameter values to the websocket
Expand Down Expand Up @@ -140,7 +134,7 @@ const CreateWorkspacePageExperimental: FC = () => {
const onMessage = useCallback(
(response: DynamicParametersResponse) => {
setCurrentResponse((prev) => {
if (prev?.id === response.id) {
if (prev && prev?.id >= response.id) {
return prev;
}

Expand Down