Bags: stop the merged stack count leaking onto the raw bag grid - #1296
Merged
EllesmereGaming merged 1 commit intoAug 11, 2026
Merged
Conversation
One pooled data table exists per real (bag, slot) and every section of a refresh renders those same tables. MergeDuplicates memoised its running total as _mergedCount ON the winning table, so the aggregate was visible to any later section that painted the same table. RenderButton reads the stamp unconditionally, and RenderBagGrid (OneBag/MultiBag "Main Bags", and the reagent grid) has no merge pass of its own, so it never ran the per-list clear that was supposed to undo the previous section's stamp. With Pinned enabled in OneBag, two stacks of the same item merged in the pinned quickview left the bag-order-first slot showing the combined count while its twin showed its own, e.g. 10 and 5 for two stacks of 5. The decision to merge is per section, but the memo lived on state shared by every section. Fix it at the writer: the aggregate now accumulates on a pooled shallow copy of the winner that is substituted into the returned list, so canonical slot tables are never written to. Sections that render the returned list still show merged counts; sections that render the raw slot tables show the true per-slot stackCount, which also matches stock ContainerFrame behaviour. data.info stays shared by reference. This also kills the latent variant in the All Items view, where the per-category pass and the pinned pass only agreed on a winner by ordering coincidence, and drops the unconditional clear loop, so a refresh with no duplicates now allocates and writes nothing. MergeDuplicates moves below the slot pool (pure relocation) so AcquireSlotTable is in scope; no call site sits between the two points.
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.
Cause: one pooled data table exists per real (bag, slot) and every section of a refresh renders those same tables, but
MergeDuplicatesmemoised its running total as_mergedCounton the winning table.RenderButtonreads that stamp unconditionally, andRenderBagGrid(Main Bags in OneBag/MultiBag, and the reagent grid) has no merge pass of its own, so it never ran the per-list clear meant to undo the previous section's stamp.Effect: with an item pinned in OneBag, two stacks of 5 rendered as 10 and 5 in Main Bags while the pinned row correctly showed 10. Same defect in MultiBag, the reagent grid and the Recent quickview; latent in All Items, where the category pass and the pinned pass only picked the same winner by ordering coincidence.
Fix: the aggregate now accumulates on a pooled shallow copy of the winner that is substituted into the returned list, so canonical slot tables are never written to. Merged sections still show merged counts, raw grids show the true per-slot stackCount.
data.infostays shared by reference, and the unconditional clear loop is gone, so a refresh with no duplicates allocates and writes nothing.Test: verified two stacks of 5 now read 5 and 5 in Main Bags with the pinned row still reading 10; also checked MultiBag, the reagent grid, Recent, All Items / category / group views still merging to 10, Merge Duplicates off, and that middle-click unpin and shift-click stack-split still act on the real slot.