Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 fix: remove response setting for the first message by BrunoQuaresma · Pull Request #20364 · coder/coder · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

BrunoQuaresma
Copy link
Collaborator
@BrunoQuaresma BrunoQuaresma commented Oct 17, 2025

I noticed that the connection wasn’t returning all the parameters in the first message, which caused the form to miss some field values. I was able to fix it by not setting the latest message before sending the initial parameters. After running some tests, everything seems to work nicely. Because of that, I also noticed that useSyncFormParameters might not be necessary anymore.

Update ----

The root cause is that formik's form.initialTouched was being used with the assumption that it would retain the touched state of the fields. However, this state was getting lost when handleChange was getting called when a dynamic parameter changed.

If the websocket request does not include a field on the form with an existing value, the server will respond with the default for that parameter, which cause that parameter to lose the existing value that is set.

The fix is to keep track explicitly keep track of touched fields on the form using form.setFieldTouched.

Fix #20257

@BrunoQuaresma BrunoQuaresma changed the title fix: don't set the response for the first message fix: remove response setting for the first message Oct 17, 2025
@Emyrk
Copy link
Member
Emyrk commented Oct 17, 2025

I noticed that the connection wasn’t returning all the parameters in the first message,

This is a good observation. The first message is incorrect because it assumes 0 inputs. The first message the webui sends is the inputs, and the next response is the true initial form.

  1. Websocket is opened
  2. <- Initial form state sent to webui (incorrect because assumes 0 inputs)
  3. WebUI sends over actual initial values ->
  4. <- New form state (the actual initial)

So I wonder if we need a way to open the websocket with some initial input values? Or ignore the first state back?

@jaaydenh I think you would have the most insight here.

8000

@BrunoQuaresma
Copy link
Collaborator Author

@Emyrk could I ask you to QA it locally and see if it works as expected? I don’t want to spend more time thinking about it without being sure this actually fixes the problem. I tested it myself, but a double check never hurts. 🙏

@Emyrk
Copy link
Member
Emyrk commented Oct 17, 2025

The form is having errors even when switching another value too.

Screencast.From.2025-10-17.11-46-28.webm

The websocket traffic is strange to me.

Screenshot From 2025-10-17 11-48-08

That first message sent from the client has all the parameter values set to the initial default values. But it should not be sending any inputs yet, as the user took no action yet. And default values should be omitted.

So the second message from the client only has the parameter that was changed. The others revert back to their default of unset.

@Emyrk
Copy link
Member
Emyrk commented Oct 17, 2025

@BrunoQuaresma it does fix it. The error message you see in this video happens on dogfood too when it also resets the Volume Size.

Screencast.From.2025-10-17.11-50-58.webm

@BrunoQuaresma
Copy link
Collaborator Author

@steve-Coder-Ent about the error message, I think it happens because you are selecting the already selected option, which unselects it and sets the field value to null.

That first message sent from the client has all the parameter values set to the initial default values. But it should not be sending any inputs yet, as the user took no action yet. And default values should be omitted.

So the following code should not be necessary, correct?

// On page load, sends initial workspace build parameters to the websocket.
// This ensures the backend has the form's complete initial state,
// vital for rendering dynamic UI elements dependent on initial parameter values.
const sendInitialParameters = useEffectEvent(() => {
	if (initialParamsSentRef.current) return;
	if (autofillParameters.length === 0) return;

	const initialParamsToSend: Record<string, string> = {};
	for (const param of autofillParameters) {
		if (param.name && param.value) {
			initialParamsToSend[param.name] = param.value;
		}
	}
	if (Object.keys(initialParamsToSend).length === 0) return;

	sendMessage(initialParamsToSend);
	initialParamsSentRef.current = true;
});

Which also makes me wonder, if the BE already has all the necessary information, why can’t the first websocket message contain the correct values?

@jaaydenh
Copy link
Contributor

This does fix the issue atleast temporarily but the root cause is that the frontend is using formik's touched fields state to keep track of which form fields should always be sent to the server on every request. If a field, that has a legitimate value that we want to maintain on the frontend, is not sent in a request, then the backend will always return that field with its default value which is the incorrect behavior in this case.

I am still investigating what the proper fix should be.

@BrunoQuaresma
Copy link
Collaborator Author

@jaayden is this something you’d like to assign to yourself, or should I take it over? I just want to make sure we don’t duplicate efforts.

I’d be more than happy to help and dive deeper into this, but if you think you can get it done faster, I’m totally fine with that. Please let me know what you think.

@jaaydenh jaaydenh assigned jaaydenh and unassigned BrunoQuaresma Oct 20, 2025
@jaaydenh jaaydenh removed their request for review October 20, 2025 19:00
@jaaydenh jaaydenh marked this pull request as ready for review October 20, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Parameters hidden by default have their values reset to default when unrelated parameter value modified on existing workspace

3 participants

0