Skip to content

Keep the editor's coordinates when the library rebuilds underneath it - #405

Merged
SunkenInTime merged 1 commit into
mainfrom
t3/canvas-keeps-coordinates
Oct 28, 2026
Merged

SunkenInTime merged 1 commit into
mainfrom
t3/canvas-keeps-coordinates

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Before and after: hovering a lineup after the folder list updates

Users on Discord ("Line up path moving", Oct 22 and Oct 28) see lineup lines, and sometimes agents and abilities, slide off their spots while they edit. Leaving to the library and reopening the strategy puts them back, until it happens again.

Same session on both builds: open, place Jett, hover a lineup, place another agent

Cause

Every placed item, lineup line and drawing converts between world and screen through one shared CoordinateSystem, and whichever widget built last set it. The editor's canvas sets it as it lays out, sized to its own height: the window minus the 40px strip. The library (FolderNavigator) also set it on every build, sized to window height − 90. That matched the editor's old 90px header. Since the editor moved to the library's 40px strip on Sept 12 (35a0a2a2, first shipped in 5.0.0), the two sizes have differed by about 6%.

The editor opens on top of the library, and the library stays mounted underneath it. Whenever something the library watches changes, it rebuilds and replaces the editor's coordinates with the smaller size. From then until the canvas lays out again, anything that redraws (a hovered lineup's lines, agents re-laid after a new one is placed, strokes) is drawn about 6% closer to the top-left of the map. Things that haven't redrawn stay where they were, which is why it looks random.

In cloud mode the trigger is ordinary editing. The folder list the server pushes includes each folder's agents in play (#343, Oct 19). Placing an agent a folder hasn't used yet changes that list. The server pushes it, the library rebuilds under the editor, and the coordinates shrink. A teammate adding a folder or a strategy does the same. Reading the code, a sign-in change (such as a token refresh) that rebuilds the folder list should do it too.

Fix

Only a canvas sets the coordinates now. The library's line is gone. That line also kept CoordinateSystem.instance from throwing before any canvas had laid out (a strategy's page can load before its canvas is on screen). So instead of throwing, CoordinateSystem now starts with the 1920×1080 capture size until a canvas lays out, as the library's size did before.

Ground truth

Windows release builds of main and of this branch, each with a scratch driver that sends real pointer events. Run on the dev deployment with a test account. Window 1584×891, so the canvas is 851px tall.

  • main: opened a cloud strategy with two lineups. The coordinates were 851 tall. Placed Jett: 8.6 s later the folder list push arrived and the coordinates became 801 tall. Hovering a lineup then drew both lines off their icons (left image), the same picture as the Discord report.
  • this branch: same steps. The push still arrives and the library still rebuilds, but the coordinates stay 851 tall the whole session. Lines stay on their icons, and new agents land where they're dropped.

Tests

  • test/library_under_editor_coordinates_test.dart mounts the real library, opens a canvas on top with the editor's 40px strip, and rebuilds the library underneath. It fails on main (860 → 810) and passes here.
  • Full flutter test: 2871 passed. One vision geometry test timed out at 30 s while a release build was compiling alongside it, and it passes when run alone.

Not covered

  • I couldn't show a drag saving a wrong position. A drop converts through the coordinates its widget was last built with, and in my runs that was still the right size. Items placed while the coordinates were wrong may still have been saved off. I have no repro of that.
  • ReplayCanvas also sets the coordinates when it lays out. It's a canvas, and it isn't laid out while the editor covers it, so I left it alone.

ci: analyze test web

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

The PR stops FolderNavigator from replacing the editor's coordinates when the library rebuilds underneath it.

  • The editor keeps its canvas coordinates when the library rebuilds.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Strategy loads before canvas] --> B[Use 1920×1080 fallback]
  B --> C[Canvas lays out]
  C --> D[Use canvas coordinates]
  E[Library rebuilds underneath] --> F[Leave coordinates unchanged]
  D --> G[Editor keeps its placement scale]
  F --> G
Loading

Reviews (1) · Last reviewed commit: "Stop the library resizing the editor's c..." · Reviewed by Greptile

The editor opens on top of the library, which stays mounted and rebuilds
whenever something it watches changes (a cloud folder list update, a
token refresh). Each rebuild replaced the shared CoordinateSystem with
one sized for window height - 90, while the editor's canvas is window
height - 40 since the editor took the library's 40px strip. Every item,
lineup line and stroke redrawn after that landed about 6% closer to the
top-left until the canvas laid out again.

Only a canvas sets the coordinates now. Until one has laid out, the
capture size stands in, so a strategy can still load first.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fd15f13c-cfa7-4de6-b77e-1c3cfc062fa4
Commits

Reviewing files that changed from the base of the PR and between f1993e1 and 7728ee3.

Files selected for processing: 3
  • lib/const/coordinate_system.dart
  • lib/widgets/folder_navigator.dart
  • test/library_under_editor_coordinates_test.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@SunkenInTime
SunkenInTime merged commit b45764b into main Oct 28, 2026
15 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