Repository navigation
Conversation
A reconnecting client keeps its control tree, and its View looks up the page's _overlay and _dialogs containers once. ruflet_rails (ConnectionProtocol) re-sent them as replace ops, and ruflet run merged them by ids that moved with the content, so the client built new containers and no dialog, snack bar or bottom sheet showed again. - Page: _overlay, _services and _dialogs keep fixed wire ids 3, 4 and 5, below the allocator's 100, like the page (1), window (2) and view (20). - Page#register_containers_patch: only those containers, for a register reply that op patches follow; marks them mounted. Until the next view patch, container content set without a push (overlay <<, a dialog given to set_view_props) still goes out, as its own patch. - ConnectionProtocol sends that patch in the register_client reply, for a fresh and a resumed Page, before the app block. The rest of the page still streams as op patches: first paint stays progressive. - show_dialog checks whether the container is mounted, not whether it has a wire id (it always has one now). Behavior changes: the containers' wire ids (app controls after them get ids 3 lower); the Rails register reply carries the containers and the page patches no longer replace them (the 5 --rails-endpoint H1 page goldens, regenerated; same message counts).
|
Plants: each part of the fix put back on its own in a scratch copy, with the new and changed tests run against it. Every plant is caught by at least one test. container ids back on the allocator (the three
ConnectionProtocol back to
no flush of container content set before the first view patch (
All of main (a668af6), no fix
|
page.snack_bar=, dialog=, bottom_sheet= and overlay= push their container as soon as it is mounted, which the register reply now does. A prop set on the control afterwards (snack_bar.props["open"] = true), before the app block's first view patch, was compared only against the container's own state, so it was never sent and then recorded as sent. The check now walks the container's subtree. On main the first view patch carried the whole container, so the client got that change. Tests: the snack bar, dialog and bottom sheet opened after their setter, an overlay control changed after overlay=, the real Rails LocalServer case, and that only the first view patch flushes.
|
Plants on head 0d29af4: each part of the fix put back on its own in a scratch copy, with the new and changed tests run against it (
Q1 is this round's fix put back (the check compares only the container's own state, as on 8ad4f20). Q2/P5 is the non-blocking finding: the flush window that never closes is now caught. P9 and P11 are equivalent on this head: |
Fixes #142
A client keeps its control tree when it reconnects, and its View holds the page's
_overlayand_dialogscontainers it looked up once. Both servers used to hand a reconnecting client containers that replaced those instances, so after a reconnect no dialog, snack bar or bottom sheet showed again:ConnectionProtocol) re-sent the containers as replace ops.ruflet run(Ruflet::Server) merges itspage_patchby id, but the container ids moved with the content.What changed
Page(ruflet_core):_overlay3,_services4,_dialogs5 (Page::OVERLAY_WIRE_ID,SERVICES_WIRE_ID,DIALOGS_WIRE_ID). This follows the page (1), window (2) and implicit view (20). The allocator still starts at 100, so nothing collides.Page#register_containers_patchreturns only the three containers as a property map, marks them mounted, and records what they hold. It does not publish the page shell, so the nextpage.updatestill sends the views.register_containers_patchchecks each container and every control inside it. If anything changed and was not sent, that container's own patch goes out right after the view patch. Examples:page.overlay << control, a dialog given toset_view_props, orsb.props["open"] = trueafterpage.snack_bar = sb. Later view patches do not run this check: they send what they sent on main.show_dialogdecided whether to send the page first by "the container has a wire id". It now checks "the container is mounted", because the id is always set. A page whose containers are not mounted still sends the page first, as before.Ruflet::ConnectionProtocol(ruflet_server, run by ruflet_rails'LocalServer): theregister_clientreply'spage_patchcarries those containers, for a fresh Page and for a resumed one, before the app block runs. The client merges that map by id, so a reconnecting client keeps its instances. The rest of the page still streams as op patches while the app block renders it.Ruflet::Serverdoes it. That would hide a spinner the block shows before slow work, and it would delay the first message until the block ends.Ruflet::Serverneeds no change: with fixed ids, itspage_patchmerges into the client's containers on any route.No API, CLI or Rails host API change. Nothing is configured differently, and apps need no change.
Behavior changes
All four follow from the #142 fix. In each case in the table below, the client ends with the same UI as on main, except the last row, which fixes a lost update.
ruflet runnormalize ids by first appearance, and the order is unchanged, so they show no diff.{}, and the page patches no longer replace them. On a first connect the client builds the same containers, from the reply instead of from the first patch. After a reconnect it keeps its containers, which fixes the bug.--rails-endpointpage goldens. Their register reply carries_overlay,_servicesand_dialogs, and their page patch no longer does. Each has the same number of messages as on main.page.dialog=,snack_bar=,bottom_sheet=,overlay=,services=,add_serviceandservice(...)now send apatch_controlto container 3, 4 or 5 right away, ahead of the view patch. The client has that container from the register reply. This is what these setters already do once the containers are mounted, in event handlers and underruflet run. On main, in this window, the dialog setters sent nothing.overlay=and the services setters sent a patch to an allocator id the client did not have yet. The content then arrived inside the first view patch.Messages each app block sends after the register reply. Measured with the real
ConnectionProtocoland a client that merges by id:page.snack_bar = Ruflet.snack_bar(..., open: true);page.add(same withdialog=andpage.update)page.overlay = [t];page.addpage.service(:clipboard);page.add(same withadd_service,services=)page.snack_bar = sb;sb.props["open"] = true;page.add(same withdialog=andpage.update, and withbottom_sheet=)page.overlay = [t]; changet;page.addtpage.overlay << t;page.addpage.show_dialog(d);page.addpage.show_dialog(d); change the dialog's title;page.addHow verified
All on head 0d29af4 (main d3f7f12 merged in).
New tests. Each fails on main and passes here, except
test_rails_first_paint_stays_progressive, which guards what main already does. Each part of the fix was planted back on its own, and at least one test catches each plant (comments below).ruflet_core/test/page_internal_containers_test.rb(11 tests): fixed ids on any content, no collision with the allocator, the containers-only patch, a resumed page's open dialog, content set before the first view patch, a change inside a container after its setter (snack bar, dialog, bottom sheet, overlay control), nothing sent twice, only the first view patch flushes, andshow_dialogon an unmounted page.ruflet_server/test/reconnect_containers_test.rb(5 tests): uses a small model of the engine's two apply paths (Control.updatemerges by_i, a replace op builds new controls). It checks that the View's captured_dialogsand_overlayinstances survive a Rails fresh reconnect, a Rails resumed reconnect, and aruflet runreconnect on a route with more content, and that the dialog shown afterwards lands in them. It also checks the register reply shape, and that Rails first paint stays progressive.ruflet_rails/test/local_server_reconnect_test.rb(3 tests): the realLocalServerwith aSessionRegistry. A fresh Page after the old socket closed names the same containers; a dialog shown afterwards patches container 5; a snack bar opened afterpage.snack_bar=in the app block reaches the client open.ruflet_rails/test/session_registry_test.rb#test_local_server_reattaches_existing_page_when_websocket_reconnectsasserted the replace op this fixes. It now asserts that the container, with the open dialog, is in the register reply, and that the reattach patch carries views but no_dialogs.page_api_coverage_test.rblists the new public method.Real client replay. A widget test replayed the wire of 5 scenarios through the real
PageControl, Navigator andViewControl, with a real disconnect and reconnect, a client that keeps its tree, and then a dialog. It ran with Flutter 3.41.2 on enginecodex/engine-initialization00d1df3c and on the vendored engine in template main 8b08569, the client published gems build. The test itself is not committed. The wire of those 5 scenarios, regenerated on this head, is identical to the replayed one except for the random service uid.Suites, one process per file: ruflet_core (212 files), ruflet_server (19), ruflet_rails (22, under
bundle exec) and ruflet (28), all green. H1 goldens:ruby test/compat/compat.rb --jobs 4checked 359 goldens, rc 0, andtest/compat_goldens_test.rbpasses. No golden changed in this round; the 5 above are the only diffs against main.page.rbandconnection_protocol.rbcompile with the embedded VM'smrbc. Both are compiled into the--selfruntime.Notes for reviewers
_dialogslist sent as a whole list) is being fixed separately (fix: change the page's Dialogs layer by list operations, never re-send open dialogs #141). It records the dialogs list whenever the whole container goes to a client.register_containers_patchis a new such point, alongsideregister_page_patchand a mounting view patch. The first-view-patch flush here usespush_dialogs_update!, so it picks up that fix's list ops.page.overlay << x; page.add(y)in an event handler. Soxnever reaches the client, on main and here. A test pins that later view patches send what they sent on main. This PR keeps today's behavior there, because Dialogs layer is re-sent as a whole list: a second overlay duplicates an open dialog that then cannot close; close+show and hot reload strand a modal #138 is reworking how the dialogs list is patched.ViewControlcould also re-resolve_overlayand_dialogsindidUpdateWidget, as hardening on the client side. This fix does not depend on it.