Skip to content

refactor(erd): ErdViewController, toolbar, group menu and card cache out of _ErdViewState (#1690) - #1723

Merged
ZhuchkaTriplesix merged 4 commits into
devfrom
refactor/erd-view-split
Oct 18, 2026
Merged

ZhuchkaTriplesix merged 4 commits into
devfrom
refactor/erd-view-split

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Refs #1690 (first of the small PRs the issue asks for: the controller first, the canvas second)

erd_view.dart: 1844 -> 1482 lines; behaviour and look unchanged.

  • ErdViewController (erd_view_controller.dart, no widget imports) owns the user's state of a diagram: the pick, picked relation and marks, density (detail, collapsed, hidden), header colours, groups, notes, saved views, the search flags, and the rules on them as plain methods: createGroup / addToGroup / updateGroup / ungroup / removeFromGroup, toggleMarked, hide, setHeaderColor, applyState, note move / resize / followTables, canvasSize, view ids / rename / remove, pick / pickRelation / clearPicks, escape() (one step per press, returns which), currentFocus and cardFocusFor. _ErdViewState keeps the layout, routes, viewport, dialogs and the decision when to rebuild and save, and calls it.
  • ErdToolbar (widgets/erd_toolbar.dart): the 110-line toolbar of build.
  • erdGroupMenu (widgets/erd_group_menu.dart) and ErdCardInputs (widgets/erd_card_inputs.dart): the card's group menu and the key by which a card is reused.
  • ErdCardCache (widgets/erd_card_cache.dart): the ci(bench): erd_open_200 scenario times out in app_perf_bench; make bench failures exit non-zero #1546 card reuse and chunked mounting, as a class with its own constants.

Tests: erd_view_controller_test.dart (20 tests, no WidgetTester): group creation / adding / removal and the marks, hide / collapse / colours, applying a saved state, notes (update, move and resize at a zoom, following a table, canvas growth), views (ids, rename, remove), pick vs picked relation, the Esc sequence, focus and fading. The existing 120 ERD tests pass unchanged, and so do workspace, core/erd and e2e (803 locally). Bench after the change: erd_open_200 build p90 18.4 ms, erd_hover and erd_drag 0.3 ms p90.

Not done here, for the next PR: the canvas (viewport / zoom / fit / hover / edge tip and the layers of build) as ErdCanvas. erd_view.dart is still above the ~900 lines of the acceptance list, so the issue stays open.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 18, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit b09fdf6 into dev Oct 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant