1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//! The §11 **unfold** (bl-fa82; re-cut at the boundary's altitude by bl-44e9):
//! the conversation list's rows over the descent forest, and the seat-side fold
//! that picks the visible ones out of them.
//!
//! The reframe this module is: **a list row is the subtree rooted at its
//! agent**, and the root-only list every earlier version painted is the
//! all-collapsed case — [`super::build`] is literally [`visible`] over the whole
//! forest with an empty set. Expansion reveals a row's direct children as rows
//! of the same anatomy, recursively, so there is no second row kind and no
//! child-rendering path.
//!
//! **The derivation and the fold are two functions, and that is REMOTE §9.7's
//! altitude ruling** (bl-44e9). [`forest_rows`] answers the whole forest with
//! its per-row rollups — the shape a `Reply::Conversations` carries — and
//! [`visible`] is the *seat's* pure selection out of that answer, over rows
//! rather than over a snapshot. So the fold never crosses the boundary (DESIGN
//! §8.5: *views gain no boundary representation*), one derivation still serves
//! every seat, and a seat with no fold at all selects the root subset.
//!
//! A pre-order walk
//! that stops descending at a node the caller's set does not name, with the set
//! passed **in** rather than stored — expansion is viewport ephemera (§5.3,
//! §13.1) and never rides a [`ConvRow`].
//!
//! The **mutation** is that module's too: a click on the §11 subagent field
//! flips one id's membership in that set, the crate's one
//! disclosure-set toggle, already shared by the transcript and queue folds. A
//! second spelling of "flip a membership" would be a second thing to keep
//! honest, so this module only ever *reads* a set.
//!
//! Membership is §5.1 #8's strict descent-id rule ([`descent_order`] /
//! [`children_of`](crate::git_tree::children_of)), never the looser prefix test
//! the Stop menu's `+children` seat uses.
use HashSet;
use ;
use ;
use crate;
use crateCheck;
use crateSeenKind;
/// The §11 list at its **whole altitude**: every member of the workspace's
/// descent forest, each projected over its own subtree, in paint order. The
/// answer a `Reply::Conversations` carries (REMOTE §9.7) — no fold reaches it,
/// because the fold is the seat's ([`visible`]).
///
/// Order is §11's, both halves of it: depth-0 subtrees by **recency alone,
/// descending, then root id** for the deterministic tail (I9, bl-cad5), and
/// within a subtree the §2.3 descent order [`descent_order`] already yields
/// (id-sorted siblings, each one's children directly beneath it). Every fold of
/// it is therefore a contiguous *subsequence*, which is what makes [`visible`] a
/// selection rather than a second sort.
/// **The seat's fold** (REMOTE §9.7): the rows of an answered forest that this
/// viewport's `expanded` set makes visible, in the order the answer gave them.
///
/// A row is painted unless some ancestor of it is shut, and the cut is by
/// **depth** — pre-order says a row's ancestors are exactly the shallower rows
/// above it — so one pass needs no recursion, no stack and no snapshot. A row
/// whose id the set does not name closes over its whole descent; an empty set is
/// therefore the root subset, which is the all-collapsed list a seat with no
/// viewport at all reads.
/// A conversation's root id — the sort's deterministic tie-break. Empty for the
/// unreachable rowless conversation ([`conversations`] emits none).
/// The contiguous pre-order slice rooted at `subtree[at]`: that row, then every
/// row beneath it — the ones deeper than it, up to the next row at its own
/// depth or shallower. Total by construction rather than by a guard: an
/// out-of-range position takes depth 0, cuts at the very next row and then
/// slices nothing, which is the empty answer without a branch to reach for it
/// (no caller is out of range — the positions come from [`visible_indices`]
/// over this same slice).
/// Step `delta` rows (±1 for ↓/↑, §11) from `selected` through the **visible**
/// rows in paint order, wrapping. The walk never expands and never collapses:
/// a collapsed subtree contributes one row here, so `↓` from a collapsed parent
/// lands on the next row at the same level and `↓` after a `→` enters the first
/// child — the operator's ruling with no branch to implement it (bl-fa82).
/// A `None`/unknown selection starts before the front, so `+1` lands on the
/// first row and `-1` on the last; an empty list yields `None`.
/// The row `id` hangs under, read off the painted rows themselves: the nearest
/// row **above** it at a shallower depth (§11's `←` paging back up to the last
/// level). Purely structural — a visible row's parent is visible by
/// construction, so no snapshot lookup is needed. `None` at depth 0 and for an
/// id this list does not paint.
/// The descent-id chain above `agent_id`, outermost first — what a **jump**
/// expands so its landing is on a visible row (§11's visible-selection
/// invariant, §6: arriving somewhere you cannot see leaves *why am I here*
/// unanswered). Read off [`descent_order`] rather than re-deriving the grammar,
/// so it is the same parentage the list itself renders. Empty for a root, and
/// for an id this snapshot does not carry.
///
/// The walk carries the open chain as a stack, truncated to each row's depth —
/// pre-order says every row's ancestors are exactly the rows above it that are
/// shallower, so the truncation *is* the parentage and nothing re-derives it.