Skip to content

Commit 99526bd

Browse files
atscottclydin
authored andcommitted
refactor(@angular/cli): Improve zoneless migration prompts based on observed outcomes
After observing some results from the tool's prompts, I found some improvements: * if there was an existing import from '@angular/core' LLMs sometimes chose to delete it and all preceding imports * Moved the note about "remove provideZoneChangeDetection" to the specific prompt where it's relevant. This was being used in the final "non-actionable" prompts and resulted in LLMs choosing to delete 'provideZonelessChangeDetection' additions from previous iterations (cherry picked from commit 3b06b28)
1 parent b2d5e6e commit 99526bd

File tree

1 file changed

+8
-3
lines changed
  • packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration

1 file changed

+8
-3
lines changed

packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ export function createProvideZonelessForTestsSetupPrompt(testFilePath: string):
2525
2626
In the main \`beforeEach\` block for the test suite (the one inside the top-level \`describe\`), add \`provideZonelessChangeDetection()\` to the providers array in \`TestBed.configureTestingModule\`.
2727
28+
* If there is already an import from \`@angular/core\`, add \`provideZonelessChangeDetection\` to the existing import.
29+
* Otherwise, add a new import statement for \`provideZonelessChangeDetection\` from \`@angular/core\`.
30+
2831
\`\`\`diff
29-
+ import { provideZonelessChangeDetection } from '@angular/core';
32+
- import {{ SomeImport }} from '@angular/core';
33+
+ import {{ SomeImport, provideZonelessChangeDetection }} from '@angular/core';
3034
3135
describe('MyComponent', () => {
3236
+ beforeEach(() => {
@@ -202,6 +206,9 @@ export async function createFixResponseForZoneTests(
202206
203207
The following usages of \`provideZoneChangeDetection\` must be removed:
204208
${locations.map((loc) => `- ${loc}`).join('\n')}
209+
210+
After removing \`provideZoneChangeDetection\`, the tests will likely fail. Use this guide to diagnose and fix the failures.
211+
205212
${testDebuggingGuideText(sourceFile.fileName)}
206213
207214
### Final Step
@@ -214,8 +221,6 @@ function testDebuggingGuideText(fileName: string) {
214221
return `
215222
### Test Debugging Guide
216223
217-
After removing \`provideZoneChangeDetection\`, the tests will likely fail. Use this guide to diagnose and fix the failures.
218-
219224
1. **\`ExpressionChangedAfterItHasBeenCheckedError\`**:
220225
* **Cause**: This error indicates that a value in a component's template was updated, but Angular was not notified to run change detection.
221226
* **Solution**:

0 commit comments

Comments
 (0)