-
Notifications
You must be signed in to change notification settings - Fork 613
feat: UI cleanup - reduce re-renders #9716
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
Conversation
| commitWithExamples({ | ||
| variables: { | ||
| connections, | ||
| input: { | ||
| name: trimmed, | ||
| description: params.description || null, | ||
| color: params.color, | ||
| metadata: null, | ||
| exampleIds, | ||
| }, | ||
| }, | ||
| }); |
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.
The commitWithExamples mutation is missing onCompleted and onError handlers, unlike the commit function below. This means users won't receive success or error notifications when creating a split with examples. Consider adding these handlers to provide consistent feedback:
commitWithExamples({
variables: {
connections,
input: {
name: trimmed,
description: params.description || null,
color: params.color,
metadata: null,
exampleIds,
},
},
onCompleted: () => {
notifySuccess({
title: "Split created",
message: `Created split "${trimmed}"`,
});
onCompleted?.();
},
onError: (error) => {
const formattedError = getErrorMessagesFromRelayMutationError(error);
notifyError({
title: "Failed to create split",
message: formattedError?.[0] ?? error.message,
});
},
});| commitWithExamples({ | |
| variables: { | |
| connections, | |
| input: { | |
| name: trimmed, | |
| description: params.description || null, | |
| color: params.color, | |
| metadata: null, | |
| exampleIds, | |
| }, | |
| }, | |
| }); | |
| commitWithExamples({ | |
| variables: { | |
| connections, | |
| input: { | |
| name: trimmed, | |
| description: params.description || null, | |
| color: params.color, | |
| metadata: null, | |
| exampleIds, | |
| }, | |
| }, | |
| onCompleted: () => { | |
| notifySuccess({ | |
| title: "Split created", | |
| message: `Created split "${trimmed}"`, | |
| }); | |
| onCompleted?.(); | |
| }, | |
| onError: (error) => { | |
| const formattedError = getErrorMessagesFromRelayMutationError(error); | |
| notifyError({ | |
| title: "Failed to create split", | |
| message: formattedError?.[0] ?? error.message, | |
| }); | |
| }, | |
| }); |
Spotted by Diamond
Is this helpful? React π or π to let us know.
This comment came from an experimental reviewβplease leave feedback if it was helpful/unhelpful. Learn more about experimental comments here.
| onCompleted: () => { | ||
| // refreshLatestVersion(); | ||
| }, |
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.
Let's nix this callback if it's no longer needed.
| }); | ||
| }} | ||
| /> | ||
| {isManageSplitsOpen && ( |
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.
This conditional render still feels a little weird. Is it there to prevent jitter?
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.
Maybe just leave a comment.
| }; | ||
|
|
||
| export function ManageDatasetSplitsDialog( | ||
| function ManageDatasetSplitsDialogComponent( |
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.
Let's keep the previous name.
| return true; | ||
| } | ||
|
|
||
| export const ManageDatasetSplitsDialog = memo( |
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.
Let's nix the memo since we figured out how to reduce the number of renders in other ways.
Note
Enable creating dataset splits with selected examples and return affected examples from split add/remove mutations; update UI and Relay to use new payloads and prepend newly created splits.
examples: [DatasetExample!]!toAddDatasetExamplesToDatasetSplitsMutationPayloadandRemoveDatasetExamplesFromDatasetSplitsMutationPayload.DatasetSplitMutationPayloadWithExamplesand updatecreateDatasetSplitWithExamplesto return it.add_dataset_examples_to_dataset_splitsandremove_dataset_examples_from_dataset_splitsnow load and return updatedexamples.create_dataset_split_with_examplesreturns new split plus associatedexamples.to_gql_dataset_examplehelper.exampleIds; prepend new split toManageDatasetSplitsDialog_datasetSplitsconnection; request returnedexamples.selectedExamples; computesharedSplitIds/partialSplitIdsinternally.NewDatasetSplitDialogwith selected example IDs.selectedExamplesto dialog; simplify shared/partial split logic; extract confirm handler.examples.Written by Cursor Bugbot for commit 1a9edff. This will update automatically on new commits. Configure here.