rch 2.1.15

Remote Compilation Helper - PreToolUse hook CLI
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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
//! Progress indicators for long-running CLI operations.
//!
//! Provides spinners, progress bars, step indicators, and multi-progress
//! managers using the indicatif crate. All progress types are aware of
//! output mode and gracefully degrade in non-TTY, JSON, or quiet modes.
//!
//! # Usage
//!
//! ```rust,ignore
//! use rch::ui::progress::{Spinner, TransferProgress, MultiProgressManager};
//! use rch::ui::OutputContext;
//!
//! // Spinner for unknown-duration operations
//! let spinner = Spinner::new(&ctx, "Connecting...");
//! // ... do work ...
//! spinner.finish_success("Connected");
//!
//! // Progress bar for known-size transfers
//! let bar = TransferProgress::new(&ctx, total_bytes, "Syncing");
//! bar.set_position(bytes_transferred);
//! bar.finish();
//! ```

use super::context::{OutputContext, OutputMode};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use std::time::Duration;

/// The tick rate for spinner animations (80ms = 12.5 fps).
const SPINNER_TICK_RATE: Duration = Duration::from_millis(80);

/// Braille dot spinner characters for smooth animation.
const SPINNER_CHARS: &[&str] = &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];

/// ASCII fallback spinner for non-unicode terminals.
const SPINNER_CHARS_ASCII: &[&str] = &["|", "/", "-", "\\"];

/// Progress bar characters for filled display.
const PROGRESS_CHARS: &str = "█▓░";

/// ASCII fallback progress bar characters.
const PROGRESS_CHARS_ASCII: &str = "#-·";

/// Check if progress should be displayed based on output context.
///
/// Returns false if:
/// - JSON mode is active
/// - Quiet mode is active
/// - stderr is not a TTY (piped output)
fn should_show_progress(ctx: &OutputContext) -> bool {
    !ctx.is_json() && !ctx.is_quiet() && ctx.mode() == OutputMode::Human
}

/// Get the appropriate spinner characters for the terminal.
fn spinner_chars(ctx: &OutputContext) -> &'static [&'static str] {
    if ctx.theme().supports_unicode() {
        SPINNER_CHARS
    } else {
        SPINNER_CHARS_ASCII
    }
}

/// Get the appropriate progress bar characters for the terminal.
fn progress_chars(ctx: &OutputContext) -> &'static str {
    if ctx.theme().supports_unicode() {
        PROGRESS_CHARS
    } else {
        PROGRESS_CHARS_ASCII
    }
}

/// A spinner for unknown-duration operations.
///
/// Displays an animated spinner with a message. Automatically hides
/// in non-TTY, JSON, or quiet modes.
///
/// # Example
///
/// ```rust,ignore
/// let spinner = Spinner::new(&ctx, "Connecting to worker...");
/// do_connection().await;
/// spinner.finish_success("Connected");
/// ```
pub struct Spinner {
    inner: ProgressBar,
    _visible: bool,
}

impl Spinner {
    /// Create a new spinner with the given message.
    ///
    /// The spinner is hidden in JSON/quiet modes or when output is piped.
    pub fn new(ctx: &OutputContext, message: &str) -> Self {
        let visible = should_show_progress(ctx);

        let inner = if visible {
            let pb = ProgressBar::new_spinner();
            let chars = spinner_chars(ctx);
            pb.set_style(
                ProgressStyle::default_spinner()
                    .tick_strings(chars)
                    .template("{spinner:.cyan} {msg}")
                    .expect("valid template"),
            );
            pb.set_message(message.to_string());
            pb.enable_steady_tick(SPINNER_TICK_RATE);
            pb
        } else {
            ProgressBar::hidden()
        };

        Self {
            inner,
            _visible: visible,
        }
    }

    /// Update the spinner message.
    pub fn set_message(&self, msg: &str) {
        self.inner.set_message(msg.to_string());
    }

    /// Finish the spinner with a success message.
    pub fn finish_success(&self, msg: &str) {
        self.inner.finish_with_message(format!("✓ {}", msg));
    }

    /// Finish the spinner with an error message.
    pub fn finish_error(&self, msg: &str) {
        self.inner.finish_with_message(format!("✗ {}", msg));
    }

    /// Finish the spinner with a warning message.
    pub fn finish_warning(&self, msg: &str) {
        self.inner.finish_with_message(format!("⚠ {}", msg));
    }

    /// Abandon the spinner (cancel without message change).
    pub fn abandon(&self) {
        self.inner.abandon();
    }

    /// Finish and clear the spinner line.
    pub fn finish_and_clear(&self) {
        self.inner.finish_and_clear();
    }

    /// Get the underlying progress bar for advanced operations.
    pub fn inner(&self) -> &ProgressBar {
        &self.inner
    }
}

/// A progress bar for known-size operations like file transfers.
///
/// Displays: label [█████░░░░░] bytes/total speed ETA
///
/// # Example
///
/// ```rust,ignore
/// let bar = TransferProgress::new(&ctx, total_bytes, "Syncing");
/// for chunk in chunks {
///     transfer_chunk(chunk)?;
///     bar.set_position(bytes_so_far);
/// }
/// bar.finish();
/// ```
pub struct TransferProgress {
    inner: ProgressBar,
}

impl TransferProgress {
    /// Create a new progress bar for a transfer operation.
    pub fn new(ctx: &OutputContext, total: u64, label: &str) -> Self {
        let visible = should_show_progress(ctx);

        let inner = if visible {
            let pb = ProgressBar::new(total);
            let chars = progress_chars(ctx);
            pb.set_style(
                ProgressStyle::default_bar()
                    .template("{msg:12} [{bar:40.cyan/blue}] {bytes}/{total_bytes} {bytes_per_sec} ETA {eta}")
                    .expect("valid template")
                    .progress_chars(chars),
            );
            pb.set_message(label.to_string());
            pb
        } else {
            ProgressBar::hidden()
        };

        Self { inner }
    }

    /// Create a progress bar for item count (not bytes).
    pub fn new_items(ctx: &OutputContext, total: u64, label: &str) -> Self {
        let visible = should_show_progress(ctx);

        let inner = if visible {
            let pb = ProgressBar::new(total);
            let chars = progress_chars(ctx);
            pb.set_style(
                ProgressStyle::default_bar()
                    .template("{msg:12} [{bar:40.cyan/blue}] {pos}/{len} ({percent}%)")
                    .expect("valid template")
                    .progress_chars(chars),
            );
            pb.set_message(label.to_string());
            pb
        } else {
            ProgressBar::hidden()
        };

        Self { inner }
    }

    /// Set the current position.
    pub fn set_position(&self, pos: u64) {
        self.inner.set_position(pos);
    }

    /// Increment the position by the given amount.
    pub fn inc(&self, delta: u64) {
        self.inner.inc(delta);
    }

    /// Set the message/label.
    pub fn set_message(&self, msg: &str) {
        self.inner.set_message(msg.to_string());
    }

    /// Finish the progress bar.
    pub fn finish(&self) {
        self.inner.finish();
    }

    /// Finish and clear the progress bar line.
    pub fn finish_and_clear(&self) {
        self.inner.finish_and_clear();
    }

    /// Get the underlying progress bar.
    pub fn inner(&self) -> &ProgressBar {
        &self.inner
    }
}

/// Step progress indicator for multi-phase operations.
///
/// Displays:
/// ```text
/// [1/3] ✓ Synced files (2.3s)
/// [2/3] ◐ Compiling...
/// [3/3] ○ Retrieve artifacts
/// ```
#[derive(Clone)]
pub struct StepProgress {
    steps: Vec<StepState>,
    current: usize,
    ctx_mode: OutputMode,
    ctx_unicode: bool,
}

#[derive(Clone)]
struct StepState {
    name: String,
    status: StepStatus,
    message: Option<String>,
}

#[derive(Clone, Copy, PartialEq, Eq)]
enum StepStatus {
    Pending,
    InProgress,
    Complete,
    Failed,
    Skipped,
}

impl StepProgress {
    /// Create a new step progress indicator.
    pub fn new(ctx: &OutputContext, step_names: &[&str]) -> Self {
        let steps = step_names
            .iter()
            .map(|name| StepState {
                name: name.to_string(),
                status: StepStatus::Pending,
                message: None,
            })
            .collect();

        Self {
            steps,
            current: 0,
            ctx_mode: ctx.mode(),
            ctx_unicode: ctx.theme().supports_unicode(),
        }
    }

    /// Start a step (mark as in-progress).
    pub fn start_step(&mut self, idx: usize) {
        if idx < self.steps.len() {
            self.steps[idx].status = StepStatus::InProgress;
            self.current = idx;
            self.print_current();
        }
    }

    /// Complete a step with an optional message.
    pub fn complete_step(&mut self, idx: usize, message: Option<&str>) {
        if idx < self.steps.len() {
            self.steps[idx].status = StepStatus::Complete;
            self.steps[idx].message = message.map(|s| s.to_string());
            self.print_current();
        }
    }

    /// Fail a step with an optional message.
    pub fn fail_step(&mut self, idx: usize, message: Option<&str>) {
        if idx < self.steps.len() {
            self.steps[idx].status = StepStatus::Failed;
            self.steps[idx].message = message.map(|s| s.to_string());
            self.print_current();
        }
    }

    /// Skip a step.
    pub fn skip_step(&mut self, idx: usize) {
        if idx < self.steps.len() {
            self.steps[idx].status = StepStatus::Skipped;
            self.print_current();
        }
    }

    fn print_current(&self) {
        if self.ctx_mode == OutputMode::Json || self.ctx_mode == OutputMode::Quiet {
            return;
        }

        let total = self.steps.len();
        for (i, step) in self.steps.iter().enumerate() {
            let symbol = self.status_symbol(step.status);
            let num = format!("[{}/{}]", i + 1, total);
            let msg = step
                .message
                .as_ref()
                .map(|m| format!(" ({})", m))
                .unwrap_or_default();
            eprintln!("{} {} {}{}", num, symbol, step.name, msg);
        }
    }

    fn status_symbol(&self, status: StepStatus) -> &'static str {
        if self.ctx_unicode {
            match status {
                StepStatus::Pending => "○",
                StepStatus::InProgress => "◐",
                StepStatus::Complete => "✓",
                StepStatus::Failed => "✗",
                StepStatus::Skipped => "⊘",
            }
        } else {
            match status {
                StepStatus::Pending => "[ ]",
                StepStatus::InProgress => "[~]",
                StepStatus::Complete => "[x]",
                StepStatus::Failed => "[!]",
                StepStatus::Skipped => "[-]",
            }
        }
    }
}

/// Multi-progress manager for parallel operations.
///
/// Manages multiple spinners or progress bars that update simultaneously.
///
/// # Example
///
/// ```rust,ignore
/// let manager = MultiProgressManager::new(&ctx);
/// let spinner1 = manager.add_spinner("worker-1", "Connecting...");
/// let spinner2 = manager.add_spinner("worker-2", "Connecting...");
///
/// // Update independently
/// spinner1.finish_success("OK (45ms)");
/// spinner2.finish_error("Connection refused");
/// ```
pub struct MultiProgressManager {
    multi: MultiProgress,
    visible: bool,
    ctx_unicode: bool,
}

impl MultiProgressManager {
    /// Create a new multi-progress manager.
    pub fn new(ctx: &OutputContext) -> Self {
        let visible = should_show_progress(ctx);

        let multi = if visible {
            MultiProgress::new()
        } else {
            MultiProgress::with_draw_target(ProgressDrawTarget::hidden())
        };

        Self {
            multi,
            visible,
            ctx_unicode: ctx.theme().supports_unicode(),
        }
    }

    /// Add a spinner to the multi-progress display.
    pub fn add_spinner(&self, prefix: &str, message: &str) -> ProgressBar {
        let pb = self.multi.add(ProgressBar::new_spinner());

        if self.visible {
            let chars = if self.ctx_unicode {
                SPINNER_CHARS
            } else {
                SPINNER_CHARS_ASCII
            };

            #[allow(clippy::literal_string_with_formatting_args)]
            let template = "{prefix:12} {spinner:.cyan} {msg}";
            pb.set_style(
                ProgressStyle::default_spinner()
                    .tick_strings(chars)
                    .template(template)
                    .expect("valid template"),
            );
            pb.set_prefix(prefix.to_string());
            pb.set_message(message.to_string());
            pb.enable_steady_tick(SPINNER_TICK_RATE);
        }

        pb
    }

    /// Add a progress bar to the multi-progress display.
    pub fn add_progress_bar(&self, total: u64, prefix: &str) -> ProgressBar {
        let pb = self.multi.add(ProgressBar::new(total));

        if self.visible {
            let chars = if self.ctx_unicode {
                PROGRESS_CHARS
            } else {
                PROGRESS_CHARS_ASCII
            };

            pb.set_style(
                ProgressStyle::default_bar()
                    .template("{prefix:12} [{bar:30.cyan/blue}] {percent:3}%")
                    .expect("valid template")
                    .progress_chars(chars),
            );
            pb.set_prefix(prefix.to_string());
        }

        pb
    }

    /// Suspend the multi-progress display temporarily.
    ///
    /// Use this when streaming output that would conflict with progress.
    pub fn suspend<F, T>(&self, f: F) -> T
    where
        F: FnOnce() -> T,
    {
        self.multi.suspend(f)
    }

    /// Hide the draw target temporarily.
    pub fn hide(&self) {
        self.multi.set_draw_target(ProgressDrawTarget::hidden());
    }

    /// Show the draw target (restore to stderr).
    pub fn show(&self) {
        if self.visible {
            self.multi.set_draw_target(ProgressDrawTarget::stderr());
        }
    }

    /// Clear all progress bars.
    pub fn clear(&self) {
        self.multi.clear().ok();
    }

    /// Check if progress is visible.
    pub fn is_visible(&self) -> bool {
        self.visible
    }
}

/// Execute an async operation with a spinner.
///
/// The spinner shows while the operation is in progress, then finishes
/// with success or error based on the result.
///
/// # Example
///
/// ```rust,ignore
/// let result = with_spinner(&ctx, "Connecting...", async {
///     connect_to_worker().await
/// }).await;
/// ```
pub async fn with_spinner<F, T>(ctx: &OutputContext, message: &str, future: F) -> T
where
    F: std::future::Future<Output = T>,
{
    let spinner = Spinner::new(ctx, message);
    let result = future.await;
    spinner.finish_and_clear();
    result
}

/// Execute an async operation with a spinner, showing success/error on completion.
pub async fn with_spinner_result<F, T, E>(
    ctx: &OutputContext,
    message: &str,
    success_msg: &str,
    future: F,
) -> Result<T, E>
where
    F: std::future::Future<Output = Result<T, E>>,
    E: std::fmt::Display,
{
    let spinner = Spinner::new(ctx, message);
    let result = future.await;

    match &result {
        Ok(_) => spinner.finish_success(success_msg),
        Err(e) => spinner.finish_error(&e.to_string()),
    }

    result
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::ui::{OutputConfig, OutputContext};
    use tracing::info;

    fn log_test_start(name: &str) {
        info!("TEST START: {}", name);
    }

    fn make_plain_context() -> OutputContext {
        OutputContext::new(OutputConfig {
            color: super::super::context::ColorChoice::Never,
            ..Default::default()
        })
    }

    fn make_quiet_context() -> OutputContext {
        OutputContext::new(OutputConfig {
            quiet: true,
            ..Default::default()
        })
    }

    fn make_json_context() -> OutputContext {
        OutputContext::new(OutputConfig {
            json: true,
            ..Default::default()
        })
    }

    #[test]
    fn test_spinner_lifecycle() {
        log_test_start("test_spinner_lifecycle");
        let ctx = make_plain_context();
        let spinner = Spinner::new(&ctx, "Testing...");
        spinner.set_message("Still testing...");
        spinner.finish_success("Done");
        // Hidden spinner should not panic
    }

    #[test]
    fn test_spinner_in_quiet_mode() {
        log_test_start("test_spinner_in_quiet_mode");
        let ctx = make_quiet_context();
        let spinner = Spinner::new(&ctx, "Testing...");
        spinner.finish_success("Done");
        // Should use hidden progress bar
    }

    #[test]
    fn test_spinner_in_json_mode() {
        log_test_start("test_spinner_in_json_mode");
        let ctx = make_json_context();
        let spinner = Spinner::new(&ctx, "Testing...");
        spinner.finish_error("Failed");
        // Should use hidden progress bar
    }

    #[test]
    fn test_spinner_error_finish() {
        log_test_start("test_spinner_error_finish");
        let ctx = make_plain_context();
        let spinner = Spinner::new(&ctx, "Working...");
        spinner.finish_error("Connection failed");
    }

    #[test]
    fn test_spinner_warning_finish() {
        log_test_start("test_spinner_warning_finish");
        let ctx = make_plain_context();
        let spinner = Spinner::new(&ctx, "Working...");
        spinner.finish_warning("Partial success");
    }

    #[test]
    fn test_spinner_abandon() {
        log_test_start("test_spinner_abandon");
        let ctx = make_plain_context();
        let spinner = Spinner::new(&ctx, "Working...");
        spinner.abandon();
    }

    #[test]
    fn test_transfer_progress_lifecycle() {
        log_test_start("test_transfer_progress_lifecycle");
        let ctx = make_plain_context();
        let bar = TransferProgress::new(&ctx, 100, "Syncing");
        bar.set_position(50);
        bar.inc(25);
        bar.finish();
    }

    #[test]
    fn test_transfer_progress_items() {
        log_test_start("test_transfer_progress_items");
        let ctx = make_plain_context();
        let bar = TransferProgress::new_items(&ctx, 10, "Items");
        bar.set_position(5);
        bar.finish_and_clear();
    }

    #[test]
    fn test_transfer_progress_quiet() {
        log_test_start("test_transfer_progress_quiet");
        let ctx = make_quiet_context();
        let bar = TransferProgress::new(&ctx, 100, "test");
        bar.set_position(50);
        bar.finish();
        // Should use hidden bar
    }

    #[test]
    fn test_step_progress_lifecycle() {
        log_test_start("test_step_progress_lifecycle");
        let ctx = make_plain_context();
        let mut steps = StepProgress::new(&ctx, &["Sync", "Compile", "Retrieve"]);
        steps.start_step(0);
        steps.complete_step(0, Some("2.3s"));
        steps.start_step(1);
        steps.complete_step(1, None);
        steps.start_step(2);
        steps.complete_step(2, Some("45ms"));
    }

    #[test]
    fn test_step_progress_failure() {
        log_test_start("test_step_progress_failure");
        let ctx = make_plain_context();
        let mut steps = StepProgress::new(&ctx, &["Sync", "Compile"]);
        steps.start_step(0);
        steps.fail_step(0, Some("Connection refused"));
    }

    #[test]
    fn test_step_progress_skip() {
        log_test_start("test_step_progress_skip");
        let ctx = make_plain_context();
        let mut steps = StepProgress::new(&ctx, &["Sync", "Compile"]);
        steps.skip_step(0);
    }

    #[test]
    fn test_multi_progress_manager() {
        log_test_start("test_multi_progress_manager");
        let ctx = make_plain_context();
        let manager = MultiProgressManager::new(&ctx);
        let pb1 = manager.add_spinner("worker-1", "Connecting...");
        let pb2 = manager.add_spinner("worker-2", "Connecting...");
        pb1.finish_with_message("OK");
        pb2.finish_with_message("OK");
    }

    #[test]
    fn test_multi_progress_suspend() {
        log_test_start("test_multi_progress_suspend");
        let ctx = make_plain_context();
        let manager = MultiProgressManager::new(&ctx);
        let result = manager.suspend(|| {
            // Simulate streaming output
            42
        });
        assert_eq!(result, 42);
    }

    #[test]
    fn test_multi_progress_visibility() {
        log_test_start("test_multi_progress_visibility");
        let ctx = make_quiet_context();
        let manager = MultiProgressManager::new(&ctx);
        assert!(!manager.is_visible());

        let ctx_plain = make_plain_context();
        let manager_plain = MultiProgressManager::new(&ctx_plain);
        // Plain mode is not TTY, so visibility depends on detection
        // This test just ensures no panic
        let _ = manager_plain.is_visible();
    }

    #[test]
    fn test_multi_progress_bar() {
        log_test_start("test_multi_progress_bar");
        let ctx = make_plain_context();
        let manager = MultiProgressManager::new(&ctx);
        let pb = manager.add_progress_bar(100, "Task");
        pb.set_position(50);
        pb.finish();
    }

    #[test]
    fn test_should_show_progress() {
        log_test_start("test_should_show_progress");
        let ctx_quiet = make_quiet_context();
        assert!(!should_show_progress(&ctx_quiet));

        let ctx_json = make_json_context();
        assert!(!should_show_progress(&ctx_json));
    }

    #[test]
    fn test_spinner_chars_selection() {
        log_test_start("test_spinner_chars_selection");
        let ctx = make_plain_context();
        // Plain mode typically doesn't support unicode
        let chars = spinner_chars(&ctx);
        // Just verify it returns something valid
        assert!(!chars.is_empty());
    }

    #[test]
    fn test_progress_chars_selection() {
        log_test_start("test_progress_chars_selection");
        let ctx = make_plain_context();
        let chars = progress_chars(&ctx);
        assert!(!chars.is_empty());
    }
}