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
//! The `--tui` mode implementation of [`AnalysisProgress`] (ADR 0033):
//! redraws `rinkaku_tui`'s splash screen on the same terminal
//! `TuiSession::init` already opened, in place of ADR 0032's stderr
//! spinner.
//!
//! Wraps the live [`rinkaku_tui::TuiSession`] in a [`std::sync::Mutex`]
//! rather than holding a plain `&mut` — `rinkaku_core::pipeline::analyze_repo`'s
//! `on_progress` callback (ADR 0033) is called from rayon worker threads
//! during the parallel whole-repo parse (ADR 0031), so the closure
//! `main.rs` builds around this type must be `Sync`. No genuine concurrent
//! contention is expected in practice (the stride in
//! `rinkaku_core::progress::should_report_progress` already bounds how
//! often any thread calls in), but the `Mutex` makes the one-terminal-at-a-
//! time invariant a compile-time guarantee rather than an informal
//! assumption about how often two strided calls could land at once.
use crateAnalysisProgress;
use crate;
use TuiSession;
use SplashState;
use Mutex;
/// The mutable state [`SplashProgress`] guards behind one [`Mutex`] — the
/// live terminal, the currently-cached phase label (so a file-progress
/// redraw can still show *which* phase is measuring that progress, since
/// `rinkaku-core`'s `on_progress` callback only ever receives `(done,
/// total)`), and the buffered notes (ADR 0033's note-deferral decision, see
/// [`AnalysisProgress::note`]'s own doc comment for why raw `eprintln!`
/// during `--tui` mode corrupts the alternate screen).
/// See the module doc comment. Owns the [`TuiSession`] for the duration of
/// the analysis phase; `main.rs` extracts it back out via
/// [`SplashProgress::into_session_and_notes`] once analysis finishes, to
/// hand the terminal off to [`TuiSession::run`]'s main event loop and flush
/// the buffered notes to stderr only after that terminal has torn down the
/// alternate screen.
pub
// No unit tests in this module: `TuiSession::init` needs a real terminal
// (ADR 0033's own doc comment on why `TuiSession`'s lifecycle is not
// unit-tested, mirroring ADR 0032's stance on `Spinner`), so a real
// `SplashProgress` cannot be constructed in a unit test — every method here
// is a thin wrapper (a `Mutex::lock` plus a field write/`Vec::push`/
// `TuiSession::draw_splash` call) with no branching logic of its own to
// exercise in isolation. The two things actually worth pinning as pure
// logic — "an `AnalysisProgress` implementer can override `note` to buffer
// instead of printing" and "buffering preserves call order" — are covered
// by `crate::progress::tests::should_buffer_note_instead_of_printing_when_note_is_overridden`,
// which exercises the exact same trait contract this type implements
// without needing a terminal. This type's own behavior is covered by this
// PR's dynamic verification (pty-driven `--tui` runs, see the PR body).