Skip to content

Add conditional control-flow blocks in DevTools#69676

Draft
SkyZeroZx wants to merge 4 commits into
angular:mainfrom
SkyZeroZx:add-devtools-control-flow
Draft

Add conditional control-flow blocks in DevTools#69676
SkyZeroZx wants to merge 4 commits into
angular:mainfrom
SkyZeroZx:add-devtools-control-flow

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

refactor(compiler): collect metadata for conditional blocks

Carry conditional block metadata through template lowering and emit the debug instruction that records it in generated views.

This keeps the original expressions for if and switch branches so runtime inspection can report the declared control-flow structure.

feat(core): expose metadata for conditional blocks

Record development-mode metadata for conditional control-flow blocks so debugging APIs can describe @if and @switch views.

This gives DevTools the context it needs to show which branch is active and where each condition came from, while keeping the data limited to development-time inspection.

feat(devtools): show conditional control-flow blocks

Surface conditional control-flow blocks in Angular DevTools alongside the existing @defer and @for blocks.

The directive tree now labels active branches and cases, and the property pane shows the declared blocks, rendered state, and source expressions from the runtime metadata.


This would align with what was commented at #65849 (comment)

devtools.mp4

SkyZeroZx added 2 commits July 7, 2026 20:21
Carry conditional block metadata through template lowering and emit the debug instruction that records it in generated views.

This keeps the original expressions for if and switch branches so runtime inspection can report the declared control-flow structure.
Record development-mode metadata for conditional control-flow blocks so debugging APIs can describe `@if` and `@switch` views.

This gives DevTools the context it needs to show which branch is active and where each condition came from, while keeping the data limited to development-time inspection.
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime area: devtools labels Jul 8, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 8, 2026
@@ -0,0 +1,122 @@
<section class="control-flow-cases" aria-label="Control flow validation cases">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if this is the right place for it, or if we should create a different route for these cases and perhaps make it more interactive, or is it okay as is?


export function guardedExpression(guard: string, expr: o.Expression): o.Expression {
const guardExpr = new o.ExternalExpr({name: guard, moduleName: null});
const guardExpr = o.variable(guard);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to update this because in case of JIT were failing. I'm not sure if this is correct or if I'm missing something.

Surface conditional control-flow blocks in Angular DevTools alongside the existing `@defer` and `@for` blocks.

The directive tree now labels active branches and cases, and the property pane shows the declared blocks, rendered state, and source expressions from the runtime metadata.
@SkyZeroZx SkyZeroZx force-pushed the add-devtools-control-flow branch from e66e977 to f4e073e Compare July 8, 2026 02:56
@JeanMeche JeanMeche requested a review from hawkgs July 8, 2026 11:59
@hawkgs

hawkgs commented Jul 8, 2026

Copy link
Copy Markdown
Member

@SkyZeroZx, thank you for the contribution, but we are already actively working on this feature and plan to ship an experimental version probably in the upcoming weeks.

@hawkgs

hawkgs commented Jul 8, 2026

Copy link
Copy Markdown
Member

Actually, I think that your approach with the tree shakable ɵɵconditionalMetadata instruction is solid! I think we should explore it.

Anyway, I'll let someone from the FW team verify if we are okay with this addition to Ivy to begin with, and then I can leave my review on the rest of the code.

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

Labels

area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime area: devtools detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants