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
//! Activity strip and project-removal undo snackbar.
use iced::{
Alignment, Element, Length,
widget::{Space, button, container, row, text},
};
use knotra_ui::widget::{SMALL_BUTTON_HEIGHT, centered_button_label, style};
use crate::{
message::{ActivityMessage, Message, WorkspaceMessage},
state::{ActivityRetryAction, AppState, LatestOpState, RetryAvailability},
};
pub fn view(state: &AppState) -> Option<Element<'_, Message>> {
let tokens = &state.theme.tokens;
if let Some(removal) = &state.recent_removal {
let msg = format!(
"{} {}.",
state.t("plain.undo.removed_prefix"),
removal.project.name,
);
let snackbar = container(
row![
text(msg)
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(tokens)),
Space::new().width(Length::Fill),
// Task 100 §3: styled like every other knotra button —
// `style::secondary`/`style::ghost` plus `with_focus_ring`,
// the same shape `freezer.rs::styled_button` uses. Neither
// button is a focus target (the snackbar sits outside the
// `Layer`/`layer_focus` system entirely), so `is_focused` is
// hardcoded `false` rather than left out — the same choice
// `freezer.rs`'s own `styled_button` doc comment makes for
// this stage.
button(centered_button_label(
text(state.t("plain.undo.undo"))
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(tokens))
))
.height(SMALL_BUTTON_HEIGHT)
.padding([0, 12])
.on_press(Message::Workspace(WorkspaceMessage::UndoRemoval))
.style({
let t = tokens.clone();
move |_theme, status| {
style::with_focus_ring(&t, false, style::secondary(&t, status))
}
}),
button(centered_button_label(
text(state.t("plain.undo.dismiss"))
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(tokens))
))
.height(SMALL_BUTTON_HEIGHT)
.padding([0, 12])
.on_press(Message::Workspace(WorkspaceMessage::DismissUndoSnackbar))
.style({
let t = tokens.clone();
move |_theme, status| {
style::with_focus_ring(&t, false, style::ghost(&t, status))
}
}),
]
.spacing(8)
.align_y(Alignment::Center)
.padding([4, 12]),
)
.width(Length::Fill);
return Some(snackbar.into());
}
match &state.activity.latest {
LatestOpState::Idle => None,
LatestOpState::Running {
label, done, total, ..
} => {
let progress_label = if *total > 0 {
format!("⟳ {} {}/{}", label, done, total)
} else {
format!("⟳ {}", label)
};
Some(
container(
row![
text(progress_label)
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(
tokens
)),
Space::new().width(Length::Fill)
]
.spacing(8)
.align_y(Alignment::Center)
.padding([4, 12]),
)
.width(Length::Fill)
.into(),
)
}
LatestOpState::Completed { log, retry } => {
let succeeded = log.result.successful_projects().len();
let failed = log.result.failed_projects().len();
let skipped = log.result.skipped_projects().len();
let icon = if failed == 0 {
"ⓘ"
} else if succeeded == 0 {
"✗"
} else {
"⚠"
};
// RFC-035 R16/Handoff 030 §4.2: `failed` is now guarded the same
// way `skipped` already was — a fully successful run no longer
// prints "0 failed" (`060` finding 4). `succeeded` stays
// unconditional: it is the segment that anchors the count, and
// a run with zero successes needs "0 succeeded" to say so.
// Building the segments as a list and joining them (rather than
// conditionally appending onto a base string) is what keeps the
// separator from dangling when a segment is omitted.
let mut segments = vec![format!(
"{} {}",
succeeded,
state.t("plain.activity.succeeded")
)];
if failed > 0 {
segments.push(format!("{} {}", failed, state.t("plain.activity.failed")));
}
if skipped > 0 {
segments.push(format!("{} {}", skipped, state.t("plain.activity.skipped")));
}
let label = format!(
"{} {}: {}",
icon,
super::operation_kind_label(state, &log.result.kind),
segments.join(", "),
);
let mut content = row![
text(label)
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(tokens)),
Space::new().width(Length::Fill)
]
.spacing(8)
.align_y(Alignment::Center);
match retry {
RetryAvailability::Available(action) => {
let (label, source_operation_id) = match action {
ActivityRetryAction::FetchFailed {
source_operation_id,
..
} => (
state.t("plain.activity.retry_failed_fetches"),
source_operation_id,
),
ActivityRetryAction::ReviewSmartPull {
source_operation_id,
..
} => (state.t("plain.activity.review_retry"), source_operation_id),
};
let retry = (!state.operation_interlock.is_busy()).then_some(
Message::Activity(ActivityMessage::RetryRequested {
source_operation_id: source_operation_id.clone(),
}),
);
content = content.push(
button(
text(label)
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(
tokens,
)),
)
.on_press_maybe(retry),
);
if state.operation_interlock.is_busy() {
content = content.push(
text(state.t("plain.activity.busy"))
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(
tokens,
)),
);
}
}
RetryAvailability::Unavailable(reason) => {
content = content.push(
text(state.t(reason.i18n_key()))
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(
tokens,
)),
);
}
RetryAvailability::NotApplicable => {}
}
content = content.push(
button(
text(state.t("plain.activity.details"))
.size(snora::design::style::text::body_small_size(tokens))
.line_height(snora::design::style::text::body_small_line_height(tokens)),
)
.on_press(Message::Activity(ActivityMessage::DetailsRequested {
operation_id: log.result.operation_id.clone(),
})),
);
Some(
container(content.padding([4, 12]))
.width(Length::Fill)
.into(),
)
}
}
}