Skip to content

Bags: stop the merged stack count leaking onto the raw bag grid - #1296

Merged
EllesmereGaming merged 1 commit into
EllesmereGaming:mainfrom
dfrisone:bags-pinned-stack-count
Aug 11, 2026
Merged

Bags: stop the merged stack count leaking onto the raw bag grid#1296
EllesmereGaming merged 1 commit into
EllesmereGaming:mainfrom
dfrisone:bags-pinned-stack-count

Conversation

@dfrisone

@dfrisone dfrisone commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Cause: one pooled data table exists per real (bag, slot) and every section of a refresh renders those same tables, but MergeDuplicates memoised its running total as _mergedCount on the winning table. RenderButton reads that stamp unconditionally, and RenderBagGrid (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.info stays 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.

Spider-Man GIF

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.
@EllesmereGaming
EllesmereGaming merged commit b55fe52 into EllesmereGaming:main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants