Skip to content

feat: option to highlight "Deep dependencies" when clicking on source files - #180

Merged
antoine-coulon merged 12 commits into
antoine-coulon:mainfrom
MengLinMaker:highlight-dependencies
Nov 22, 2024
Merged

antoine-coulon merged 12 commits into
antoine-coulon:mainfrom
MengLinMaker:highlight-dependencies

Conversation

@MengLinMaker

@MengLinMaker MengLinMaker commented Nov 16, 2024 •

Copy link
Copy Markdown
Contributor

closes #179

Summary

Allow highlighting deep dependency sub-graph of a file that is selected:

Screen.Recording.2024-11-16.at.10.58.22.pm.mp4

This is still Work In Progress.

Implementation

Implementation overview:

  • Add new deepDependencyNodeOptions and deepDependencyEdgeOptions to highlight nodes and edges.
  • Add toggle_deep NetworkAction, new network state in store and checkbox to trigger option.
  • Created highlightDeepDependencies function to highlight deep dependencies using DFS.
  • Add listener _network.on('click', ...) for viz-network to trigger dependency highlighting.
  • oldNodeId is used to reset highlighting of previously selected node.

Alternative UX:

  • Could highlight deep dependencies when focus_on_node. But click event provides faster feedback.

Bugs:

  • The highlight will override Circular dependencies - fixing would require huge changes to how rendering works.

Performance:

  • Could create a diffing function between old dependency graph and new one to optimise rendering speed.

Testing

  • Unit tests updated for new default store

Impacted documentation

  • Changesets were generated using pnpm changeset at the root of the workspace, affected packages are being bumped (either patch/minor) and a clear description for each of the affected packages was added.

@MengLinMaker MengLinMaker changed the title feat: highlight "Deep dependencies" graph toggle feat: option to highlight "Deep dependencies" when clicking on source files Nov 16, 2024
@MengLinMaker
MengLinMaker force-pushed the highlight-dependencies branch from 4bab4c8 to ddbdf79 Compare November 16, 2024 12:33
@MengLinMaker
MengLinMaker marked this pull request as draft November 16, 2024 12:33
@MengLinMaker
MengLinMaker marked this pull request as ready for review November 16, 2024 13:39
@MengLinMaker

Copy link
Copy Markdown
Contributor Author
  • fixed bug related to single file with no dependency
  • fixed bug related to not clearing
  • improved performance by detecting invalid nodeId in dfs algorithm

@MengLinMaker

MengLinMaker commented Nov 16, 2024 •

Copy link
Copy Markdown
Contributor Author

@antoine-coulon This is ready to be reviewed.

Screen.Recording.2024-11-17.at.12.42.39.am.mp4

The behaviour works as expected, except:

  • this feature would clash with Circular dependencies option
  • performance is degraded by clearing old selected graph

These improvements would probably require big changes in how the renderer works. One idea is to introduce layers and a diffing engine that merges changes before sending the minimal required changes to vis-nwtwork.

Some performance bottlenecks come from the underlying update function:
image

@antoine-coulon

Copy link
Copy Markdown
Owner

Awesome work @MengLinMaker, that looks super great!

I'm currently on my phone but I should be able to grab my laptop before tomorrow's night to review the work and all the provided information, and obviously merge the PR 🚀

@MengLinMaker

Copy link
Copy Markdown
Contributor Author

Whoops sorry, just found another bug - "Deep dependencies" should never be disabled

@antoine-coulon antoine-coulon left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Overall it looks good to me, thanks for the great work! I provided few comments mostly regarding the way the UI state and the graph are updated.

Also, I played a bit with the feature and it looks like Deep dependencies and Circular dependencies are overlapping and playing with both at the same time creates visual inconsistencies. For example, when having both options checked, selecting nodes will make highlighted circular dependencies disappear.

I would probably consider that these two options can't be checked at the same time, meaning that one option can't be checked while the other one is checked. That way, we avoid the need of reconciling the graph each time. What do you think?

Comment thread apps/web/src/network/Network.tsx Resolved
Comment thread apps/web/src/network/Network.tsx Resolved
@MengLinMaker

MengLinMaker commented Nov 18, 2024 •

Copy link
Copy Markdown
Contributor Author

I would probably consider that these two options can't be checked at the same time, meaning that one option can't be checked while the other one is checked. That way, we avoid the need of reconciling the graph each time. What do you think?

Good suggestion. It's a simpler solution.

Mutually exclusive toggle implemented in 6a44479

@MengLinMaker

Copy link
Copy Markdown
Contributor Author

Added tests.

The naming is confusing, especially toggleDependencies which appears in 2 places.
I believe one is a reducer that mutates state.
The other generates a dispatcher that emits events

@antoine-coulon antoine-coulon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM, thanks for the good work!

@antoine-coulon

Copy link
Copy Markdown
Owner

@all-contributors please add @MengLinMaker for code

@allcontributors

Copy link
Copy Markdown
Contributor

@antoine-coulon

I've put up a pull request to add @MengLinMaker! 🎉

@antoine-coulon
antoine-coulon merged commit 93bc556 into antoine-coulon:main Nov 22, 2024
@github-actions github-actions Bot mentioned this pull request Nov 22, 2024
@MengLinMaker
MengLinMaker deleted the highlight-dependencies branch November 22, 2024 10:32
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.

Feature request: highlight all dependencies of a file

2 participants