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
//! Whether a message submitted during a running turn is a duplicate (#798).
//!
//! Recalling the previous message with Arrow Up and pressing Enter while a turn
//! is still running used to queue it unconditionally, so an accidental
//! double-Enter became a second real turn: the same question answered twice,
//! both copies persisted, and both reloaded into context on every later turn of
//! the session. The duplicate is pure waste and biases the model toward
//! re-answering.
//!
//! The comparison is deliberately short-sighted. It looks only at the turn
//! currently in flight and the messages already queued behind it, never further
//! back, so deliberately repeating yourself later in a session is untouched.
//! Repetition is only meaningless while the first copy has not been answered
//! yet.
//!
//! Pure so the decision is testable without a TUI or a running turn.
/// What to do with a message submitted while the session is busy.
pub
/// Classify `incoming` against the turn in flight and the pending queue.
///
/// `in_flight` is the user message the running turn is answering, if known.
/// `queued` is what is already waiting behind it.
///
/// Matching is exact after trimming. Anything looser would eventually drop a
/// message the user meant to send, and a wrongly dropped message is far worse
/// than a duplicate: one wastes context, the other silently loses work.
pub