knotra 0.34.0

knotra: multi-project VCS dashboard and bulk-operation tool.
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
//! Dashboard toolbar: status filter chips, grouping/sorting selectors,
//! search, and the bulk-selection entry point.
//!
//! Migrated onto the RFC-035 Stage 1 primitives (`chip::filter`,
//! `select::pick_list`) in Stage 2 commit 2. Rebuilt as one region per the
//! External Design sketch: a chip row, then a single controls row — the
//! old four-stacked-elements layout and its `Space::new().width(Fill)`
//! spacer (which marooned the bulk-selection button at the far edge) are
//! gone.
//!
//! RFC-035 Stage 4/Handoff 028 added a second, compact composition
//! (`view_compact_toolbar`/`compact_focus_order`): chips beyond the first
//! three behind a `⋯` overflow, both selectors behind a `▾` disclosure.
//! Handoff 028 §4's "standard stays byte-for-byte unchanged" rule held
//! until RFC-073 D2, which explicitly changes the standard/wide composition
//! too: Group and Sort move into one "Arrange" control, shared by both
//! bands (`arrange_button`/`arrange_panel`) — the duplication Handoff 028
//! accepted between the two compositions' grouping/sorting construction is
//! gone with it, since both bands now call the same panel builder.

use iced::widget::{Space, button, column, container, row, text};
use iced::{Alignment, Element, Length, Padding};
use knotra_ui::widget::{
    BUTTON_HEIGHT, Tokens, centered_button_label, centered_button_row, chip, icon, select, style,
};

use crate::{
    config::{DashboardGrouping, DashboardSort},
    message::{DashboardMessage, FilterMessage, Message, SelectionMessage, StatusFilter},
    state::{
        AppState, SelectionSummary,
        dashboard::badge_for_filter,
        focus::{FocusOrder, FocusTarget},
    },
};

use super::width_mode::WidthMode;

/// Stable keys for the toolbar's `FocusTarget`s (RFC-036), shared between
/// [`focus_order`] (Tab/Shift-Tab + activation) and [`view_toolbar`] (which
/// control currently draws the ring). Kept as one list so the two cannot
/// drift — same discipline as `shell.rs`'s and `workspace_manager.rs`'s own
/// `focus_target` modules.
mod focus_target {
    pub const FILTER_NEEDS_HELP: &str = "dashboard.toolbar.filter.needs_help";
    pub const FILTER_DIRTY: &str = "dashboard.toolbar.filter.dirty";
    pub const FILTER_BEHIND: &str = "dashboard.toolbar.filter.behind";
    pub const FILTER_AHEAD: &str = "dashboard.toolbar.filter.ahead";
    pub const FILTER_ALL_SET: &str = "dashboard.toolbar.filter.all_set";
    /// RFC-073 D2: replaces the old separate `GROUP_SELECT`/`SORT_SELECT`
    /// targets in both bands — one "Arrange" control, opening a menu that
    /// holds both selects unchanged, is now the single Tab stop.
    pub const ARRANGE: &str = "dashboard.toolbar.arrange";
    pub const CLEAR_FILTERS: &str = "dashboard.toolbar.clear_filters";
    pub const SELECT_MODE: &str = "dashboard.toolbar.select_mode";
}

/// The five status filters, in the order the chip row renders them.
/// RFC-073 D5 removed the sixth, `Conflict` ("Needs a choice") — every
/// project needing a resolution choice already needs help, and its row
/// still says why (`DashboardCause::Conflict`'s own cause text).
const FILTERS: [StatusFilter; 5] = [
    StatusFilter::NeedsHelp,
    StatusFilter::Dirty,
    StatusFilter::Behind,
    StatusFilter::Ahead,
    StatusFilter::AllSet,
];

fn filter_focus_key(filter: &StatusFilter) -> &'static str {
    match filter {
        StatusFilter::NeedsHelp => focus_target::FILTER_NEEDS_HELP,
        StatusFilter::Dirty => focus_target::FILTER_DIRTY,
        StatusFilter::Behind => focus_target::FILTER_BEHIND,
        StatusFilter::Ahead => focus_target::FILTER_AHEAD,
        StatusFilter::AllSet => focus_target::FILTER_ALL_SET,
    }
}

/// Whether the toolbar control keyed `key` currently draws the RFC-036
/// focus ring — plain equality against `state.dashboard_focus`, same
/// pattern as `shell.rs`'s/`workspace_manager.rs`'s own `is_focused`.
fn is_focused(state: &AppState, key: &'static str) -> bool {
    state.dashboard_focus.as_ref() == Some(&FocusTarget::control(key))
}

/// A single filter chip, built once and shared between the standard chip
/// row and the compact composition's visible/overflow chip groups — same
/// discipline as `row.rs`'s shared `selection_checkbox`/`name_button`.
fn chip_element<'a>(
    state: &'a AppState,
    tokens: &Tokens,
    filter: &StatusFilter,
) -> Element<'a, Message> {
    let active = state.filter.has_status_filter(filter);
    let (tone, glyph) = badge_for_filter(filter);
    let count = state.status_filter_count(filter);
    chip::filter(
        tokens,
        state.t(filter.label_key()),
        (tone, &glyph),
        count,
        active,
        is_focused(state, filter_focus_key(filter)),
        Some(Message::Filter(FilterMessage::StatusFilterToggled(
            filter.clone(),
        ))),
    )
}

/// RFC-035 R15/Handoff 030 §4.1: the Select control's disabled reason must
/// be true to its actual cause — `AppState::visible_projects_unavailable_reason`
/// (shared with the command palette's own equivalent check, so the two
/// cannot pick different wording for the same cause) distinguishes nothing
/// registered, every match sitting in a closed group (RFC-073 D16 W3), and
/// the filter itself matching nothing.
fn select_mode_reason(state: &AppState, summary: &SelectionSummary) -> Option<&'static str> {
    if !summary.visible_ids.is_empty() {
        return None;
    }
    state.visible_projects_unavailable_reason()
}

pub(super) fn focus_order(state: &AppState, mode: WidthMode) -> FocusOrder<Message> {
    match mode {
        WidthMode::Compact => compact_focus_order(state),
        WidthMode::Standard | WidthMode::Wide => standard_focus_order(state),
    }
}

/// The toolbar's Tab/Shift-Tab focus targets (RFC-036 R2), in visual order:
/// the five filter chips, Arrange, search, Clear filters (when rendered),
/// then the bulk-selection entry point — **before** `dashboard::focus_order`
/// appends its section/row targets (RFC-035 Handoff 022 §7.4). Without
/// this, `chip::filter`'s `is_focused` has nothing to ever be `true`, and
/// its ring is dead code.
///
/// **Clear filters is guarded on the same condition that renders it**
/// (`state.filter.is_active()`, matching `view_toolbar`'s own condition
/// exactly) — same shape as `dashboard/mod.rs`'s row-checkbox target being
/// guarded on `state.selection_mode`. An unconditional target here would
/// be a focus black hole: Tab would stop on a control that is not on
/// screen (Handoff 023 §5).
///
/// RFC-073 D2: Arrange carries `Some(ArrangeToggled)` — unlike the two
/// selects it replaces, it is a real button with a real activation message,
/// so this is a genuine keyboard-operability gain, not just a rename. The
/// grouping/sorting selects themselves keep no `FocusTarget` of their own
/// any more (see `arrange_panel`'s own doc comment for why that loses
/// nothing a plain Tab stop on them ever bought).
fn standard_focus_order(state: &AppState) -> FocusOrder<Message> {
    let mut order: FocusOrder<Message> = FILTERS
        .iter()
        .map(|filter| {
            (
                FocusTarget::control(filter_focus_key(filter)),
                Some(Message::Filter(FilterMessage::StatusFilterToggled(
                    filter.clone(),
                ))),
            )
        })
        .collect();

    order.push((
        FocusTarget::control(focus_target::ARRANGE),
        Some(Message::Dashboard(DashboardMessage::ArrangeToggled)),
    ));
    order.push((
        FocusTarget::text_input(knotra_ui::widget::focus_id::SEARCH.clone()),
        None,
    ));

    if state.filter.is_active() {
        order.push((
            FocusTarget::control(focus_target::CLEAR_FILTERS),
            Some(Message::Filter(FilterMessage::AllFiltersCleared)),
        ));
    }

    let summary = state.selection_summary();
    let select_message = (!summary.visible_ids.is_empty())
        .then_some(Message::Selection(SelectionMessage::ModeEntered));
    order.push((
        FocusTarget::control(focus_target::SELECT_MODE),
        select_message,
    ));

    order
}

/// Compact's order (RFC-035 R8, Handoff 028 §5; RFC-073 Amendment A6 §1):
/// all five chips now — the three-visible/overflow split and its own
/// `TOOLBAR_OVERFLOW` target are gone along with the "⋯" control itself.
/// Search, then Arrange (sharing `standard_focus_order`'s single `ARRANGE`
/// target and `ArrangeToggled` message — the same control, not a
/// compact-only pair, since `view_compact_toolbar` now calls
/// [`arrange_button`] directly). Clear filters and the bulk-selection
/// entry point keep the same guards `standard_focus_order` uses.
fn compact_focus_order(state: &AppState) -> FocusOrder<Message> {
    let mut order: FocusOrder<Message> = FILTERS
        .iter()
        .map(|filter| {
            (
                FocusTarget::control(filter_focus_key(filter)),
                Some(Message::Filter(FilterMessage::StatusFilterToggled(
                    filter.clone(),
                ))),
            )
        })
        .collect();

    order.push((
        FocusTarget::text_input(knotra_ui::widget::focus_id::SEARCH.clone()),
        None,
    ));

    order.push((
        FocusTarget::control(focus_target::ARRANGE),
        Some(Message::Dashboard(DashboardMessage::ArrangeToggled)),
    ));

    if state.filter.is_active() {
        order.push((
            FocusTarget::control(focus_target::CLEAR_FILTERS),
            Some(Message::Filter(FilterMessage::AllFiltersCleared)),
        ));
    }

    let summary = state.selection_summary();
    let select_message = (!summary.visible_ids.is_empty())
        .then_some(Message::Selection(SelectionMessage::ModeEntered));
    order.push((
        FocusTarget::control(focus_target::SELECT_MODE),
        select_message,
    ));

    order
}

pub(super) fn view_toolbar(state: &AppState, mode: WidthMode) -> Element<'_, Message> {
    match mode {
        WidthMode::Compact => view_compact_toolbar(state),
        WidthMode::Standard | WidthMode::Wide => view_standard_toolbar(state),
    }
}

fn view_standard_toolbar(state: &AppState) -> Element<'_, Message> {
    let tokens = &state.theme.tokens;

    // RFC-071 Amendment A6 §1: the chip row wraps onto a second line when
    // it does not fit, rather than letting a chip's own label wrap inside
    // it (`chip::filter`'s `Wrapping::None` is the other half of this).
    let chips = row(FILTERS
        .iter()
        .map(|filter| chip_element(state, tokens, filter))
        .collect::<Vec<_>>())
    .spacing(4)
    .wrap()
    .vertical_spacing(4);

    // RFC-073 D2: Group and Sort move into one "Arrange" control.
    let arrange = arrange_button(state, tokens);

    // RFC-073 handoff Amendment A3 §2: `BUTTON_HEIGHT` through the shared
    // builder — this was the field the capture caught sitting short beside
    // 44px controls.
    let search = knotra_ui::widget::styled_text_input(
        tokens,
        state.t("dashboard.search_placeholder"),
        &state.filter.search_text,
    )
    .id(knotra_ui::widget::focus_id::SEARCH.clone())
    .on_input(|value| Message::Filter(FilterMessage::SearchChanged(value)))
    .width(Length::Fixed(220.0));

    let clear: Element<'_, Message> = if state.filter.is_active() {
        clear_filters_button(
            tokens,
            state.t("dashboard.clear_filters"),
            is_focused(state, focus_target::CLEAR_FILTERS),
        )
    } else {
        Space::new().width(Length::Shrink).into()
    };

    let summary = state.selection_summary();
    let select_message = (!summary.visible_ids.is_empty())
        .then_some(Message::Selection(SelectionMessage::ModeEntered));
    let select = select_mode_button(
        tokens,
        state.t("plain.selection.enter"),
        select_message,
        select_mode_reason(state, &summary),
        is_focused(state, focus_target::SELECT_MODE),
    );

    // RFC-073 Amendment A2: aligned to the top (`Start`, not `Center`), so
    // "Select"'s own reason line (rendered beneath it when disabled) grows
    // the row's height without dropping "Arrange" and Search out of line
    // with "Select"'s own top edge.
    let mut controls = column![
        row![arrange, search, clear, select]
            .spacing(6)
            .align_y(Alignment::Start)
    ]
    .spacing(5);

    if state.dashboard_arrange_open {
        controls = controls.push(arrange_panel(state, tokens));
    }

    container(column![chips, controls].spacing(5))
        .width(Length::Fill)
        .padding(Padding {
            top: 0.0,
            right: 12.0,
            bottom: 8.0,
            left: 12.0,
        })
        .into()
}

/// RFC-073 D2: the single control, beside Search, that opens
/// [`arrange_panel`] — replacing the two always-visible selects
/// `view_standard_toolbar` drew directly before this change.
/// `with_focus_ring`/`ghost` styled, with a text label (`dashboard.arrange`)
/// rather than a bare glyph. RFC-073 Amendment A6 §1: now also
/// `view_compact_toolbar`'s own Arrange control, verbatim — Compact no
/// longer builds a bare-glyph disclosure trigger of its own.
fn arrange_button<'a>(state: &'a AppState, tokens: &Tokens) -> Element<'a, Message> {
    let t = tokens.clone();
    let focused = is_focused(state, focus_target::ARRANGE);
    // RFC-073 Amendment A1: a chevron follows the label, the same icon
    // helper and size as the workspace switcher's own disclosure cue
    // (`shell.rs`'s `switcher_trigger`) — down while closed, up while
    // open, so "Arrange" shows that it opens something before it is ever
    // pressed.
    let chevron = if state.dashboard_arrange_open {
        icon::chevron_up()
    } else {
        icon::chevron_down()
    };
    // RFC-073 Amendment A2: `centered_button_row` is `centered_button_label`
    // for a `Row` — an icon+text row can't go through the `Text`-only
    // helper, so this centres the row itself, the same way
    // `header_control` does. The button's own fixed height is spelled
    // `Length::Fixed(BUTTON_HEIGHT)`; `button_label_guard` now treats that
    // the same as the bare constant it always scanned for.
    button(centered_button_row(
        row![
            text(state.t("dashboard.arrange"))
                .size(snora::design::style::text::body_size(tokens))
                .line_height(snora::design::style::text::body_line_height(tokens)),
            icon::icon_element(&chevron),
        ]
        .spacing(6),
    ))
    .height(Length::Fixed(BUTTON_HEIGHT))
    .padding([0, 18])
    .on_press(Message::Dashboard(DashboardMessage::ArrangeToggled))
    .style(move |_theme, status| style::with_focus_ring(&t, focused, style::ghost(&t, status)))
    .into()
}

/// The grouping/sorting selects, revealed beneath [`arrange_button`] (or
/// beside compact's own `▾` trigger) while `state.dashboard_arrange_open`.
/// RFC-073 D2 unified what Handoff 028 had kept as two separate
/// constructions (standard's always-visible row and compact's
/// `compact_selectors_row`) — the panel's content and behaviour are
/// identical in both bands now, so one function serves both.
///
/// Neither select carries a `FocusTarget` of its own: Tab now stops once,
/// on `arrange_button`/its compact equivalent (D2's own focus-order
/// change), and opening either select's own menu was already a
/// pointer-only interaction before this change — the `is_focused: false`
/// here is an explicit, honest "unwired", not a regression from a working
/// ring to a dead one.
fn arrange_panel<'a>(state: &'a AppState, tokens: &Tokens) -> Element<'a, Message> {
    let grouping_options = vec![
        (
            DashboardGrouping::Attention,
            state.t("dashboard.grouping.attention").to_owned(),
        ),
        (
            DashboardGrouping::ProjectGroup,
            state.t("dashboard.grouping.project_group").to_owned(),
        ),
        (
            DashboardGrouping::None,
            state.t("dashboard.grouping.none").to_owned(),
        ),
    ];
    // RFC-071 Amendment A3 D14: a field label — `body`.
    let grouping = row![
        text(state.t("dashboard.grouping"))
            .size(snora::design::style::text::body_size(tokens))
            .line_height(snora::design::style::text::body_line_height(tokens)),
        select::styled_pick_list(
            tokens,
            grouping_options,
            Some(state.config.dashboard_grouping),
            false,
            |value| Message::Dashboard(DashboardMessage::GroupingChanged(value)),
        ),
    ]
    .spacing(4)
    .align_y(Alignment::Center);

    let sorting_options = vec![
        (
            DashboardSort::Recommended,
            state.t("dashboard.sorting.recommended").to_owned(),
        ),
        (
            DashboardSort::NameAscending,
            state.t("dashboard.sorting.name").to_owned(),
        ),
    ];
    // RFC-071 Amendment A3 D14: a field label — `body`.
    let sorting = row![
        text(state.t("dashboard.sorting"))
            .size(snora::design::style::text::body_size(tokens))
            .line_height(snora::design::style::text::body_line_height(tokens)),
        select::styled_pick_list(
            tokens,
            sorting_options,
            Some(state.config.dashboard_sort),
            false,
            |value| Message::Dashboard(DashboardMessage::SortChanged(value)),
        ),
    ]
    .spacing(4)
    .align_y(Alignment::Center);

    row![grouping, sorting]
        .spacing(6)
        .align_y(Alignment::Center)
        .into()
}

/// Compact (RFC-035 R8, Handoff 028 §4; RFC-073 Amendment A6 §1). Since
/// Task 110 the chip row wraps onto a second line rather than clamping or
/// running off-screen, so the reason Handoff 028 hid two chips behind a
/// `⋯` overflow (and Group/Sort behind a bare `▾`) is gone: Compact now
/// shows every status filter directly, in the same wrapping row Standard
/// uses, and reuses [`arrange_button`] byte-for-byte rather than a
/// glyph-only disclosure trigger of its own.
fn view_compact_toolbar(state: &AppState) -> Element<'_, Message> {
    let tokens = &state.theme.tokens;

    // Task 110 §1: wraps onto a second line rather than clamping — the
    // same `.wrap()` `view_standard_toolbar`'s own five-chip row uses.
    let chips = row(FILTERS
        .iter()
        .map(|filter| chip_element(state, tokens, filter))
        .collect::<Vec<_>>())
    .spacing(4)
    .wrap()
    .vertical_spacing(4);

    // RFC-073 handoff Amendment A3 §2: same shared builder as the standard
    // band's search field above.
    let search = knotra_ui::widget::styled_text_input(
        tokens,
        state.t("dashboard.search_placeholder"),
        &state.filter.search_text,
    )
    .id(knotra_ui::widget::focus_id::SEARCH.clone())
    .on_input(|value| Message::Filter(FilterMessage::SearchChanged(value)))
    .width(Length::Fixed(220.0));

    let arrange = arrange_button(state, tokens);

    let summary = state.selection_summary();
    let select_message = (!summary.visible_ids.is_empty())
        .then_some(Message::Selection(SelectionMessage::ModeEntered));
    let select = select_mode_button(
        tokens,
        state.t("plain.selection.enter"),
        select_message,
        select_mode_reason(state, &summary),
        is_focused(state, focus_target::SELECT_MODE),
    );

    // RFC-073 Amendment A2: top-aligned, same reason as the standard band.
    let mut controls = column![
        row![search, arrange, select]
            .spacing(6)
            .align_y(Alignment::Start)
    ]
    .spacing(5);

    if state.dashboard_arrange_open {
        controls = controls.push(arrange_panel(state, tokens));
    }

    if state.filter.is_active() {
        controls = controls.push(clear_filters_button(
            tokens,
            state.t("dashboard.clear_filters"),
            is_focused(state, focus_target::CLEAR_FILTERS),
        ));
    }

    container(column![chips, controls].spacing(5))
        .width(Length::Fill)
        .padding(Padding {
            top: 0.0,
            right: 12.0,
            bottom: 8.0,
            left: 12.0,
        })
        .into()
}

/// The bulk-selection entry point, token-styled with a working focus ring
/// (RFC-036 R2/D7) — `guided_button` cannot carry `is_focused` (RFC-034 R7
/// keeps it stable for rows until Stage 3), so this reproduces its
/// disabled-reason-text composition on top of a real `secondary` button
/// style instead, via `style::with_focus_ring` directly (the same pattern
/// `workspace_manager.rs`'s dialog buttons use), so the control this
/// handoff explicitly adds to `focus_order` (§7.4) actually renders a
/// ring rather than becoming a second instance of the gap `chip` had
/// before Handoff 020.
fn select_mode_button<'a>(
    tokens: &Tokens,
    label: &'a str,
    on_press: Option<Message>,
    reason: Option<&'a str>,
    is_focused: bool,
) -> Element<'a, Message> {
    let t = tokens.clone();
    let show_reason = on_press.is_none();

    let btn = button(centered_button_label(
        text(label)
            .size(snora::design::style::text::body_size(tokens))
            .line_height(snora::design::style::text::body_line_height(tokens)),
    ))
    .height(BUTTON_HEIGHT)
    .padding([0, 18])
    .on_press_maybe(on_press)
    .style(move |_theme, status| {
        style::with_focus_ring(&t, is_focused, style::secondary(&t, status))
    });

    match reason {
        // RFC-071 Amendment A3 D14: a reason — `body`.
        Some(r) if show_reason => column![
            btn,
            text(r)
                .size(snora::design::style::text::body_size(tokens))
                .line_height(snora::design::style::text::body_line_height(tokens))
        ]
        .spacing(6)
        .into(),
        _ => btn.into(),
    }
}

/// Clear filters, token-styled with a working focus ring — the same
/// `style::secondary` + `with_focus_ring` treatment as
/// [`select_mode_button`] (Handoff 023 §6), since this control gained a
/// real `focus_order` entry and would otherwise be reachable and operable
/// but invisible.
fn clear_filters_button<'a>(
    tokens: &Tokens,
    label: &'a str,
    is_focused: bool,
) -> Element<'a, Message> {
    let t = tokens.clone();
    // RFC-071 Amendment A3 D14: a button label — `body`.
    // RFC-073 D8: `BUTTON_HEIGHT`, matching Arrange/Search/Select in the
    // same controls row.
    button(centered_button_label(
        text(label)
            .size(snora::design::style::text::body_size(tokens))
            .line_height(snora::design::style::text::body_line_height(tokens)),
    ))
    .height(BUTTON_HEIGHT)
    .padding([0, 12])
    .on_press(Message::Filter(FilterMessage::AllFiltersCleared))
    .style(move |_theme, status| {
        style::with_focus_ring(&t, is_focused, style::secondary(&t, status))
    })
    .into()
}