-
Notifications
You must be signed in to change notification settings - Fork 601
feat: dataset label cleanup #9959
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
base: main
Are you sure you want to change the base?
Conversation
message: "Failed to save label changes. Please try again.", | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Label Sync Issue During Rapid User Actions
The auto-apply label logic has a race condition where rapid user selections can be lost. The useEffect
hook, intended to sync local state, can overwrite recent user changes with stale server data when mutations are in flight. This results in labels appearing deselected unexpectedly and can cause incorrect or duplicate mutations.
Additional Locations (1)
connections={connections} | ||
datasetId={datasetId} | ||
onCompleted={() => { | ||
// Only close the create modal, keep the labels popover open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Only close the create modal, keep the labels popover open |
Let's nix the comment.
*/ | ||
connections?: string[]; | ||
/** | ||
* Optional dataset ID to auto-apply the label to after creation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Optional dataset ID to auto-apply the label to after creation | |
* Optional dataset ID. If provided, newly created labels will be auto-applied to the dataset upon creation. |
const selectedLabelIds = useMemo( | ||
() => datasetData?.labels?.map((label) => label.id) || [], | ||
[datasetData?.labels] | ||
); | ||
const [search, setSearch] = useState(""); | ||
const [selected, setSelected] = useState<Selection>( | ||
() => new Set(selectedLabelIds) | ||
); | ||
const [hasChanges, setHasChanges] = useState(false); | ||
|
||
// Sync local selection state when dataset labels change (e.g., from auto-apply) | ||
useEffect(() => { | ||
setSelected(new Set(selectedLabelIds)); | ||
}, [selectedLabelIds]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to rely on Relay for the re-rendering of the labels rather than a useEffect
hook.
setSelected(selection); | ||
|
||
// Check if there are changes from the original selection | ||
// Auto-apply changes immediately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Auto-apply changes immediately |
message: "Failed to save label changes. Please try again.", | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What made this change necessary?
onCompleted, | ||
onCompleted: (response) => { | ||
// Auto-apply the new label to the dataset if datasetId is provided | ||
if (datasetId && response.createDatasetLabel?.datasetLabel?.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (datasetId && response.createDatasetLabel?.datasetLabel?.id) { | |
if (datasetId && response.createDatasetLabel.datasetLabel.id) { |
// Still call onCompleted even if auto-apply fails | ||
// The label was created successfully | ||
onCompleted(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to notify on error here.
Note
Streamlines dataset label UX by auto-applying selections and newly created labels, removing the save flow, and simplifying menu interactions and form UI.
DatasetLabelConfigButton
; removed explicit Save flow andonClose
prop; popover stays open when creating labels; selection syncs with dataset viauseEffect
/useMemo
.NewDatasetLabelDialog
accepts optionaldatasetId
and auto-applies the newly created label viaNewDatasetLabelDialogSetLabelsMutation
(generated file added); connections still updated.DatasetActionMenu
opens label configuration directly from the menu (no submenu/chevron); addsDialogTrigger
with invisible anchor to position popover.NewLabelForm
UI cleanup: removes helper descriptions, tweaks placeholders and layout.Edit Labels
link only (removed Manage/Save).Written by Cursor Bugbot for commit 5ce6bb9. This will update automatically on new commits. Configure here.