Repository navigation
Description
Description
The WorkspaceParametersPage (specifically the experimental/dynamic parameters flow) exhibits a flickering/janky UI behavior when users interact with workspace parameters. The form inputs appear to visually reset or jump, creating a very poor user experience.
This was reported by a customer.
Expected Behavior
Parameter form inputs should update smoothly without any visible flickering, re-rendering, or input value jumping when a user changes a parameter value.
Actual Behavior
When interacting with parameters on the Workspace Parameters settings page, the UI flickers/jumps, likely causing form values to visually reset before settling. This makes the page feel broken and is a bad UX.
Root Cause Analysis
This is likely a React re-rendering issue in the dynamic parameters flow. The suspected area involves the interplay between:
-
WebSocket-driven state updates —
WorkspaceParametersPageExperimentalopens a WebSocket connection totemplateVersionDynamicParameters. Every parameter change triggers a WebSocket message, and every response callssetLatestResponse(), causing a full component re-render. -
useSyncFormParametershook — This hook watches for changes in theparametersarray (from WebSocket responses) and callssetFieldValue("rich_parameter_values", newParameterValues)to reconcile form state with server-side parameter state. This creates a render loop:- User changes a value →
handleChangeupdates formik state and sends a WebSocket message - WebSocket responds with new parameters →
setLatestResponsetriggers re-render useSyncFormParametersdetects the parameter change → callssetFieldValueagain → another re-render- The form briefly shows the server-reconciled value before settling
- User changes a value →
-
enableReinitialize: falseon Formik — While this prevents Formik from resetting on prop changes, theuseSyncFormParametershook effectively does a manual reinitialize on every WebSocket response, bypassing this protection.
Relevant Code
site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsxsite/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageViewExperimental.tsxsite/src/modules/hooks/useSyncFormParameters.ts
Suggested Fix
Potential approaches to investigate:
- Debounce or batch WebSocket responses — Avoid re-rendering on every single WebSocket message. Only update state when the response is for the latest request ID.
- Optimistic form updates — Don't overwrite the form value with the server response if the user just set it. The
useSyncFormParametershook should skip reconciliation for the parameter the user just changed. - Transition API /
useTransition— Mark the WebSocket-driven state updates as non-urgent so React can keep the UI responsive during the reconciliation. - Compare before setting — In
useSyncFormParameters, compare the user's current input (not just the ref) against the incoming server value to avoid unnecessarysetFieldValuecalls that cause flicker.
Reproduction
Navigate to a workspace's Settings → Parameters page (with dynamic parameters / non-classic parameter flow) and interact with parameter inputs.
Impact
This is a significant UX issue — the flickering makes the page feel broken and unreliable.
Created on behalf of @jakehwll
Activity
fix: implement debounce `<WorkspaceParametersPageViewExperimental />` (…