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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//! **What a control does, whichever control did it.**
//!
//! The acts the window affords beyond composing a gesture: aim at a workspace,
//! select a conversation, and put a notice down. Each used to live
//! inside the `if …clicked()` that made it, which is fine while a pointer is
//! the only way to make it — and stops being fine once a key can make it. Two
//! spellings of *what aiming means* would drift, and the one that drifted would
//! be the one nobody points at.
//!
//! So a binding names a control that already exists (`crate::ui::keys`), by
//! calling the same door the click calls. **A binding that could fire something
//! a click cannot is a second surface**, which is why the keyboard's own cursor
//! walks only rows the pointer can also reach: an unaddressable roster row is
//! skipped by both, structurally, because both ask the same question.
//!
//! # Each act clears exactly what it invalidated
//!
//! Aiming at another workspace retires the conversation list, what that list was an
//! answer to, the selection and everything under it, because none of it is
//! about the new workspace. Retiring the *answer* beside the rows is what lets the
//! pane say it has not heard yet rather than reporting an empty workspace. Selecting a
//! conversation retires the transcript and the live tail, because they are the
//! old one's. Nothing else is touched — and in particular the draft is not,
//! because what an operator typed is theirs until they send it.
use super::{Aim, Model};
impl Model {
/// **Aim at a workspace**, down the channel that resolved it.
///
/// `address` is what a gesture must carry rather than the name the row
/// wears; the two differ exactly where an entry renames, and the roster is
/// what maps one to the other.
///
/// **Aiming where the window is already aimed retires nothing** (DESIGN
/// §4.39, bl-b9a3). Since the conversations stand under their workspace, the
/// one cursor crosses the aimed workspace's own row every time it moves between
/// the server above it and the rows beneath it — and a cursor passing over
/// a row is not an operator asking about that workspace again. Re-asking would
/// empty the list under the cursor and put *waiting to hear about this
/// workspace* where the rows had been, which is bl-f780's transient defect made
/// reachable by an arrow key. What an aim always does is put the cursor on
/// the workspace and drop the selection under it; what it does only when it
/// MOVED is retire everything that was about the workspace it left.
pub fn aim_at(&mut self, channel: &str, address: &str) {
let aim = Aim {
channel: channel.to_owned(),
address: address.to_owned(),
};
let moved = self.aim.as_ref() != Some(&aim);
self.aim = Some(aim);
self.founding = None;
// **The server remembers the workspace it was left on** (DESIGN §4.39), so
// a server an operator comes back to is the server they left. It is
// recorded here rather than by each surface that aims, for this
// module's own reason: two spellings of *what aiming means* would
// drift, and the one that drifted would be the one nobody points at.
// Keyed by the server and not the channel (bl-13b9): one server
// held under two names is one place to come back to.
let server = self.server_of(channel);
self.servers.aimed.insert(server, address.to_owned());
// **And the roster's cursor is a workspace again.** The walk stands on a
// server row without selecting it; an aim is a selection, so the two
// cannot both be where the operator is.
self.standing = None;
// **The selection goes whichever workspace this is**, because the cursor is
// on the workspace now: `Model::select` is the only thing that puts it back
// on a conversation, and it is the same clearing that one does.
self.moving_to(None);
self.conversation = None;
self.transcript = crate::reply::transcript::Transcript::default();
self.live = None;
if !moved {
return;
}
self.convs.clear();
self.answered = None;
// **The tuning pane goes with the workspace it was opened on** (bl-4a2c).
// It holds no aim of its own, deliberately — every gesture it composes
// reads `Model::aim` at the moment of composing — so leaving it open
// over a new workspace would leave an operator looking at one workspace's rows
// while its controls wrote to another's. Retiring the ROWS beside it is
// the same reading `answered` above gets: `None` is a workspace nobody has
// asked yet, and the old workspace's answer is not this workspace's.
self.tuning = None;
self.roles = None;
self.offers.clear();
// **The login pane goes with the workspace too** (bl-e3c5), and for the
// sharper form of the same reason: its act signs a credential into ONE
// workspace's own store, so a pane left standing over a new aim would offer
// to sign the operator in somewhere they are no longer looking.
self.retire_login();
// **And the clients pane with them** (bl-e53c), on the login pane's own
// terms: its rows are one workspace's registrations, so a pane left
// standing over a new aim would paint one workspace's machines under
// another's name.
self.retire_clients();
// **And the offers page**: its rows and its minted URL are one
// workspace's.
self.retire_offers();
// **And the config pane with them** (bl-5c53), sharper again: a
// destination carries the aim's own workspace inside it, so a pane
// left standing over a new aim would read one workspace's file and paint it
// under another's name.
self.retire_configuring();
self.retire_records();
// **The ball pane's WORKSPACE half goes with the workspace, and the pane does
// not** (bl-d2af). Two of its four reads name every channel, so the
// pane's subject survives an aim that moved; the two that name one
// workspace do not, and painting the old workspace's balls under the new workspace's
// name is exactly what the retirement above prevents one level up.
self.retire_workspace_balls();
// **The fleet pane goes with the workspace too** (bl-a43a), and for the
// login pane's sharper reason: its acts run drones and spend money in
// ONE workspace, so a pane left standing over a new aim would offer to
// start a fleet somewhere the operator is no longer looking.
self.retire_fleet();
}
/// **Select a conversation**, by the id every gesture addresses it with.
/// A selection is where the cursor is (bl-f991), and opens its tab; the
/// switcher's walk is the one cursor that does not (`super::walk`).
pub fn select(&mut self, root_id: &str) {
self.preview(root_id);
self.open_tab(root_id);
}
/// **Assert this workspace's place in the strip** — pinned, or not (bl-7782).
///
/// `pinned` is what the operator is asking FOR, not what the row currently
/// is: the wire's two ops are assertions rather than a toggle, and upstream
/// says why — *"unpinning one that is not pinned leaves the list alone,
/// which is what lets two seats send it at once and agree."* So this end
/// composes the act it means and never flips a flag it read a beat ago.
///
/// The aim is the gate, exactly as it is for every other per-workspace act, and
/// what says it landed is the next roster answer: both ops reply with the
/// listing carrying the ranks it now has, which is a kind this seat already
/// paints.
pub fn post_pin(&mut self, pinned: bool) {
let Some(Aim { address, .. }) = self.aim.clone() else {
return;
};
let gesture = if pinned {
crate::verbs::pin(address)
} else {
crate::verbs::unpin(address)
};
self.outbox.push(super::Posted::act(gesture));
}
/// **Put the notice down.** An operator who has read a refusal should not
/// have to wait for the next answer to clear it.
pub fn dismiss(&mut self) {
self.notice = None;
}
/// **What Escape means**, in the order an operator means it (bl-7574,
/// extended for the tuning pane in bl-4a2c).
///
/// A ladder from the innermost thing on the glass outwards, which is the
/// order the key is actually reached for. First a draft assignment,
/// which is a thing inside a pane rather than the pane: Escape over a
/// half-typed model puts the draft down and leaves the rows standing.
/// Then the tuning pane itself, then the ball pane's authoring block
/// (bl-f7ae) — a thing INSIDE a pane rather than the pane, on the draft
/// assignment's own terms: Escape over a half-typed title puts the block
/// down and leaves the board standing. Then the records pane (bl-2cf7), then the
/// decision queue (bl-f0ef), then whichever of the window's own two is
/// standing (bl-40ec — one arm, because one field holds both), then the
/// login pane (bl-e3c5), then the clients pane (bl-e53c), then an
/// unmaking (bl-48fa) — no two of the nine ever stand together, so the
/// order among them is never spent. The
/// unmaking is on the ladder because Escape over a destructive pane means
/// what [`Model::close_unmaking`] means and nothing else: it unmakes
/// nothing, and a key that could arm or spend one would be the second
/// surface `crate::ui::keys` refuses to be. With nothing covering, the notice
/// is the only thing left to put down, and Escape is its × reached without
/// a pointer.
pub fn escape(&mut self) {
if self.dropup.is_some() {
self.close_dropup();
} else if self.switching {
self.close_switcher();
} else if matches!(self.tuning, Some(super::Tuning::Editing(_))) {
self.cancel_assignment();
} else if self.tuning.is_some() {
self.close_tuning();
} else if self.authoring.is_some() {
self.close_authoring();
} else if self.showing(super::Listing::Queue) {
self.close_queue();
} else if self.showing(super::Listing::Clients) {
self.close_clients();
} else if self.showing(super::Listing::Offers) {
self.close_offers();
} else if self.fleet.is_some() {
self.close_fleet();
} else if self.lookup.is_some() {
self.close_lookup();
} else if self.login.is_some() {
self.close_login();
} else if self.unmaking.is_some() {
self.close_unmaking();
// **The three re-homed panes last among the panes** (DESIGN §4.48
// item 8): floating they are exclusive with the rest, so the order
// is never spent; docked they stand beside whatever floats, and Esc
// reaches them once nothing does — the context rail first, being
// about what is selected, then the branch.
} else if self.context.is_some() {
self.context = None;
} else if self.clearing() {
// Back to the trail it was opened from, which is what the pane's
// own way out did (`crate::ui::clear`).
self.close_clearing();
} else if self.trail.is_some() {
self.close_trail();
} else if self.founding.is_some() {
self.founding = None;
} else {
self.dismiss();
}
}
}
#[cfg(test)]
mod tests;