@@ -55,6 +55,7 @@ import {
5555 SelectValue ,
5656} from "@/client/components/Select" ;
5757import { mockUsers } from "@/owner" ;
58+ import { checkerModule } from "./snippets" ;
5859
5960export const Preview : FC = ( ) => {
6061 const $wasmState = useStore ( ( state ) => state . wasmState ) ;
@@ -107,6 +108,7 @@ export const Preview: FC = () => {
107108 const rawOutput = await window . go_preview ?.(
108109 {
109110 "main.tf" : debouncedCode ,
111+ "checker/main.tf" : checkerModule ,
110112 } ,
111113 $owner ,
112114 $form ,
@@ -529,24 +531,28 @@ const Log: FC<LogProps> = ({ log }) => {
529531type FormProps = { parameters : ParameterWithSource [ ] } ;
530532
531533const Form : FC < FormProps > = ( { parameters } ) => {
532- return parameters
533- . sort ( ( a , b ) => a . order - b . order )
534- // Since the form is sourced from constantly changing terraform, we are not sure
535- // if the parameters are the "same" as the previous render.
536- . map ( ( p ) => < FormElement key = { window . crypto . randomUUID ( ) } parameter = { p } /> ) ;
534+ const $force = useStore ( ( state ) => state . _force ) ;
535+
536+ const getParameterHash = ( p : ParameterWithSource ) =>
537+ `${ $force } :${ p . name } :${ p . form_type } ` ;
538+
539+ return (
540+ parameters
541+ . sort ( ( a , b ) => a . order - b . order )
542+ // Since the form is sourced from constantly changing terraform, we are not sure
543+ // if the parameters are the "same" as the previous render.
544+ . map ( ( p ) => < FormElement key = { getParameterHash ( p ) } parameter = { p } /> )
545+ ) ;
537546} ;
538547
539548type FormElementProps = { parameter : ParameterWithSource } ;
540549const FormElement : FC < FormElementProps > = ( { parameter } ) => {
541550 const $form = useStore ( ( state ) => state . form ) ;
542551 const $setForm = useStore ( ( state ) => state . setFormState ) ;
543552
544- const value = useMemo (
545- ( ) =>
546- $form [ parameter . name ] ??
547- undefined ,
548- [ $form , parameter ] ,
549- ) ;
553+ const value = useMemo ( ( ) => {
554+ return $form [ parameter . name ] ;
555+ } , [ $form , parameter . name ] ) ;
550556
551557 const onValueChange = ( value : string ) => {
552558 $setForm ( parameter . name , value ) ;
0 commit comments