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
//! **The claim a start leaves on the selection**, the row it stands in for, and
//! the answer that spends it.
//!
//! Upstream's rule is *a start focuses what it started* (yog's `docs/DESIGN.md`
//! §3.4), and honouring it directly does not work: the minted name is a barrier
//! — every gesture after the receipt may address it — but only once the
//! detached driver has written the conversation's branch, and until then the
//! server resolves it nowhere. A seat that simply selected it would publish the
//! standing set's third question against an address the server refuses, and
//! paint the operator's own new conversation as unknown for the whole of a
//! healthy start.
//!
//! So the selection is taken and three things ride with it. None of them is a
//! second pending concept: the claim **is** [`Start`](super::Start) in its
//! [`Started`](super::Phase::Started) phase, read against what is selected, and
//! [`Model::pending`] is that reading — the one row the claim amounts to.
//!
//! - **Nothing is asked about it.** [`Model::asked`] is what
//! `crate::state::Standing` publishes as its third question, and a claimed
//! name is not it. An empty conversation pane is what the world honestly
//! holds; a refusal painted there would be this seat asking a question it
//! knew the answer to.
//! - **A row stands where the conversation will be.** [`Model::rows`] is the
//! list every surface paints and walks, so the row is one row in one list
//! rather than a case each of them carries. It is what nothing observed: no
//! lock, no completed step, flagged uncertain — exactly what the server's own
//! classifier answers for a conversation it cannot probe. **It must not read
//! `live`**, which would claim a driver this seat has never seen.
//! - **It is spent where it was made.** [`Model::resolve`] retires the claim
//! the moment the server answers a row under that name, and moves the
//! selection **only while the selection is still the name the claim put
//! there**. A start can take a minute to write its branch, and an operator
//! who read something else in that minute must not be yanked back by their
//! own conversation arriving.
//!
//! **A claim whose row never arrives is inert**, which is what a start whose
//! driver died honestly is: the name stays selected, the row stays faded, and
//! one arrow key leaves it.
use super::start::Phase;
use crate::reply::convs::{AgentState, ConvRow, Tone};
use crate::ui::Model;
impl Model {
/// **The conversation this window started and the server cannot yet
/// resolve**, as the row that stands for it.
///
/// The comparison against the selection is the whole predicate. Aiming
/// elsewhere clears the selection and selecting another conversation
/// replaces it, so a claim that is no longer where it was made answers
/// `None` here with nothing having had to retire it.
///
/// **`name` is absent on the row** for the reason the vocabulary gives that
/// field: it is what a later act may *address*, and this is the one
/// conversation the server will not answer to yet. Withholding it is also
/// what keeps [`resolve`](Self::resolve) from matching this row against the
/// claim it was built from.
pub fn pending(&self) -> Option<ConvRow> {
let start = self.start.as_ref()?;
let Phase::Started(name) = &start.phase else {
return None;
};
if self.conversation.as_deref() != Some(name.as_str()) {
return None;
}
Some(ConvRow {
root_id: name.clone(),
display: name.clone(),
name: None,
state: AgentState::Quiescent,
uncertain: true,
preview: start.goal.clone(),
age_secs: 0,
attention: 0,
members: 1,
depth: 0,
tone: Tone::Weak,
// Nothing has run yet, so nothing has failed: this row is the
// window's own word for a send the server has not confirmed.
failure: None,
})
}
/// **The conversation the standing set may ask about.** A claimed name
/// resolves nowhere, so there is no transcript to ask for and no tail to
/// hold open against it.
/// **Whether the selected conversation is asking for the operator** —
/// read off the row the list paints, so the prompt's glow, the ask above
/// it and the standing read all agree about the one fact they share.
pub fn asks(&self) -> bool {
self.conversation.as_ref().is_some_and(|id| {
self.rows()
.iter()
.any(|row| row.root_id == *id && row.attention > 0)
})
}
pub fn asked(&self) -> Option<String> {
match self.pending() {
Some(_) => None,
None => self.conversation.clone(),
}
}
/// **The conversation list as it is painted and walked** — what the server
/// answered, and the claim's row before the server has anything to answer.
///
/// One list, because the pointer and the keyboard both read it: a row a
/// click could reach and a key could not is the second surface
/// `crate::ui::keys` exists in order not to have.
/// **What hangs under a conversation is under it** (`super::subtree`): the
/// list is the conversations, and an unopened subtree is one gesture away
/// rather than five rows of it. The filter is applied HERE, on the one
/// list, so a row a click cannot reach is one a key cannot walk onto
/// either.
pub fn rows(&self) -> Vec<ConvRow> {
self.unfolded(
self.pending()
.into_iter()
.chain(self.convs.iter().cloned())
.collect(),
)
}
/// **Spend the claim against what the server answered.**
///
/// The name is the join: a row hands back its *addressable* name exactly
/// when a stored fact backs it, which is the same moment the conversation
/// became addressable at all.
pub(super) fn resolve(&mut self) {
let Some(start) = self.start.as_ref() else {
return;
};
let Phase::Started(name) = start.phase.clone() else {
return;
};
let Some(row) = self
.convs
.iter()
.find(|row| row.name.as_deref() == Some(name.as_str()))
else {
return;
};
let root = row.root_id.clone();
let held = self.conversation.as_deref() == Some(name.as_str());
self.start = None;
self.rename_tab(&name, &root);
if held {
self.select(&root);
}
}
}
#[cfg(test)]
mod tests;