feat: lineage scoping and explorer dependency chain sort#56
feat: lineage scoping and explorer dependency chain sort#56wicky-zipstack wants to merge 6 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 dep-chain sort, child-model decorations, and sort dropdown; child-model className is never set on initial load because applyModelDecorations runs after transformTree in all non-sort-click paths. |
| frontend/src/ide/editor/lineage-utils.js | New shared utility extracting getRelatedNodeIds and applyScopedStyles — logic is clean and correctly handles null (no selected node found) via an early-return guard. |
| frontend/src/ide/editor/lineage-tab/lineage-tab.jsx | Integrates optional selectedModelName prop and applies scoped styles from the shared utility; three call sites (initial fetch, layout toggle, sample fetch) are consistently updated. |
| frontend/src/ide/editor/no-code-model/no-code-model.jsx | Applies scoped lineage styles when modelName is available and triggers setRefreshModels(true) after config save to refresh the explorer. |
| backend/backend/application/file_explorer/file_explorer.py | Adds references field to the explorer API response using a safe .get(name, []) lookup; no existing fields changed. |
| frontend/src/store/project-store.js | Adds schemaList to persisted store and a setSchemaList action — straightforward additive change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[getExplorer / rebuildTree] --> B["transformTree(freshData)\n(no _isChild yet → className NOT set)"]
B --> C["setTreeData(freshData)"]
C --> D["treeNoCodeModeTitleIcon(el.children)"]
D --> E["sortModels(children, modelSortBy)"]
E --> F["applyModelDecorations(children)\n(_isChild = true — but transformTree\nalready ran, className never set)"]
F --> G["setTree(resp)\n❌ className missing → no indent"]
H[handleModelSort click] --> I["applyModelDecorations(child.children)\n(_isChild = true)"]
I --> J["transformTree(freshData)\n(sees _isChild → className set)"]
J --> K["setTreeData(freshData, false)"]
K --> L["setTree(resp)\n✅ className present → indent visible"]
style G fill:#ffcccc,stroke:#cc0000
style L fill:#ccffcc,stroke:#00aa00
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/explorer/explorer-component.jsx
Line: 427-432
Comment:
**Child indentation never appears on initial load**
`transformTree` is called before `setTreeData` in every code path except `handleModelSort` (`getExplorer`, `rebuildTree`, and the `modelsRunning` effect all follow the same `transformTree → setTreeData` order). `transformTree` sets `className = "explorer-child-model"` only when `node._isChild` is already present, but `_isChild` is written by `applyModelDecorations` which runs *inside* `treeNoCodeModeTitleIcon`, *inside* `setTreeData` — i.e., after `transformTree` has already finished.
Concretely, on first load (`getExplorer`):
1. `transformTree(treeData)` — no `_isChild` flags yet → no `className` set
2. `setTreeData(treeData)` → `treeNoCodeModeTitleIcon` → `applyModelDecorations` — `_isChild` is set, but `transformTree` already ran
The child-model `className` is therefore never attached to the tree-node data, so the CSS indent rule `.explorerTree .ant-tree-treenode.explorer-child-model` never fires. Indentation is only visible after the user manually clicks a sort option (which goes through `handleModelSort`, the one path where `applyModelDecorations` precedes `transformTree`).
Fix: move the `applyModelDecorations` call before `transformTree` in `getExplorer` and `rebuildTree`, or restructure so `transformTree` runs on the already-decorated data.
How can I resolve this? If you propose a fix, please make it concise.Reviews (6): Last reviewed commit: "fix: wrap handleModelSort in useCallback..." | 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
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