tix-tracker 0.11.0

A terminal issue tracker: markdown + YAML frontmatter issues with a kanban TUI and CLI
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
//! Saved-views modal: list, apply, and manage the registry (WP05, T024–T027;
//! mission `saved-issue-views-01M3C926`).
//!
//! This module is a **pure view + model**, exactly as `filter_modal.rs` and
//! `settings.rs` are: it renders rows, holds a cursor and an inline prompt, and
//! never reads a key, touches `tix.toml`, or interprets a query. `app.rs` routes
//! the keys and calls the shared [`crate::views::service::ViewService`] — the
//! same service `tix view` calls — so every rule (stable ids, scope precedence,
//! plan validation, definition-only delete) stays owned once, by WP01–WP03.
//!
//! # What this surface deliberately does not do
//!
//! - **no second grammar** (C-002/C-004): a view created here is built from the
//!   *live* [`StructuredFilter`](crate::search::StructuredFilter) and text query
//!   through [`ViewPlan::from_parts`], the same adapter the CLI uses;
//! - **no writes to issues** (C-005): deleting a view removes the saved
//!   definition and nothing else;
//! - **no reconciliation** (C-006): divergence is *reported* by the feedback
//!   panel, never applied.
//!
//! # Display parity
//!
//! The feedback text is derived by `app.rs` from the shared domain types and
//! rendered verbatim here, so the widget owns no comparison. The spellings it
//! renders — `scope_label`, the diagnostic line, the plan summary — mirror the
//! ones `tix view show`/`tix view status` print; the CLI's private helpers
//! (`crate::commands::views::scope_label`, `render_diagnostic`, `plan_lines`) are
//! the reference, and the tests below pin them.

use ratatui::Frame;
use ratatui::layout::Rect;
use ratatui::style::{Color, Modifier, Style};
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, Borders, Clear, Paragraph};

use crate::keybindings::{EffectiveBindings, InputContext, KeyBindings, TuiAction};
use crate::views::divergence::ViewDivergence;
use crate::views::plan::ViewPlan;
use crate::views::registry::{ScopeResolution, ViewDiagnostic, ViewId, ViewRefusal, ViewScope};

use super::modal::modal_rect;

/// The rendered saved-view feedback: one indicator line plus ordered detail
/// lines (T024/T026).
///
/// The **text** is derived once, in `app.rs`, from the shared domain types and
/// then rendered by both the filter modal and the views modal. A widget that
/// derives its own text would eventually describe the same record differently
/// from the other one, which is the drift this split exists to prevent.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ViewFeedback {
    /// The compact one-line indicator, e.g. `view Active · diverged (plan.sort)`.
    pub indicator: String,
    /// Ordered detail: the scope, the plan, the differences, the diagnostics.
    pub lines: Vec<String>,
}

impl ViewFeedback {
    /// Feedback for a saved view: its indicator and its detail lines.
    #[must_use]
    pub fn new(indicator: impl Into<String>, lines: Vec<String>) -> Self {
        Self {
            indicator: indicator.into(),
            lines,
        }
    }
}

/// One saved view as the modal lists it (T024).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ViewRow {
    /// The stable id — the identity a mutation and the active marker use. Never
    /// the name (C-002).
    pub id: ViewId,
    /// The display label. Renameable; never the identity.
    pub name: String,
    /// `scope_label (resolution)`, already rendered by the app.
    pub scope: String,
    /// Whether the live board is associated with this view (FR-004).
    pub active: bool,
}

/// The inline prompt the modal is showing, if any (T027).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ViewsPrompt {
    /// Naming a new view, which is created from the live plan.
    Create(String),
    /// Renaming the view with this stable id.
    Rename { id: ViewId, buffer: String },
    /// Confirming the definition-only delete of the view with this id.
    ConfirmDelete { id: ViewId, name: String },
}

/// The saved-views modal's own state: rows, cursor, prompt, feedback.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ViewsModal {
    /// One row per stored view, in declaration order (registry order).
    pub rows: Vec<ViewRow>,
    /// The cursor over `rows`.
    pub selected: usize,
    /// The active inline prompt, or `None` while browsing the list.
    pub prompt: Option<ViewsPrompt>,
    /// Feedback for the row under the cursor, refreshed by the app (T026).
    pub feedback: Option<ViewFeedback>,
    /// One line about the last operation: a refusal, or what was written.
    pub note: Option<String>,
}

impl ViewsModal {
    /// A modal over `rows`, with the cursor on the active view when one is
    /// marked and on the first row otherwise — so opening the view list shows
    /// the view the board is currently associated with.
    #[must_use]
    pub fn new(rows: Vec<ViewRow>) -> Self {
        let selected = rows.iter().position(|row| row.active).unwrap_or(0);
        Self {
            rows,
            selected,
            prompt: None,
            feedback: None,
            note: None,
        }
    }

    /// The row under the cursor, when the list is not empty.
    #[must_use]
    pub fn selected_row(&self) -> Option<&ViewRow> {
        self.rows.get(self.selected)
    }

    /// Move the cursor by `delta`, clamped to the list (no wrap: the views modal
    /// is a menu, and a menu that wraps hides how many entries there are).
    pub fn move_selected(&mut self, delta: isize) {
        if self.rows.is_empty() {
            self.selected = 0;
            return;
        }
        let last = self.rows.len() - 1;
        let next = if delta < 0 {
            self.selected.saturating_sub(delta.unsigned_abs())
        } else {
            self.selected.saturating_add(delta as usize)
        };
        self.selected = next.min(last);
    }

    /// Jump the cursor straight to `row` (a row click, D6), clamped to the same
    /// range the arrow keys navigate.
    pub fn move_selected_to(&mut self, row: usize) {
        if self.rows.is_empty() {
            self.selected = 0;
            return;
        }
        self.selected = row.min(self.rows.len() - 1);
    }

    /// Whether an inline prompt is open.
    #[must_use]
    pub const fn is_prompting(&self) -> bool {
        self.prompt.is_some()
    }

    /// Drop the prompt (a cancel, or after a completed operation).
    pub fn clear_prompt(&mut self) {
        self.prompt = None;
    }

    /// The first row index the modal draws for a body `inner_h` rows tall.
    fn window_start(&self, inner_h: usize) -> usize {
        let row_budget = inner_h.min(self.rows.len());
        if self.rows.len() > row_budget {
            (self.selected + 1).saturating_sub(row_budget)
        } else {
            0
        }
    }

    /// The clickable rect of every **visible** row, paired with that row's index
    /// in [`Self::rows`] (D6).
    ///
    /// The widget owns its own layout, so the app asks it where the rows are
    /// rather than re-deriving the windowing and drifting from it — a click that
    /// selected the wrong view would be a silent wrong action, which is exactly
    /// what the region indirection exists to prevent.
    #[must_use]
    pub fn row_hit_regions(&self, area: Rect) -> Vec<(Rect, usize)> {
        let rect = modal_rect(area);
        let inner_h = rect.height.saturating_sub(2) as usize;
        let start = self.window_start(inner_h);
        let visible = inner_h.min(self.rows.len());
        (0..visible)
            .map(|offset| {
                (
                    Rect {
                        x: rect.x + 1,
                        y: rect.y + 1 + offset as u16,
                        width: rect.width.saturating_sub(2),
                        height: 1,
                    },
                    start + offset,
                )
            })
            .collect()
    }

    /// Render the modal with the built-in keybindings (tests, and any caller that
    /// has no `EffectiveBindings` at hand).
    pub fn render(&self, f: &mut Frame, area: Rect) {
        let bindings =
            KeyBindings::resolve(&KeyBindings::default()).expect("built-in bindings are valid");
        self.render_with_bindings(f, area, &bindings, InputContext::Views);
    }

    #[allow(clippy::too_many_lines)]
    pub fn render_with_bindings(
        &self,
        f: &mut Frame,
        area: Rect,
        bindings: &EffectiveBindings,
        context: InputContext,
    ) {
        let rect = modal_rect(area);
        let inner_h = rect.height.saturating_sub(2) as usize;
        let mut lines: Vec<Line<'static>> = Vec::new();

        // The list is windowed (not truncated) around the cursor, so a registry
        // longer than the modal can still be walked: the cursor is always on
        // screen.
        let row_budget = inner_h.min(self.rows.len());
        let start = self.window_start(inner_h);
        for (offset, row) in self.rows[start..].iter().take(row_budget).enumerate() {
            let is_cursor = start + offset == self.selected;
            let marker = if row.active { "*" } else { " " };
            let cursor = if is_cursor { "> " } else { "  " };
            let style = if is_cursor {
                Style::default()
                    .fg(Color::Yellow)
                    .add_modifier(Modifier::BOLD)
            } else {
                Style::default().fg(Color::White)
            };
            lines.push(Line::from(vec![
                Span::styled(cursor, style),
                Span::styled(
                    format!("{marker} {}", row.name),
                    if row.active {
                        style.fg(Color::Cyan).add_modifier(Modifier::BOLD)
                    } else {
                        style
                    },
                ),
                Span::styled(
                    format!("  [{}]", row.scope),
                    Style::default().fg(Color::DarkGray),
                ),
            ]));
        }
        if self.rows.is_empty() {
            lines.push(Line::from(Span::styled(
                "  (no saved views)",
                Style::default().fg(Color::DarkGray),
            )));
        }

        let mut budget = inner_h.saturating_sub(lines.len());
        let mut push = |line: Line<'static>, budget: &mut usize| {
            if *budget > 0 {
                lines.push(line);
                *budget -= 1;
            }
        };

        // The last operation's outcome first: it is the reason the prompt is
        // still open when a name was refused, and the reason the list changed
        // when one was accepted.
        if let Some(note) = &self.note {
            push(
                Line::from(Span::styled(
                    note.clone(),
                    Style::default().fg(Color::Yellow),
                )),
                &mut budget,
            );
        }

        match &self.prompt {
            Some(ViewsPrompt::Create(buffer)) => push(
                Line::from(Span::styled(
                    format!("New view name: {buffer}_"),
                    Style::default().fg(Color::Cyan),
                )),
                &mut budget,
            ),
            Some(ViewsPrompt::Rename { buffer, .. }) => push(
                Line::from(Span::styled(
                    format!("Rename to: {buffer}_"),
                    Style::default().fg(Color::Cyan),
                )),
                &mut budget,
            ),
            Some(ViewsPrompt::ConfirmDelete { name, .. }) => push(
                Line::from(Span::styled(
                    format!("Delete view '{name}' (definition only)? [y/N]"),
                    Style::default().fg(Color::Red).add_modifier(Modifier::BOLD),
                )),
                &mut budget,
            ),
            None => {
                if let Some(feedback) = &self.feedback {
                    // Indicator first: the same line the board shows, so the two
                    // cannot say different things about the same state.
                    push(
                        Line::from(Span::styled(
                            feedback.indicator.clone(),
                            Style::default().fg(Color::Green),
                        )),
                        &mut budget,
                    );
                    for line in &feedback.lines {
                        push(
                            Line::from(Span::styled(
                                line.clone(),
                                Style::default().fg(Color::DarkGray),
                            )),
                            &mut budget,
                        );
                    }
                }
            }
        }

        if budget > 0 {
            // The last row is the key legend: a binding nobody can find is a
            // binding nobody uses.
            let footer = match &self.prompt {
                Some(ViewsPrompt::ConfirmDelete { .. }) => format!(
                    "{}: delete · {}: cancel",
                    bindings.label(InputContext::ConfirmDelete, TuiAction::Confirm),
                    bindings.label(InputContext::ConfirmDelete, TuiAction::Cancel),
                ),
                Some(_) => format!(
                    "{}: save · {}: cancel",
                    bindings.label(context, TuiAction::Submit),
                    bindings.label(context, TuiAction::Cancel),
                ),
                None => format!(
                    "{}: apply · {}: new · {}: rename · {}: update from live · \
                     {}: duplicate · {}: delete · {}: close",
                    bindings.label(context, TuiAction::ApplyView),
                    bindings.label(context, TuiAction::NewView),
                    bindings.label(context, TuiAction::RenameView),
                    bindings.label(context, TuiAction::UpdateView),
                    bindings.label(context, TuiAction::DuplicateView),
                    bindings.label(context, TuiAction::DeleteView),
                    bindings.label(context, TuiAction::Close),
                ),
            };
            lines.push(Line::from(Span::styled(
                footer,
                Style::default().fg(Color::DarkGray),
            )));
        }

        let block = Block::default()
            .borders(Borders::ALL)
            .title(format!(" Saved views ({}) ", self.rows.len()))
            .style(Style::default().fg(Color::Cyan));
        let para = Paragraph::new(lines).block(block);
        f.render_widget(Clear, rect);
        f.render_widget(para, rect);
    }
}

/// One diagnostic, rendered through the **shared** refusal renderer, so the TUI
/// spells a diagnostic exactly as `tix view show` does (`kind: message`).
#[must_use]
pub fn diagnostic_line(diagnostic: &ViewDiagnostic) -> String {
    ViewRefusal::from_diagnostic(diagnostic.clone()).render()
}

/// The scope family and its metadata as one token.
///
/// The spellings mirror `tix view show`'s (`crate::commands::views::scope_label`)
/// so the two surfaces describe one record identically.
#[must_use]
pub fn scope_label(scope: &ViewScope) -> String {
    match scope.kind {
        crate::views::registry::ViewScopeKind::Repository => "repository".to_string(),
        crate::views::registry::ViewScopeKind::Project => {
            format!("project {}", scope.project_id.as_deref().unwrap_or(""))
        }
        crate::views::registry::ViewScopeKind::UserShare => {
            let mut parts = vec!["user".to_string()];
            if let Some(owner) = scope.owner.as_deref() {
                parts.push(format!("owner={owner}"));
            }
            if !scope.shared_with.is_empty() {
                parts.push(format!("shared_with={}", scope.shared_with.join(",")));
            }
            parts.join(" ")
        }
    }
}

/// `repository (resolved)` — the scope family plus its derived resolution, the
/// two facts T026 asks the TUI to render.
#[must_use]
pub fn scope_summary(scope: &ViewScope, resolution: ScopeResolution) -> String {
    format!("{} ({resolution})", scope_label(scope))
}

/// The plan as one line of `key: value` parts, in the vocabulary
/// `tix view show` prints one-per-line.
#[must_use]
pub fn plan_summary(plan: &ViewPlan) -> String {
    let mut parts = vec![format!("filter: {}", plan.filter())];
    if let Some(query) = plan.text_query() {
        parts.push(format!("query: {query}"));
    }
    if let Some(sort) = plan.sort() {
        parts.push(format!("sort: {sort}"));
    }
    if let Some(group) = plan.group() {
        parts.push(format!("group: {group}"));
    }
    if let Some(visibility) = plan.visibility() {
        parts.push(format!(
            "hide-columns: {}",
            visibility.hidden_columns().join(",")
        ));
        parts.push(format!(
            "show-mismatch: {}",
            visibility
                .show_mismatch()
                .map_or_else(|| "inherit".to_string(), |value| value.to_string())
        ));
    }
    parts.join(" · ")
}

/// One line per divergent field, `saved=… live=…` with `(unset)` for an unset
/// value — the same shape `tix view status` prints.
#[must_use]
pub fn difference_lines(divergence: &ViewDivergence) -> Vec<String> {
    divergence
        .differences()
        .iter()
        .map(|difference| {
            format!(
                "{}: saved={} live={}",
                difference.field(),
                difference.saved().unwrap_or("(unset)"),
                difference.live().unwrap_or("(unset)"),
            )
        })
        .collect()
}

/// The compact indicator: `view Foo · in sync` or
/// `view Foo · diverged (plan.sort, plan.group)`.
///
/// Deliberately one line: the board renders it in a single row, and a truncating
/// surface must be able to tell "in sync" from "diverged" from the prefix. The
/// full differences follow in the feedback panel.
#[must_use]
pub fn indicator_line(name: &str, divergence: &ViewDivergence) -> String {
    if !divergence.in_sync() {
        let fields: Vec<&str> = divergence
            .differences()
            .iter()
            .map(|difference| difference.field())
            .collect();
        let mut summary = if fields.is_empty() {
            "diverged".to_string()
        } else {
            format!("diverged ({})", fields.join(", "))
        };
        if !divergence.diagnostics().is_empty() {
            summary.push_str(" +diagnostics");
        }
        return format!("view {name} · {summary}");
    }
    format!("view {name} · in sync")
}

#[cfg(test)]
mod tests {
    #[allow(clippy::wildcard_imports)]
    use super::*;
    use crate::search::StructuredFilter;
    use crate::views::registry::ViewDiagnosticKind;
    use ratatui::Terminal;
    use ratatui::backend::TestBackend;

    fn row(id: &str, name: &str, active: bool) -> ViewRow {
        ViewRow {
            id: ViewId::new(id).unwrap(),
            name: name.to_string(),
            scope: "repository (resolved)".to_string(),
            active,
        }
    }

    #[test]
    fn the_cursor_opens_on_the_active_view() {
        let modal = ViewsModal::new(vec![row("v-1", "One", false), row("v-2", "Two", true)]);
        assert_eq!(modal.selected, 1);
        assert_eq!(modal.selected_row().unwrap().name, "Two");
    }

    #[test]
    fn the_cursor_clamps_at_both_ends() {
        let mut modal = ViewsModal::new(vec![row("v-1", "One", false), row("v-2", "Two", false)]);
        modal.move_selected(-1);
        assert_eq!(modal.selected, 0);
        modal.move_selected(5);
        assert_eq!(modal.selected, 1);
        modal.move_selected_to(99);
        assert_eq!(modal.selected, 1);
        modal.move_selected_to(0);
        assert_eq!(modal.selected, 0);
    }

    #[test]
    fn an_empty_registry_renders_and_keeps_the_cursor_at_zero() {
        let mut modal = ViewsModal::new(Vec::new());
        modal.move_selected(3);
        assert_eq!(modal.selected, 0);
        assert!(modal.selected_row().is_none());
        let backend = TestBackend::new(80, 24);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| modal.render(f, f.area())).unwrap();
    }

    #[test]
    fn scope_labels_name_the_family_and_its_metadata() {
        assert_eq!(scope_label(&ViewScope::repository()), "repository");
        assert_eq!(
            scope_label(&ViewScope::project("p-platform")),
            "project p-platform"
        );
        assert_eq!(
            scope_label(&ViewScope::user_share(
                Some("alice".to_string()),
                vec!["bob".to_string()]
            )),
            "user owner=alice shared_with=bob"
        );
        assert_eq!(
            scope_summary(&ViewScope::repository(), ScopeResolution::Resolved),
            "repository (resolved)"
        );
    }

    #[test]
    fn a_diagnostic_line_is_the_shared_refusal_spelling() {
        let diagnostic = ViewDiagnostic::new(ViewDiagnosticKind::UnknownMetadata, "kept")
            .with_field("extensions.colour");
        // `ViewRefusal::render` goes through the shared
        // `error::render_diagnostics(id, pairs)`, which is the *rendered* form —
        // level, id, message — exactly as `Diagnostic::error(...).render()` spells
        // it. The mission was written against the plain `kind: message` form that
        // the one-argument renderer produced; the id is part of the shared
        // spelling now, and the modal shows one line of it.
        assert_eq!(
            diagnostic_line(&diagnostic),
            "error[E-tix-views]: unknown_metadata: kept"
        );
    }

    #[test]
    fn an_in_sync_indicator_names_the_view_only() {
        let plan = ViewPlan::from_parts(StructuredFilter::default(), "sort:due");
        let divergence = ViewDivergence::between(&plan, &plan);
        assert_eq!(
            indicator_line("Active", &divergence),
            "view Active · in sync"
        );
        assert_eq!(
            difference_lines(&divergence),
            [] as [std::string::String; 0]
        );
    }

    #[test]
    fn a_diverged_indicator_names_the_divergent_fields() {
        let saved = ViewPlan::from_parts(StructuredFilter::default(), "sort:due");
        let live = ViewPlan::from_parts(StructuredFilter::default(), "sort:created");
        let divergence = ViewDivergence::between(&saved, &live);
        assert_eq!(
            indicator_line("Active", &divergence),
            "view Active · diverged (plan.sort)"
        );
        assert_eq!(
            difference_lines(&divergence),
            vec!["plan.sort: saved=due live=created".to_string()]
        );
    }

    #[test]
    fn a_missing_marker_indicator_says_so_rather_than_in_sync() {
        let live = ViewPlan::from_parts(StructuredFilter::default(), "sort:due");
        let divergence = ViewDivergence::missing_marker(&live);
        assert!(!divergence.in_sync());
        assert_eq!(
            indicator_line("Active", &divergence),
            "view Active · diverged +diagnostics"
        );
    }

    #[test]
    fn a_plan_summary_lists_the_set_fields_in_the_cli_vocabulary() {
        let plan = ViewPlan::from_parts(StructuredFilter::default(), "sort:due group:cycle");
        assert_eq!(
            plan_summary(&plan),
            "filter: (no active criteria) · sort: due · group: cycle"
        );
    }

    #[test]
    fn render_smoke_at_several_sizes() {
        for (w, h) in [(120, 40), (80, 24), (20, 5)] {
            let mut modal =
                ViewsModal::new(vec![row("v-1", "One", true), row("v-2", "Two", false)]);
            modal.feedback = Some(ViewFeedback::new(
                "view One · in sync",
                vec!["scope: repository (resolved)".to_string()],
            ));
            modal.note = Some("Saved v-1".to_string());
            let backend = TestBackend::new(w, h);
            let mut terminal = Terminal::new(backend).unwrap();
            terminal.draw(|f| modal.render(f, f.area())).unwrap();
        }
    }
}