Skip to content
Prev Previous commit
Next Next commit
chore: updates for PR review comments
  • Loading branch information
jaaydenh committed May 15, 2025
commit 03dde8a56522d9ca599b51cabf5bae7db567efea
4 changes: 3 additions & 1 deletion site/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const SelectValue = SelectPrimitive.Value;

export const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & { id?: string }
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
id?: string;
}
>(({ className, children, id, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
Expand Down
31 changes: 16 additions & 15 deletions site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import {
TooltipProvider,
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { Info, Link, Settings, TriangleAlert } from "lucide-react";
import { type FC, useEffect, useId, useState } from "react";
import { Info, LinkIcon, Settings, TriangleAlert } from "lucide-react";
import { type FC, useId, useState } from "react";
import type { AutofillBuildParameter } from "utils/richParameters";
import * as Yup from "yup";

Expand Down Expand Up @@ -96,7 +96,6 @@ const ParameterLabel: FC<ParameterLabelProps> = ({
autofill,
id,
}) => {
const hasDescription = parameter.description && parameter.description !== "";
const displayName = parameter.display_name
? parameter.display_name
: parameter.name;
Expand Down Expand Up @@ -163,7 +162,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({
<TooltipTrigger asChild>
<span className="flex items-center">
<Badge size="sm">
<Link />
<LinkIcon />
URL Autofill
</Badge>
</span>
Expand All @@ -176,7 +175,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({
)}
</Label>

{hasDescription && (
{Boolean(parameter.description) && (
<div className="text-content-secondary">
<MemoizedMarkdown className="text-xs">
{parameter.description}
Expand Down Expand Up @@ -204,7 +203,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
id,
}) => {
const [localValue, setLocalValue] = useState(
value !== undefined ? value : validValue(parameter.value)
value !== undefined ? value : validValue(parameter.value),
);
if (value !== undefined && value !== localValue) {
setLocalValue(value);
Expand All @@ -215,7 +214,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
return (
<Select
onValueChange={onChange}
value={value}
value={localValue}
disabled={disabled}
required={parameter.required}
>
Expand All @@ -235,7 +234,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
);

case "multi-select": {
const values = parseStringArrayValue(value ?? "");
const values = parseStringArrayValue(localValue ?? "");

// Map parameter options to MultiSelectCombobox options format
const options: Option[] = parameter.options.map((opt) => ({
Expand Down Expand Up @@ -280,7 +279,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
}

case "tag-select": {
const values = parseStringArrayValue(value ?? "");
const values = parseStringArrayValue(localValue ?? "");

return (
<TagInput
Expand All @@ -298,7 +297,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
return (
<Switch
id={id}
checked={value === "true"}
checked={localValue === "true"}
onCheckedChange={(checked) => {
onChange(checked ? "true" : "false");
}}
Expand All @@ -308,7 +307,11 @@ const ParameterField: FC<ParameterFieldProps> = ({

case "radio":
return (
<RadioGroup onValueChange={onChange} disabled={disabled} value={value}>
<RadioGroup
onValueChange={onChange}
disabled={disabled}
value={localValue}
>
{parameter.options.map((option) => (
<div
key={option.value.value}
Expand All @@ -334,7 +337,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
<div className="flex items-center space-x-2">
<Checkbox
id={id}
checked={value === "true"}
checked={localValue === "true"}
onCheckedChange={(checked) => {
onChange(checked ? "true" : "false");
}}
Expand Down Expand Up @@ -513,9 +516,7 @@ export const getInitialParameterValues = (
);

const useAutofill =
autofillParam &&
isValidParameterOption(parameter, autofillParam) &&
autofillParam.value;
autofillParam?.value && isValidParameterOption(parameter, autofillParam);

return {
name: parameter.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
useContext,
useEffect,
useId,
useMemo,
useRef,
useState,
} from "react";
Expand Down Expand Up @@ -153,7 +152,7 @@ export const CreateWorkspacePageViewExperimental: FC<

const formValues = form.values.rich_parameter_values;
if (parameters.length > 0 && formValues && formValues.length > 0) {
const initialParams: { [k: string]: string } = {};
const initialParams: Record<string, string> = {};
for (const param of formValues) {
if (param.name && param.value) {
initialParams[param.name] = param.value;
Expand All @@ -166,12 +165,8 @@ export const CreateWorkspacePageViewExperimental: FC<
}
}, [parameters, form.values.rich_parameter_values, sendMessage]);

const autofillByName = useMemo(
() =>
Object.fromEntries(
autofillParameters.map((param) => [param.name, param]),
),
[autofillParameters],
const autofillByName = Object.fromEntries(
autofillParameters.map((param) => [param.name, param]),
);

useEffect(() => {
Expand Down Expand Up @@ -251,7 +246,7 @@ export const CreateWorkspacePageViewExperimental: FC<
parameter: PreviewParameter,
value: string,
) => {
const formInputs: { [k: string]: string } = {};
const formInputs: Record<string, string> = {};
formInputs[parameter.name] = value;
const parameters = form.values.rich_parameter_values ?? [];

Expand Down