voelin-gpui: the tree and members events carry the rows their operations lead to

TreeEvent::Rows and ::People carried the row operations only, and the panes
applied them to the model's rows read when the event was delivered. A model
that refreshes twice in one flush (it listens to the tree, toolbar and member
card signals, and a batch raises several) holds the second rows by the time a
pane hears of the first operations, so an observer that changes the state
inside the flush made the first operations index the second rows: the gate's
probe, select_server from the observer of the toolbar signal during a
Presence flush, panicked in ChannelTree::apply on the shrink.

The events now carry the rows (Rows(Changes, Arc<Vec<TreeItem>>), People the
same) and the panes apply the operations to the rows they have and keep the
carried ones, so the events lead from the rows a pane started with to the
model's last whatever the order of the flush. apply checks the counts in
debug builds (debug_check), and "For the next slices" has the rule: a signal's
observer reads the state and sets its own fields, a change of the root state
is an action's or a task's. The probe is a test
(a_state_change_inside_a_flush_does_not_apply_old_operations_to_new_rows); it
panicked on the code before ("index out of bounds: the len is 0 but the index
is 3", channels.rs) and passes now.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-28 07:22:58 +03:00
1 parent e61919ebf4
commit 6b01e25391
5 files changed
+134 -35

No files matched your search

+23 -3
View File
@@ -1502,9 +1502,12 @@ the tests:
entity builds the rows for both panes on the tree, toolbar and member-card
signals, compares them with the rows it had (`voelin_ui_vm::list::diff`, the
operations the Slint front end applies to its `VecModel`) and emits what
differs. A pane applies the operations to its list state (`gpui::ListState`:
a person who joins is a row inserted and the scroll stays where it was), and a
change that moves none of the rows of a pane emits nothing to it.
differs, with the rows the operations lead to (`TreeEvent::Rows(Changes,
Arc<Vec<TreeItem>>)`, `People` the same). A pane applies the operations to its
list state (`gpui::ListState`: a person who joins is a row inserted and the
scroll stays where it was) and to the rows it has, and keeps the rows the
event carries, not the model's at the moment it hears of them; a change that
moves none of the rows of a pane emits nothing to it.
- **The tree carries no `talking`.** Its rows are built with the flag cleared,
so someone who starts or stops talking changes the members panel (and the
sidebar's own card when it is us) and not the tree: its pane is not rendered
@@ -1766,6 +1769,23 @@ the slices that meet it; none of it is a defect of what exists today.
panes (a cached view inside a view that renders again is rendered again), and
raises its flag from `Signals::areas`. A new area is one more variant of
`signals::Area`.
- **No state change from a signal's observer, inside a flush.** The model
listens to three signals (tree, toolbar, member card) and a batch raises
several of them, so it may refresh twice in one flush of GPUI's effects, and
what it emitted the first time is delivered after the second refresh has
run. An observer that changes the state in that window (`select_server`,
say, in the observer of a signal) makes the second refresh a different list
from the one the first operations were made for. The events carry their rows
for that reason, and the panes check in debug builds that the operations lead
from the rows they have to the rows carried (`debug_check`); a probe in the
tests makes exactly this change, from the observer of the toolbar signal
during a Presence flush, and found the old code indexing past the end of the
rows (`a_state_change_inside_a_flush_does_not_apply_old_operations_to_new_rows`).
The rule for a new part is that an observer of a signal reads the state and
sets its own fields, and a change of the root state belongs to an action's
handler or a task of its own, not to a signal's observer. The events that
carry no rows (`Selection`, `Lists`, `Card`) are read from the model at
delivery and end right whatever the order.
- **A click renders every pane; a hover only the pane it is over.** In gpui-pre
0.3.10 pressing a clickable element and releasing it call `window.refresh()`
(`elements/div.rs`), which ignores every cache for that frame, so a click on a