langgenius / langgenius/dify

fix(workflow): re-fetch dataset details when workflow nodes change

Open Beginner friendly
#39,516 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
156k
Forks
24.6k
Avg merge
20h 50m
Merged PRs (30d)
586

Description

## DatasetsDetailProvider fetches dataset metadata only on mount, leaving store stale when workflow graph changes

`web/app/components/workflow/datasets-detail-store/provider.tsx` lines 34-46 — the effect that fetches dataset details for knowledge-retrieval nodes has an empty dependency array, but reads the `nodes` prop. As a result, the fetch only happens when the provider first mounts. Any subsequent change to the workflow graph leaves the dataset-detail store in its initial state, even though the graph on screen has been replaced.

### Trigger scenarios

- Loading a different saved workflow while the workflow editor stays mounted.
- Real-time collaboration: another user adds, removes, or changes the dataset IDs of a knowledge-retrieval node.
- Undo / redo of node additions or deletions.
- Adding or removing a knowledge-retrieval node after the initial mount.
- Snippet insertion that introduces or rewires nodes.

In each case, consumers of the store (dataset pickers, dataset-name previews, validation messages that need the dataset title) display either the original dataset list, missing entries, or datasets that no longer exist on the workflow.

### Expected

The dataset-detail store reflects the current set of datasets referenced by any knowledge-retrieval node in the live workflow graph.

### Actual

The store is populated only once, on initial mount. Subsequent workflow-graph changes are not reflected.

### Suggested fix

Add `nodes` (and `updateDatasetsDetail` for completeness, even though it is already memoized with `[]` deps) to the effect's dependency array:

```tsx
useEffect(() => {
...
updateDatasetsDetail(allDatasetIds)
}, [nodes, updateDatasetsDetail])
```

Contributor guide

Open the contributing guide

Research direction

Open web/app/components/workflow/datasets-detail-store/provider.tsx and inspect lines 34-46, especially the effect that reads nodes and updates the dataset-detail store. Exercise workflow graph changes such as loading another workflow or adding and removing knowledge-retrieval nodes. Done means the store reflects the dataset IDs referenced by the current graph rather than only the initial mount.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.