prodigy 0.4.4

Turn ad-hoc Claude sessions into reproducible development pipelines with parallel AI agents
Documentation
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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
//! Progress and message display implementation
//!
//! ## Formatting Guidelines
//!
//! This module provides centralized message formatting for consistent CLI output.
//! All display operations should use the semantic message types rather than
//! embedding icons directly in format strings.
//!
//! ### Message Type Usage
//! - `info()`: General information messages
//! - `warning()`: Non-critical issues or cautions
//! - `error()`: Critical errors (always shown, even in quiet mode)
//! - `progress()`: Ongoing operations or status updates
//! - `success()`: Successful completion of operations
//! - `action()`: User-initiated actions or commands
//! - `metric()`: Quantitative data (timings, counts, measurements)
//! - `status()`: State changes or current status
//!
//! ### Icon Management
//! Icons are centrally configured in `IconConfig` and automatically applied
//! based on the message type. Never embed icons directly in message strings.
//!
//! ### Examples
//! ```rust,ignore
//! // Good: Use semantic methods
//! display.metric("Total time", "15.2s");
//! display.progress("Processing items...");
//! display.status("Ready to continue");
//!
//! // Bad: Don't embed icons in strings
//! display.info("📊 Total time: 15.2s");  // Wrong!
//! display.info("🔄 Processing...");      // Wrong!
//! ```

use super::SpinnerHandle;
use std::sync::{Arc, Mutex};
use std::time::Duration;

/// Semantic message types for consistent formatting
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DisplayMessageType {
    Info,
    Warning,
    Error,
    Progress,
    Success,
    Action, // User-initiated actions
    Metric, // Quantitative information
    Status, // State changes
}

/// Centralized icon configuration
#[derive(Clone, Copy)]
pub struct IconConfig {
    info: &'static str,
    warning: &'static str,
    error: &'static str,
    progress: &'static str,
    success: &'static str,
    action: &'static str,
    metric: &'static str,
    status: &'static str,
    debug: &'static str,
}

impl Default for IconConfig {
    fn default() -> Self {
        Self {
            info: "â„šī¸",
            warning: "âš ī¸",
            error: "❌",
            progress: "🔄",
            success: "✅",
            action: "📝",
            metric: "📊",
            status: "📋",
            debug: "🔍",
        }
    }
}

/// Verbosity level for output control
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum VerbosityLevel {
    Quiet = 0,   // Minimal output (errors only)
    Normal = 1,  // Default: progress + results
    Verbose = 2, // -v: command names + exit codes
    Debug = 3,   // -vv: + stdout/stderr
    Trace = 4,   // -vvv: + Claude output + internal details
}

impl VerbosityLevel {
    /// Create from CLI arguments
    pub fn from_args(verbosity_count: u8, quiet: bool) -> Self {
        if quiet {
            VerbosityLevel::Quiet
        } else {
            match verbosity_count {
                0 => VerbosityLevel::Normal,
                1 => VerbosityLevel::Verbose,
                2 => VerbosityLevel::Debug,
                _ => VerbosityLevel::Trace,
            }
        }
    }
}

/// Trait for displaying progress and messages
pub trait ProgressDisplay: Send + Sync {
    /// Display information message
    fn info(&self, message: &str);

    /// Display warning message
    fn warning(&self, message: &str);

    /// Display error message
    fn error(&self, message: &str);

    /// Display progress message
    fn progress(&self, message: &str);

    /// Display success message
    fn success(&self, message: &str);

    /// Display action message (user-initiated actions)
    fn action(&self, message: &str);

    /// Display metric message (quantitative information)
    fn metric(&self, label: &str, value: &str);

    /// Display status message (state changes)
    fn status(&self, message: &str);

    /// Start a spinner
    fn start_spinner(&self, message: &str) -> Box<dyn SpinnerHandle>;

    /// Display iteration start boundary
    fn iteration_start(&self, current: u32, total: u32);

    /// Display iteration end summary
    fn iteration_end(&self, current: u32, duration: Duration, success: bool);

    /// Display step start
    fn step_start(&self, step: u32, total: u32, description: &str);

    /// Display step end
    fn step_end(&self, step: u32, success: bool);

    /// Display command output based on verbosity
    fn command_output(&self, output: &str, verbosity: VerbosityLevel);

    /// Display debug output if verbosity allows
    fn debug_output(&self, message: &str, min_verbosity: VerbosityLevel);

    /// Get current verbosity level
    fn verbosity(&self) -> VerbosityLevel;
}

/// Real implementation of progress display
pub struct ProgressDisplayImpl {
    verbosity: VerbosityLevel,
    use_unicode: bool,
    icons: IconConfig,
}

impl Default for ProgressDisplayImpl {
    fn default() -> Self {
        Self::new(VerbosityLevel::Normal)
    }
}

impl ProgressDisplayImpl {
    pub fn new(verbosity: VerbosityLevel) -> Self {
        // Detect terminal capabilities
        let use_unicode = Self::supports_unicode();

        Self {
            verbosity,
            use_unicode,
            icons: IconConfig::default(),
        }
    }

    /// Create from CLI arguments
    pub fn from_args(verbosity_count: u8, quiet: bool) -> Self {
        let verbosity = VerbosityLevel::from_args(verbosity_count, quiet);
        Self::new(verbosity)
    }

    /// Check if terminal supports Unicode
    fn supports_unicode() -> bool {
        // Check LANG/LC_ALL environment variables
        if let Ok(lang) = std::env::var("LANG") {
            if lang.contains("UTF-8") || lang.contains("utf8") {
                return true;
            }
        }
        if let Ok(lc_all) = std::env::var("LC_ALL") {
            if lc_all.contains("UTF-8") || lc_all.contains("utf8") {
                return true;
            }
        }
        // Default to ASCII on Windows, Unicode elsewhere
        !cfg!(windows)
    }

    /// Get box drawing characters based on Unicode support
    fn box_chars(&self) -> BoxChars {
        if self.use_unicode {
            BoxChars::unicode()
        } else {
            BoxChars::ascii()
        }
    }

    /// Format duration for display
    fn format_duration(duration: Duration) -> String {
        let secs = duration.as_secs();
        let millis = duration.subsec_millis();

        if secs >= 60 {
            let mins = secs / 60;
            let secs = secs % 60;
            format!("{mins}m {secs}s")
        } else if secs > 0 {
            format!("{secs}.{millis:03}s")
        } else {
            format!("{millis}ms")
        }
    }
}

/// Box drawing characters for terminal UI
struct BoxChars {
    horizontal: char,
    vertical: char,
    top_left: char,
    top_right: char,
    bottom_left: char,
    bottom_right: char,
}

impl BoxChars {
    fn unicode() -> Self {
        Self {
            horizontal: '═',
            vertical: '║',
            top_left: '╔',
            top_right: '╗',
            bottom_left: '╚',
            bottom_right: '╝',
        }
    }

    fn ascii() -> Self {
        Self {
            horizontal: '=',
            vertical: '|',
            top_left: '+',
            top_right: '+',
            bottom_left: '+',
            bottom_right: '+',
        }
    }
}

impl ProgressDisplay for ProgressDisplayImpl {
    fn info(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.info);
        }
    }

    fn warning(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            eprintln!("{} {message}", self.icons.warning);
        }
    }

    fn error(&self, message: &str) {
        // Always show errors, even in quiet mode
        eprintln!("{} {message}", self.icons.error);
    }

    fn progress(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.progress);
        }
    }

    fn success(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.success);
        }
    }

    fn action(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.action);
        }
    }

    fn metric(&self, label: &str, value: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {label}: {value}", self.icons.metric);
        }
    }

    fn status(&self, message: &str) {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.status);
        }
    }

    fn start_spinner(&self, message: &str) -> Box<dyn SpinnerHandle> {
        if self.verbosity >= VerbosityLevel::Normal {
            println!("âŗ {message}");
        }
        Box::new(SimpleSpinnerHandle::new(self.verbosity, self.icons))
    }

    fn iteration_start(&self, current: u32, total: u32) {
        if self.verbosity >= VerbosityLevel::Normal {
            let chars = self.box_chars();
            let width = 60;
            let title = format!(" ITERATION {current}/{total} ");
            let padding = (width - title.len()) / 2;

            println!();
            println!(
                "{}{}{}",
                chars.top_left,
                std::iter::repeat_n(chars.horizontal, width).collect::<String>(),
                chars.top_right
            );
            println!(
                "{}{:padding$}{}{:padding$}{}",
                chars.vertical,
                "",
                title,
                "",
                chars.vertical,
                padding = padding
            );
            println!(
                "{}{}{}",
                chars.bottom_left,
                std::iter::repeat_n(chars.horizontal, width).collect::<String>(),
                chars.bottom_right
            );
            println!();
        }
    }

    fn iteration_end(&self, current: u32, duration: Duration, success: bool) {
        if self.verbosity >= VerbosityLevel::Normal {
            let duration_str = Self::format_duration(duration);
            let status = if success {
                format!("{} Success", self.icons.success)
            } else {
                format!("{} Failed", self.icons.error)
            };

            println!();
            println!("┌─ Iteration {current} Summary ──────────────────────────────────────┐");
            println!("│ Duration: {:<49}│", duration_str);
            println!("│ Status: {:<51}│", status);
            println!("└────────────────────────────────────────────────────────────┘");
            println!();
        }
    }

    fn step_start(&self, step: u32, total: u32, description: &str) {
        if self.verbosity >= VerbosityLevel::Verbose {
            println!("[Step {step}/{total}] {description}");
        }
    }

    fn step_end(&self, step: u32, success: bool) {
        if self.verbosity >= VerbosityLevel::Verbose {
            let status = if success {
                self.icons.success
            } else {
                self.icons.error
            };
            println!("[Step {step}] {status}");
        }
    }

    fn command_output(&self, output: &str, verbosity: VerbosityLevel) {
        if self.verbosity >= verbosity && !output.trim().is_empty() {
            println!("{output}");
        }
    }

    fn debug_output(&self, message: &str, min_verbosity: VerbosityLevel) {
        if self.verbosity >= min_verbosity {
            println!("{} {message}", self.icons.debug);
        }
    }

    fn verbosity(&self) -> VerbosityLevel {
        self.verbosity
    }
}

/// Simple spinner handle implementation
struct SimpleSpinnerHandle {
    active: Arc<Mutex<bool>>,
    verbosity: VerbosityLevel,
    icons: IconConfig,
}

impl SimpleSpinnerHandle {
    fn new(verbosity: VerbosityLevel, icons: IconConfig) -> Self {
        Self {
            active: Arc::new(Mutex::new(true)),
            verbosity,
            icons,
        }
    }
}

impl SpinnerHandle for SimpleSpinnerHandle {
    fn update_message(&mut self, message: &str) {
        if *self.active.lock().unwrap() && self.verbosity >= VerbosityLevel::Normal {
            println!("âŗ {message}");
        }
    }

    fn success(&mut self, message: &str) {
        *self.active.lock().unwrap() = false;
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.success);
        }
    }

    fn fail(&mut self, message: &str) {
        *self.active.lock().unwrap() = false;
        if self.verbosity >= VerbosityLevel::Normal {
            println!("{} {message}", self.icons.error);
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    pub struct MockProgressDisplay {
        messages: Arc<Mutex<Vec<String>>>,
        verbosity: VerbosityLevel,
    }

    impl MockProgressDisplay {
        pub fn new() -> Self {
            Self {
                messages: Arc::new(Mutex::new(Vec::new())),
                verbosity: VerbosityLevel::Normal,
            }
        }

        pub fn get_messages(&self) -> Vec<String> {
            self.messages.lock().unwrap().clone()
        }
    }

    impl ProgressDisplay for MockProgressDisplay {
        fn info(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("INFO: {message}"));
        }

        fn warning(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("WARN: {message}"));
        }

        fn error(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("ERROR: {message}"));
        }

        fn progress(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("PROGRESS: {message}"));
        }

        fn success(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("SUCCESS: {message}"));
        }

        fn action(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("ACTION: {message}"));
        }

        fn metric(&self, label: &str, value: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("METRIC: {label}: {value}"));
        }

        fn status(&self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("STATUS: {message}"));
        }

        fn start_spinner(&self, message: &str) -> Box<dyn SpinnerHandle> {
            self.messages
                .lock()
                .unwrap()
                .push(format!("SPINNER: {message}"));
            Box::new(MockSpinnerHandle::new(self.messages.clone()))
        }

        fn iteration_start(&self, current: u32, total: u32) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("ITERATION_START: {current}/{total}"));
        }

        fn iteration_end(&self, current: u32, duration: Duration, success: bool) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("ITERATION_END: {current} {:?} {success}", duration));
        }

        fn step_start(&self, step: u32, total: u32, description: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("STEP_START: {step}/{total} {description}"));
        }

        fn step_end(&self, step: u32, success: bool) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("STEP_END: {step} {success}"));
        }

        fn command_output(&self, output: &str, _verbosity: VerbosityLevel) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("COMMAND_OUTPUT: {output}"));
        }

        fn debug_output(&self, message: &str, _min_verbosity: VerbosityLevel) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("DEBUG: {message}"));
        }

        fn verbosity(&self) -> VerbosityLevel {
            self.verbosity
        }
    }

    struct MockSpinnerHandle {
        messages: Arc<Mutex<Vec<String>>>,
    }

    impl MockSpinnerHandle {
        fn new(messages: Arc<Mutex<Vec<String>>>) -> Self {
            Self { messages }
        }
    }

    impl SpinnerHandle for MockSpinnerHandle {
        fn update_message(&mut self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("SPINNER_UPDATE: {message}"));
        }

        fn success(&mut self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("SPINNER_SUCCESS: {message}"));
        }

        fn fail(&mut self, message: &str) {
            self.messages
                .lock()
                .unwrap()
                .push(format!("SPINNER_FAIL: {message}"));
        }
    }

    #[test]
    fn test_mock_display() {
        let display = MockProgressDisplay::new();

        display.info("Test info");
        display.warning("Test warning");
        display.error("Test error");
        display.progress("Test progress");
        display.success("Test success");

        let messages = display.get_messages();
        assert_eq!(messages.len(), 5);
        assert_eq!(messages[0], "INFO: Test info");
        assert_eq!(messages[1], "WARN: Test warning");
        assert_eq!(messages[2], "ERROR: Test error");
        assert_eq!(messages[3], "PROGRESS: Test progress");
        assert_eq!(messages[4], "SUCCESS: Test success");
    }

    #[test]
    fn test_mock_spinner() {
        let display = MockProgressDisplay::new();
        let mut spinner = display.start_spinner("Starting");

        spinner.update_message("Processing");
        spinner.success("Done");

        let messages = display.get_messages();
        assert_eq!(messages.len(), 3);
        assert_eq!(messages[0], "SPINNER: Starting");
        assert_eq!(messages[1], "SPINNER_UPDATE: Processing");
        assert_eq!(messages[2], "SPINNER_SUCCESS: Done");
    }

    #[test]
    fn test_progress_display_info() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        // Test that info messages are displayed correctly
        display.info("Test info message");
        // Verify output contains the message with info icon
    }

    #[test]
    fn test_progress_display_warning() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        // Test warning messages go to stderr
        display.warning("Test warning");
        // Verify stderr output
    }

    #[test]
    fn test_progress_display_error() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        display.error("Test error");
        // Verify error formatting
    }

    #[test]
    fn test_spinner_lifecycle() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        let mut spinner = display.start_spinner("Loading...");
        // Test spinner starts
        spinner.update_message("Still processing");
        spinner.success("Done");
        // Verify spinner completes
    }

    #[test]
    fn test_progress_display_progress() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        display.progress("Test progress message");
        // Verify progress formatting
    }

    #[test]
    fn test_progress_display_success() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        display.success("Test success message");
        // Verify success formatting
    }

    #[test]
    fn test_simple_spinner_handle_fail() {
        let display = ProgressDisplayImpl::new(VerbosityLevel::Normal);
        let mut spinner = display.start_spinner("Starting task");
        spinner.fail("Failed to complete");
        // Verify failure message
    }

    #[test]
    fn test_verbosity_levels() {
        let quiet = VerbosityLevel::from_args(0, true);
        assert_eq!(quiet, VerbosityLevel::Quiet);

        let normal = VerbosityLevel::from_args(0, false);
        assert_eq!(normal, VerbosityLevel::Normal);

        let verbose = VerbosityLevel::from_args(1, false);
        assert_eq!(verbose, VerbosityLevel::Verbose);

        let debug = VerbosityLevel::from_args(2, false);
        assert_eq!(debug, VerbosityLevel::Debug);

        let trace = VerbosityLevel::from_args(3, false);
        assert_eq!(trace, VerbosityLevel::Trace);
    }

    #[test]
    fn test_iteration_display() {
        let display = MockProgressDisplay::new();
        display.iteration_start(1, 10);
        display.iteration_end(1, Duration::from_secs(5), true);

        let messages = display.get_messages();
        assert!(messages.contains(&"ITERATION_START: 1/10".to_string()));
        assert!(messages.iter().any(|m| m.starts_with("ITERATION_END: 1")));
    }

    #[test]
    fn test_step_display() {
        let display = MockProgressDisplay::new();
        display.step_start(1, 5, "Running tests");
        display.step_end(1, true);

        let messages = display.get_messages();
        assert!(messages.contains(&"STEP_START: 1/5 Running tests".to_string()));
        assert!(messages.contains(&"STEP_END: 1 true".to_string()));
    }

    #[test]
    fn test_verbosity_filtering() {
        let quiet_display = ProgressDisplayImpl::new(VerbosityLevel::Quiet);
        quiet_display.info("Should not appear");
        quiet_display.error("Should appear");
        // In quiet mode, only errors should be shown

        let verbose_display = ProgressDisplayImpl::new(VerbosityLevel::Verbose);
        verbose_display.step_start(1, 3, "test");
        // In verbose mode, step information should be shown
    }

    #[test]
    fn test_command_output_display() {
        let display = MockProgressDisplay::new();
        display.command_output("test output", VerbosityLevel::Debug);

        let messages = display.get_messages();
        assert!(messages.contains(&"COMMAND_OUTPUT: test output".to_string()));
    }

    #[test]
    fn test_debug_output() {
        let display = MockProgressDisplay::new();
        display.debug_output("debug info", VerbosityLevel::Trace);

        let messages = display.get_messages();
        assert!(messages.contains(&"DEBUG: debug info".to_string()));
    }

    #[test]
    fn test_format_duration() {
        assert_eq!(
            ProgressDisplayImpl::format_duration(Duration::from_millis(500)),
            "500ms"
        );
        assert_eq!(
            ProgressDisplayImpl::format_duration(Duration::from_secs(5)),
            "5.000s"
        );
        assert_eq!(
            ProgressDisplayImpl::format_duration(Duration::from_secs(65)),
            "1m 5s"
        );
    }
}