Skip to content

fix(forms): delay mcp reading the form model by a tick#69265

Open
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:forms-mcp-effect
Open

fix(forms): delay mcp reading the form model by a tick#69265
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:forms-mcp-effect

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

Reading the form model on init is unsafe as it could depend on inputs (eg a required input). We need to delay the read by a tick (after the inputs are set) to ensure that values can be safely read.

fixes #69262

@JeanMeche JeanMeche requested a review from dgp1130 June 9, 2026 15:49
@ngbot ngbot Bot added this to the Backlog milestone Jun 9, 2026
untracked(() => {
initWebMcpForm(formTree, options, injector);
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

effect(() => untracked(() => {...})) feels a little weird conceptually, but I guess I don't see a better way of doing it.

We should probably at least have a comment explaining why we don't want to synchronously read the form model.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be an argument for us to have #62075

Comment thread packages/forms/signals/test/web/webmcp.spec.ts Outdated
Comment thread packages/forms/signals/test/web/webmcp.spec.ts Outdated
Reading the form model on init is unsafe as it could depend on inputs (eg a required input). We need to delay the read by a tick (after the inputs are set) to ensure that values can be safely read.

fixes angular#69262
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Jun 9, 2026
@JeanMeche

Copy link
Copy Markdown
Member Author

Caretaker note: this is good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: forms merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

experimentalWebMcpTool is responsible for invoking the model synchronously

2 participants