fix: keep cost attribution labels grouped after saving a check - #1796
Open
g3john wants to merge 1 commit into
Open
fix: keep cost attribution labels grouped after saving a check#1796g3john wants to merge 1 commit into
g3john wants to merge 1 commit into
Conversation
Saving a check refetches it and resets the form with every label in a single flat list, which the one-shot split effect never re-grouped because the tenant's cost attribution label names had not changed. Reconcile whenever the cost attribution rows fall out of sync with the name list, which is the state a reset leaves behind. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Current version of PR was reviewed by /review-bugbot on Aug 10, 15:14 EDT. It flagged 0 findings. Bugbot on commit |
Script size changes
Totals
|
g3john
commented
Aug 10, 2026
Comment on lines
+37
to
+65
| const RESET_BUTTON_TEXT = 'Simulate check refetch'; | ||
|
|
||
| // Saving a check refetches it, which re-seeds `labels` with every label on the check and clears | ||
| // `calLabels`. This harness reproduces that reset so the regrouping can be asserted. | ||
| function renderWithRefetchReset(calNames: string[], labels: Label[]) { | ||
| function Harness() { | ||
| const formMethods = useForm({ defaultValues: { labels, calLabels: [] }, mode: 'onChange' }); | ||
|
|
||
| return ( | ||
| <FormProvider {...formMethods}> | ||
| <form> | ||
| <GenericLabelContent description="Test description" calNames={calNames} /> | ||
| <button type="button" onClick={() => formMethods.reset({ labels, calLabels: [] })}> | ||
| {RESET_BUTTON_TEXT} | ||
| </button> | ||
| </form> | ||
| </FormProvider> | ||
| ); | ||
| } | ||
|
|
||
| render( | ||
| <OpenFeatureTestProvider domain={SM_OPEN_FEATURE_DOMAIN} flagValueMap={getTestFlagValues()}> | ||
| <Harness /> | ||
| </OpenFeatureTestProvider> | ||
| ); | ||
|
|
||
| return userEvent.setup(); | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Not sure if its worth doing this just to have a test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses: #1791
Problem
When a check has both cost attribution labels and custom labels, saving the check moves the cost attribution labels into the Custom labels section. The cost attribution rows are left blank, as though the values had been cleared.
Nothing is actually lost. The check is saved correctly and the labels return to their proper sections when you navigate away and come back, but it looks like the save has just discarded your cost attribution values.
Solution
Sorting the labels into the two sections was a one-shot, only re-running when the tenant's cost attribution names changed. It now also runs whenever the cost attribution rows are out of sync with the names they should contain, which is the state a form reset leaves behind. It keys off the cost attribution rows rather than scanning the custom labels for cost-attribution-looking names
Before
Screen.Recording.2026-08-10.at.3.47.49.PM.mov
After
Screen.Recording.2026-08-10.at.3.47.19.PM.mov