feat: lineage scoping and explorer dependency chain sort#56
feat: lineage scoping and explorer dependency chain sort#56wicky-zipstack merged 8 commits intomainfrom
Conversation
- Lineage scoping: highlight selected model's parent/child chain, fade unrelated nodes - Selected model shown with dashed blue border, related edges in blue - Explorer: add references to API, dependency chain sort (default), A-Z, Z-A, execution order - Child models indented in explorer to show hierarchy - Explorer auto-refreshes on model config save via setRefreshModels - Applied in both bottom section lineage and standalone LineageTab
|
| Filename | Overview |
|---|---|
| frontend/src/ide/explorer/explorer-component.jsx | Adds sort dropdown with 4 options; modelSortByRef ref avoids stale-closure in rebuildTree; useEffect on modelSortBy handles UI rebuild after state settles; applyModelDecorations correctly filters external table refs before setting _isChild. |
| frontend/src/ide/editor/lineage-utils.js | New shared utility exporting getRelatedNodeIds (DFS ancestor/descendant traversal) and applyScopedStyles; correctly guards against missing node labels and unrelated edges. |
| frontend/src/ide/editor/lineage-tab/lineage-tab.jsx | Imports shared applyScopedStyles; applies scoping consistently across all three layout code paths (initial fetch, second fetch, toggle direction); selectedModelName added to effect dependencies. |
| frontend/src/ide/editor/no-code-model/no-code-model.jsx | Uses shared applyScopedStyles for bottom-panel lineage; adds setRefreshModels(true) after config save to trigger explorer re-fetch; stale comment on line 2454. |
| backend/backend/application/file_explorer/file_explorer.py | Adds references field to each no-code model item in the API response; additive change, no existing fields touched. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Model Tab Opened] --> B[getLineageData / fetch lineage API]
B --> C[getLayoutedElements]
C --> D{modelName set?}
D -- Yes --> E[applyScopedStyles]
E --> F[setNodes / setEdges with scoped styles]
D -- No --> F2[setNodes / setEdges full view]
G[Toggle Layout Direction] --> C
H[Config Save] --> I[setRefreshModels true]
I --> J[Explorer useEffect fires getExplorer]
J --> K[sortModels + applyModelDecorations]
K --> L{sortBy}
L -- dep_chain --> M[DFS from roots, childrenOf map]
L -- exec_order --> N[Keep backend topological order]
L -- alpha_asc/desc --> O[localeCompare sort]
M & N & O --> P[transformTree → setTreeData]
P --> Q[_isChild nodes get explorer-child-model CSS class]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/editor/no-code-model/no-code-model.jsx
Line: 2454-2455
Comment:
**Stale comment describes the wrong function**
The comment `// Find all ancestor and descendant node IDs for a given model` was written for `getRelatedNodeIds`, which has since been extracted to `lineage-utils.js`. It now sits above `getLineageData`, incorrectly describing that function.
```suggestion
const getLineageData = (callSample = false) => {
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (8): Last reviewed commit: "merge: resolve conflicts with main — com..." | Re-trigger Greptile
…r external refs - handleModelSort: pass sortBy directly to sortModels instead of relying on async state - applyModelDecorations: filter references to only include sibling model names, ignore external table references
tahierhussain
left a comment
There was a problem hiding this comment.
@wicky-zipstack Please make the following changes:
- Add optional chaining wherever necessary in the frontend to avoid runtime errors.
- Please add screenshots for the UI changes addressed in this PR to the PR description.
- Remove !important from explorer-child-model padding — use higher specificity selector instead - Move static sort dropdown items to MODULE_SORT_ITEMS constant outside component - Memoize sort menu config with useMemo to avoid recreation on every render - Wrap handleModelSort with useCallback
…le, exec_order - Extract getRelatedNodeIds and applyScopedStyles into shared lineage-utils.js - Remove duplicate functions from lineage-tab.jsx and no-code-model.jsx - Move hardcoded #1677ff to --lineage-selected-border CSS variable (light: #1677ff, dark: #69b1ff) - Add comment clarifying exec_order fallback uses backend's topological order
- handleModelSort and modelSortMenu were defined before setTreeData, causing 'Cannot access setTreeData before initialization' ReferenceError - Moved both after rebuildTree/setTreeData definition to fix initialization order
…tyling Explorer sort dropdown: - Use modelSortByRef to avoid stale closure in treeNoCodeModeTitleIcon - Apply sort and decorations BEFORE transformTree so _isChild flag is set when className is assigned (parent-child indent now displays correctly) - Conditional indent: only show in Dependency Chain mode, not in Execution Order/A→Z/Z→A modes - Show checkmark on currently selected sort option in the dropdown menu - useEffect rebuilds tree on modelSortBy change so dropdown reflects current state Race condition fix: - Move setRefreshModels(true) from handleSourceDestinationChange into runTransformation .then() callback. Calling it before the run completed triggered concurrent getExplorer/fetch_all_models that conflicted with in-progress sync_file_models, causing "No module named" import errors. No Credits chip styling: - Match border and background with the standard info chip (raw, etc.) - Only the text and icon stay red to indicate error state - Now consistent across light and dark themes
- file_explorer.py: keep both refs_by_name (dependency chain) and model_lookup (run status fields) — output includes references + run_status/failure_reason/last_run_at/run_duration - explorer-component.jsx: keep both MODEL_SORT_OPTIONS and MODEL_STATUS_DOT_STYLE/getModelRunStatus constants - no-code-model.jsx: keep comment for setRefreshModels call
What
Why
How
getRelatedNodeIds()traverses edges to find ancestors/descendants,applyScopedStyles()applies opacity + dashed borderreferencesfield from model_data to API responsesortModels()with dep_chain grouping,applyModelDecorations()for child indent, sort dropdown with 4 optionssetRefreshModels(true)after config save triggers explorer re-fetchCan this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist