Repository navigation
A store-owned canvas redrawn from the store stacks items in their saved order - #1029
Open
SunkenInTime wants to merge 1 commit into
Open
SunkenInTime wants to merge 1 commit into
SunkenInTime wants to merge 1 commit into
Conversation
…ed order The store lists a page's rows in the order it holds them, and the canvas drew them in that order, so an item brought to the top went back under items with later rows on the next redraw. Elements and lineup groups are now sorted by sortIndex when the store's page is turned into a snapshot, as the Convex path already does. The driver's expectCanvasIsTheStores also checks the canvas's stacking order against the store's, and cloud-store-own-stacking.json drags the lower of two overlapping agents to the top and reopens the strategy.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 32 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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.
On a store-owned strategy, the canvas drew overlapping items in the order the store lists its rows, not in their saved stacking order (sortIndex). If you dragged an item that sat under another, it came to the top for a moment. Then the redraw from the store put it back underneath. The store and server kept the right order. Only the drawing was wrong, and it was wrong every time the page was drawn from the store: after a save, after a teammate's change, or when the strategy was reopened.
#1014 is where this turned into a wrong save. After a doubted save and a reopen, the redraw sometimes ran before the canvas's next commit. In that case the commit saw the misdrawn order as a restack and sent it (
ElementPatchOp x, sortIndex 3). The extra await in the issue only decides which of the two ran first._retakeBaseis unchanged.Cause
storePageOf(lib/collab/store_editor_snapshot.dart) passescontent.elementsandcontent.lineupGroupson in the store's row order. The canvas draws page items in that list's order. The Convex path sorts the same lists by sortIndex inRemotePageSnapshot.groupElementsByPage.Fix
storePageOfsorts elements and lineups withsortBySortIndex, the same stable sort the Convex path uses, so ties keep the store's row order. Nothing downstream matches items between two snapshots by index:liveHandOffCosttakeselements.firstof one snapshot to stand in for "one row changed". It asserts one row decoded, and its figure is the whole page's conversion, so which item it picks doesn't change what it measures.Tests (
test/library_store/store_canvas_commit_test.dart)Expected: ['x', 'a1'] Actual: ['a1', 'x'][x, a1]and that the store's sortIndex order equals the canvas order. On main, default timing:Expected: ['x', 'a1'] Actual: ['a1', 'x']On main with the issue's extra await, it fails as the issue reported:
Expected: {'x': 1, 'a1': 2, 'p1': 2} Actual: {'x': 2, 'a1': 2, 'p1': 2}. With this change it passes in both timings.Expected: ['bk', 'zk'] Actual: ['zk', 'bk']The queue model and the store model don't read sortIndex through this path. Neither goes through storePageOf, the store draw source, mergeRemote or
_retakeBase, so no sweep is needed.Why the driver didn't catch it
expectCanvasIsTheStorescompared agents as an id → position map, so order was never checked. It now also requires the canvas's agent order to equal the store's sortIndex order. With only that check added to main (881b72c),cloud-store-own-open, thecloud-store-own-teammatepair andcloud-store-own-pages(run throughlinux-cut-network.sh) all stay CLEAN, because none of them restacks. The newcloud-store-own-stacking.jsonfails:the canvas stacks the agents [a1-…, a2-…], the store stacks them [a2-…, a1-…]In the running app
Driver runs on
storeruns(Linux,--library-store store --cloud-store own) ofcloud-store-own-stacking.json: two overlapping agents; Jett, the lower one, is dragged to the top, then the strategy is left and opened again. This PR's run is CLEAN. Main's run is CLEAN too, because main still has the weaker check, but its shots show the wrong order:On main, Sova is drawn over Jett right after the drag and again after reopening. With this PR, Jett stays on top.
ci: analyze test web desktop
Fixes #1014


Confidence Score: 5/5
This PR appears safe to merge; no actionable issues were found.Summary
storePageOfnow sorts elements and lineups bysortIndexbefore the canvas draws them.Reviews (1) · Last reviewed commit: "A store-owned canvas redrawn from the st..." · Reviewed by Greptile