-
Notifications
You must be signed in to change notification settings - Fork 8
feat: lineage scoping and explorer dependency chain sort #56
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
wicky-zipstack
wants to merge
6
commits into
main
Choose a base branch
from
feat/lineage-scoping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9b9f27
feat: lineage scoping, explorer dependency chain sort and child indent
wicky-zipstack 24bb897
fix: address PR review — stale closure in sort, false child indent fo…
wicky-zipstack 835752d
fix: address PR #56 review feedback
wicky-zipstack 1a8ef53
fix: address PR #56 review — extract shared lineage utils, CSS variab…
wicky-zipstack db58bbf
fix: resolve temporal dead zone — move handleModelSort after setTreeData
wicky-zipstack 0d13c47
fix: wrap handleModelSort in useCallback and add to modelSortMenu deps
wicky-zipstack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /** | ||
| * Shared utility functions for lineage scoping. | ||
| * Used by both lineage-tab.jsx (standalone) and no-code-model.jsx (bottom section). | ||
| */ | ||
|
|
||
| /** | ||
| * Find all ancestor and descendant node IDs for a given model. | ||
| * @param {Array} allEdges - Array of { source, target } edge objects | ||
| * @param {string} selectedLabel - The label of the selected model | ||
| * @param {Array} allNodes - Array of node objects with data.originalLabel or data.label | ||
| * @return {Set|null} Set of related node IDs, or null if selected model not found | ||
| */ | ||
| export const getRelatedNodeIds = (allEdges, selectedLabel, allNodes) => { | ||
| const nodeByLabel = {}; | ||
| allNodes.forEach((n) => { | ||
| nodeByLabel[n.data.originalLabel || n.data.label] = n.id; | ||
| }); | ||
| const selectedId = nodeByLabel[selectedLabel]; | ||
| if (!selectedId) return null; | ||
|
|
||
| const related = new Set([selectedId]); | ||
| const findAncestors = (id) => { | ||
| allEdges.forEach((e) => { | ||
| if (e.target === id && !related.has(e.source)) { | ||
| related.add(e.source); | ||
| findAncestors(e.source); | ||
| } | ||
| }); | ||
| }; | ||
| const findDescendants = (id) => { | ||
| allEdges.forEach((e) => { | ||
| if (e.source === id && !related.has(e.target)) { | ||
| related.add(e.target); | ||
| findDescendants(e.target); | ||
| } | ||
| }); | ||
| }; | ||
| findAncestors(selectedId); | ||
| findDescendants(selectedId); | ||
| return related; | ||
| }; | ||
|
|
||
| /** | ||
| * Apply scoped styles to nodes and edges based on the selected model's lineage chain. | ||
| * Related nodes stay full opacity, unrelated nodes are faded. | ||
| * @param {Array} layoutedNodes - Array of positioned node objects | ||
| * @param {Array} layoutedEdges - Array of edge objects | ||
| * @param {string} selectedLabel - The label of the selected model | ||
| * @return {Object} { nodes, edges } with scoped styles applied | ||
| */ | ||
| export const applyScopedStyles = ( | ||
| layoutedNodes, | ||
| layoutedEdges, | ||
| selectedLabel | ||
| ) => { | ||
| const rawEdges = layoutedEdges.map((e) => ({ | ||
| source: e.source, | ||
| target: e.target, | ||
| })); | ||
| const related = getRelatedNodeIds(rawEdges, selectedLabel, layoutedNodes); | ||
| if (!related) return { nodes: layoutedNodes, edges: layoutedEdges }; | ||
|
|
||
| const styledNodes = layoutedNodes.map((node) => { | ||
| const nodeLabel = node.data.originalLabel || node.data.label; | ||
| const isSelected = nodeLabel === selectedLabel; | ||
| const isRelated = related.has(node.id); | ||
| return { | ||
| ...node, | ||
| style: { | ||
| ...node.style, | ||
| opacity: isRelated ? 1 : 0.25, | ||
| border: isSelected | ||
| ? "2px dashed var(--lineage-selected-border)" | ||
| : node.style?.border || "1px solid var(--black)", | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| const relatedEdgeSet = new Set(); | ||
| layoutedEdges.forEach((e) => { | ||
| if (related.has(e.source) && related.has(e.target)) { | ||
| relatedEdgeSet.add(e.id); | ||
| } | ||
| }); | ||
|
|
||
| const styledEdges = layoutedEdges.map((edge) => ({ | ||
| ...edge, | ||
| style: { | ||
| ...edge.style, | ||
| opacity: relatedEdgeSet.has(edge.id) ? 1 : 0.15, | ||
| stroke: relatedEdgeSet.has(edge.id) | ||
| ? "var(--lineage-selected-border)" | ||
| : undefined, | ||
| }, | ||
| })); | ||
|
|
||
| return { nodes: styledNodes, edges: styledEdges }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.