Skip to content

feat(devtools): create devtools signals view #61919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

milomg
Copy link
Contributor

@milomg milomg commented Jun 6, 2025

create a component for the devtools signal pane, including view source, view value, and flashing of node updates

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Blocked on #61917, #61918

See #60478 for a more complete demo

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: devtools labels Jun 6, 2025
@ngbot ngbot bot added this to the Backlog milestone Jun 6, 2025
@milomg milomg force-pushed the signal-graph-8 branch 2 times, most recently from 8a32ab1 to 66ebbb2 Compare June 6, 2025 22:39
@milomg milomg marked this pull request as ready for review June 6, 2025 22:40
if (descriptor.type === PropType.Object || descriptor.type === PropType.Array) {
return arrayifyProps(descriptor.value || {}, prop);
}
return;
Copy link
Member

Choose a reason for hiding this comment

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

Should be redundant since the fn will return undefined anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helps satisfy the "not all code paths return a value" lint because the return type is undefined instead of void

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, yeah, it's a warning. I thought the compiler is handling that but I guess it's because of the "noImplicitReturns": true. Okay 👍

}

const createNode = (node: DebugSignalGraphNode) => {
const outer = document.createElement('div');
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the Renderer2 for the element creation (or DOCUMENT) and manipulation? I guess you'll have to pass an Injector or the renderer itself via the constructor.

I know there are other places that directly rely on document but we should try to limit these instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching to DOCUMENT won't help much because d3 uses document internally. Rendering an angular template here would be ideal, but maybe that makes sense to do in a follow up PR?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I thought about that. It's more about testing and being able to mock the calls, if required, rather than keeping the code platform agnostic (D3 is already violating that as you noted) but, on second though, unit testing this class might be just too time consuming compared to an E2E that'll provide more value. I guess you can leave it as is 👍.

@hawkgs
Copy link
Member

hawkgs commented Jun 9, 2025

Looks good! ✨ Left minor/style comments. I'll let the rest of the team to chime in.

I guess this shouldn't be a blocker for moving the PR forward but can we test some of the code? I realize that it's tricky to do that for complex UI without getting into E2E but maybe we can do some unit testing of the more frictionless parts.

create a component for the devtools signal pane, including view source, view value, and flashing of node updates
const parsedB = parseInt(b.name, 10);

if (isNaN(parsedA) || isNaN(parsedB)) {
return a.name > b.name ? 1 : -1;
Copy link
Member

Choose a reason for hiding this comment

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

Should we do a localeCompare here instead ?

Comment on lines +86 to +88
this.expandedData.next(
this.treeFlattener.expandFlattenedNodes(this.data.value, this.treeControl),
);
Copy link
Member

Choose a reason for hiding this comment

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

This is a side effect in a map.

Comment on lines +43 to +44
private data = new BehaviorSubject<FlatNode[]>([]);
private expandedData = new BehaviorSubject<FlatNode[]>([]);
Copy link
Member

Choose a reason for hiding this comment

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

Do we realy need a stream here ?
I was under the impression that a signal would fit here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: devtools detected: feature PR contains a feature commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants