Skip to content

Store a resize on release and settle its position a frame later - #231

Merged
SunkenInTime merged 3 commits into
icarus-cloudfrom
t3code/defense-resize-same-frame
Sep 29, 2026
Merged

SunkenInTime merged 3 commits into
icarus-cloudfrom
t3code/defense-resize-same-frame

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #226, from Greptile's review of the matching desktop PR #227.

#226 stores a resize one frame after release, once the final size is laid out. If the user switched pages inside that frame, the write could land on the next page's copy of the item, because adjacent-page copies keep the same id.

Now the size, plus a position from the current layout, is stored synchronously on release, so a page save right after sees it. The pin holds for one more frame. Once the final size is laid out, the position is stored again if it moved, but only while the provider still holds the exact object that was resized. A page switch loads fresh objects, so the next page's copy is never touched. Normally that second write finds nothing to change.

(Earlier commits here tried two narrower fixes. Storing only the last drawn size dropped movement that arrived after the last frame. A guard alone let a page save right after release miss the resize. Greptile caught both.)

Tests (test/placed_box_resize_test.dart)

  • a release before the next frame keeps its last movement: a move and the release arrive with no frame between them, and the box ends with that final movement.
  • a page switch right after release keeps the resize on its page: the resized item has its new width before any frame. Then another page's copy with the same id loads before the frame, and the copy's size and position stay unchanged.
  • Full flutter test --no-pub: 1317 passed. dart analyze is clean on touched files.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The confirmed position error should be fixed before merging.

Findings

  1. P1 Defense Resize Saves Wrong Position ▶

Summary

The PR saves text and image resizes immediately on release so a quick page switch retains the new size. On defense, that save can pair the new size with a position calculated from the previous layout. Reopening the page then visibly moves the resized item.

Reviews (3) · Last reviewed commit: "Store a resize's size on release and set..."

A resize waited one frame after release before storing, so the final
size was laid out. A page switch inside that frame could land the
resize on the next page's copy of the item, which keeps the same id.

Pointer events arrive between frames, and a frame builds and lays out
together. So on release the box on screen always matches the size it
was last built at. Storing that size with the rendered box makes the
commit synchronous and exact. A final move the frame never drew is
dropped, so the box stays where the user last saw it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 93fb3c93-0356-4ee8-b535-aa44285e85d5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread test/placed_box_resize_test.dart Outdated
Storing the size last drawn at release dropped movement that arrived
after the last frame: a quick drag could be lost entirely. Go back to
storing the final size one frame after release, when it is laid out.
Write it only if the text or image being resized is still loaded. A page
switch in that frame loads the next page's copy, which keeps the same
id, so the resize can no longer land on it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SunkenInTime SunkenInTime changed the title Store a resize when it is released, not a frame later Write a resize only to the item it started on Sep 29, 2026
Comment thread lib/widgets/draggable_widgets/text/placed_text_builder.dart
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Immediate page switch preserves a defense resize with the wrong position ▶

    • Bug
      • Proved in both builders. After the final 40-pixel movement and release without a frame, saving and switching to a page containing another object with the same ID leaves the resized page’s width updated but its position mismatched. Reopening shifts text by 40 pixels left and 22 down, and image by 40 left and 22.5 up. Product impact: resized labels and images visibly move when users return to the page.
    • Cause
      • lib/widgets/draggable_widgets/text/placed_text_builder.dart:97–106, 117–132 and lib/widgets/draggable_widgets/image/placed_image_builder.dart:91–102, 112–127 write the new width/scale using the still-laid-out old RenderBox size. The next-frame identity check then excludes the other page’s same-ID object, so it cannot correct the saved page’s position.
    • Fix
      • Compute the release position from dimensions corresponding to the final width/scale before saving, or retain a page-specific pending correction that can update the original page after layout without altering the newly loaded page.

With the write deferred a frame, a page save right after release still
read the old size, and the page switch then replaced the item, so the
resize was lost. Store the size, and a position from the current
layout, as soon as the handle is released. Hold the pin one more frame,
then store the position again if the final layout moved it, only while
the same item is still loaded. Normally that second write finds nothing
to change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SunkenInTime SunkenInTime changed the title Write a resize only to the item it started on Store a resize on release and settle its position a frame later Sep 29, 2026
Comment thread lib/widgets/draggable_widgets/text/placed_text_builder.dart
@SunkenInTime
SunkenInTime merged commit 0491d51 into icarus-cloud Sep 29, 2026
14 checks 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.

1 participant