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
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
#[allow(clippy::wildcard_imports)]
use super::super::*;
#[allow(clippy::wildcard_imports)]
use super::helpers::*;

/// Every configured board is listed under the Board trunk, and the active one
/// is marked (`NavBranch::active`) so the rail draws it bold.
#[test]
fn boards_limb_lists_every_board_and_marks_the_active_one() {
    // A single board is still listed (and is the active one).
    let (_tmp, app) = make_app();
    let board = app
        .nav_tree()
        .into_iter()
        .find(|node| node.mode == TopMode::Board)
        .expect("the Board trunk exists");
    assert_eq!(
        board
            .branches
            .iter()
            .map(|b| b.label.as_str())
            .collect::<Vec<_>>(),
        vec!["default"]
    );
    assert_eq!(board.branches[0].kind, crate::ui::nav::BranchKind::Board);
    assert!(board.branches[0].active, "the only board is active");

    // Two boards: both listed, only the active one marked.
    let (_tmp, app) = make_branchy_app();
    let board = app
        .nav_tree()
        .into_iter()
        .find(|node| node.mode == TopMode::Board)
        .expect("the Board trunk exists");
    assert_eq!(
        board
            .branches
            .iter()
            .map(|b| b.label.as_str())
            .collect::<Vec<_>>(),
        vec!["default", "release"]
    );
    assert_eq!(
        board
            .branches
            .iter()
            .filter(|b| b.active)
            .map(|b| b.label.as_str())
            .collect::<Vec<_>>(),
        vec!["default"],
        "exactly the active board is marked"
    );
}

/// The active board's limb row is drawn in bold; the others are not.
#[test]
fn active_board_limb_is_drawn_bold() {
    use ratatui::Terminal;
    use ratatui::backend::TestBackend;
    let (_tmp, mut app) = make_branchy_app();
    app.nav_display = NavDisplay::Default;
    let backend = TestBackend::new(80, 24);
    let mut terminal = Terminal::new(backend).unwrap();
    terminal
        .draw(|f| crate::app::render(&app, f, f.area()))
        .unwrap();
    let buffer = terminal.backend().buffer();
    // Rows: 0 F1 New Issue, 1 bug, 2 feature, 3 F2 Triage, 4 F3 Board,
    // 5 `default` (active board), 6 `release`. Branch text starts at col 2.
    assert!(
        buffer[(2, 5)].style().add_modifier.contains(Modifier::BOLD),
        "the active board limb is bold: {:?}",
        buffer[(2, 5)].style()
    );
    assert!(
        !buffer[(2, 6)].style().add_modifier.contains(Modifier::BOLD),
        "a non-active board limb is not bold: {:?}",
        buffer[(2, 6)].style()
    );
}

/// Templates, cycles and milestones each become a limb under their trunk,
/// with the action that activates them (acceptance 3).
#[test]
fn template_cycle_and_milestone_limbs_carry_their_actions() {
    let (_tmp, app) = make_branchy_app();
    let templates = app
        .nav_tree()
        .into_iter()
        .find(|node| node.mode == TopMode::NewIssue)
        .expect("the New Issue trunk exists");
    assert_eq!(
        templates
            .branches
            .iter()
            .map(|b| b.action.clone())
            .collect::<Vec<_>>(),
        vec![
            Action::NewFromTemplate("bug".into()),
            Action::NewFromTemplate("feature".into()),
        ]
    );

    let (_tmp, app) = make_cycle_app();
    let cycles = app
        .nav_tree()
        .into_iter()
        .find(|node| node.mode == TopMode::Cycle)
        .expect("the Cycles trunk exists");
    assert_eq!(
        cycles
            .branches
            .iter()
            .map(|b| b.label.as_str())
            .collect::<Vec<_>>(),
        vec!["Historical", "Ongoing", "Later"]
    );

    // A milestone registry file becomes a Milestones limb.
    let planner =
        crate::planning::Planner::from_config(app.store.config.clone(), app.project_root());
    planner
        .create_milestone_file("Backlog", None, None)
        .expect("milestone file is created");
    let milestones = app
        .nav_tree()
        .into_iter()
        .find(|node| node.mode == TopMode::Milestones)
        .expect("the Milestones trunk exists");
    assert_eq!(
        milestones
            .branches
            .iter()
            .map(|b| b.action.clone())
            .collect::<Vec<_>>(),
        vec![Action::SelectMilestone("Backlog".into())]
    );
}

/// The rail draws one indented row per trunk and per limb, and each limb row
/// records its own click target (acceptance 2/3).
#[test]
fn rail_draws_indented_limbs_with_click_regions() {
    let (_tmp, mut app) = make_branchy_app();
    app.nav_display = NavDisplay::Default;
    let cells = draw_board(&app, 80, 24);
    assert!(
        flush_line(&cells, 80, 0).starts_with("F1 New Issue"),
        "the New Issue trunk is the first row: {:?}",
        flush_line(&cells, 80, 0)
    );
    assert!(
        flush_line(&cells, 80, 1).starts_with("  bug"),
        "the first template limb is indented: {:?}",
        flush_line(&cells, 80, 1)
    );
    assert!(flush_line(&cells, 80, 2).starts_with("  feature"));

    // The limb row resolves to its own action, not the trunk's.
    let hovered = app.handle_mouse(moved_to(0, 1)).unwrap();
    assert_eq!(hovered, Action::None, "hover never acts");
    assert!(
        app.is_hovered(&Action::NewFromTemplate("bug".into())),
        "the template row must read as hovered"
    );
    let clicked = app.handle_mouse(down_left(0, 1)).unwrap();
    assert_eq!(clicked, Action::NewFromTemplate("bug".into()));
}

/// `Small` abbreviates each limb row to two characters while trunk rows keep
/// their chord (acceptance 4).
#[test]
fn small_navigation_abbreviates_limb_labels() {
    let (_tmp, mut app) = make_branchy_app();
    app.nav_display = NavDisplay::Small;
    let cells = draw_board(&app, 80, 24);
    let row0 = flush_line(&cells, 80, 0);
    assert!(
        row0.starts_with("F1") && !row0.starts_with("F1 New Issue"),
        "small trunk shows only the chord: {row0:?}"
    );
    assert!(
        flush_line(&cells, 80, 1).starts_with("  bu"),
        "the template limb is abbreviated: {:?}",
        flush_line(&cells, 80, 1)
    );
    assert!(flush_line(&cells, 80, 2).starts_with("  fe"));
}

/// The F5 Milestones mode is the Config surface pinned to the milestones
/// section, focused on the branch's milestone; its registry renders the same
/// rows the Config section draws (task 5).
#[test]
fn milestone_branch_focuses_and_renders_the_registry() {
    let (_tmp, mut app) = make_app();
    let planner =
        crate::planning::Planner::from_config(app.store.config.clone(), app.project_root());
    planner
        .create_milestone_file("Backlog", None, Some("first things first"))
        .unwrap();
    planner.create_milestone_file("Q4", None, None).unwrap();

    app.activate_branch(&Action::SelectMilestone("Q4".into()))
        .unwrap();
    assert!(matches!(app.mode, Mode::Settings));
    assert_eq!(app.top_mode, TopMode::Milestones);
    assert!(app.milestone_mode);
    assert_eq!(
        app.settings.as_ref().map(|s| s.section),
        Some(ConfigSection::Milestones)
    );
    assert_eq!(app.planning.as_ref().map(|m| m.selected), Some(1));

    let cells = draw_board(&app, 80, 24);
    let text = cells.concat();
    assert!(
        text.contains("Backlog") && text.contains("Q4"),
        "both milestones render: {text:?}"
    );
    assert!(
        !text.contains(" Dashboards — "),
        "the Milestones mode draws no section rail"
    );
}

#[test]
fn f4_opens_the_cycle_mode_and_highlights_it() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    assert!(matches!(app.mode, Mode::Cycle));
    assert_eq!(
        app.top_mode,
        TopMode::Cycle,
        "the navigation highlights Cycle"
    );
    assert!(app.cycle_state.is_some(), "the mode owns its cursor");
}

#[test]
fn cycle_mode_groups_cycles_chronologically() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    let groups = app.cycle_groups();
    let group_of = |name: &str| {
        groups
            .iter()
            .find(|group| group.entries.iter().any(|entry| entry.name == name))
            .map(|group| group.group)
    };
    assert_eq!(
        group_of("Ongoing"),
        Some(crate::ui::cycle::CycleGroup::Current),
        "a start date with no end date is the current cycle"
    );
    assert_eq!(
        group_of("Default"),
        Some(crate::ui::cycle::CycleGroup::Current),
        "the implicit Default cycle is current"
    );
    assert_eq!(
        group_of("Later"),
        Some(crate::ui::cycle::CycleGroup::Future)
    );
    assert_eq!(
        group_of("Historical"),
        Some(crate::ui::cycle::CycleGroup::Archived)
    );
    let order: Vec<&str> = crate::ui::cycle::flat_entries(&groups)
        .into_iter()
        .map(|entry| entry.name.as_str())
        .collect();
    assert_eq!(
        order,
        vec!["Default", "Ongoing", "Later", "Historical"],
        "current first, then future, then archived"
    );
}

#[test]
fn cycle_mode_statistics_are_progress_and_zero_for_an_empty_cycle() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    let entries = app.cycle_entries();
    let progress = |name: &str| {
        entries
            .iter()
            .find(|entry| entry.name == name)
            .map(|entry| (entry.progress.done, entry.progress.total))
            .unwrap()
    };
    assert_eq!(progress("Ongoing"), (1, 2), "one of two issues complete");
    assert_eq!(
        progress("Later"),
        (0, 0),
        "an empty cycle renders zeros, not an error"
    );
}

#[test]
fn cycle_mode_renders_group_headings_and_selected_statistics() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    // Ordinal 1 is `Ongoing` (Default is ordinal 0), so its stats show.
    app.select_cycle_row(1);
    let text = draw_board(&app, 80, 24).concat();
    assert!(text.contains("Ongoing"), "the cycle row is listed: {text}");
    assert!(
        text.contains("Completed: 1/2"),
        "the selected cycle's progress renders: {text}"
    );
    assert!(text.contains("Current"), "current heading: {text}");
    assert!(text.contains("Future"), "future heading: {text}");
    assert!(text.contains("Archived"), "archived heading: {text}");
}

#[test]
fn cycle_mode_cursor_moves_with_keys() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    app.handle_key(press(KeyCode::Char('j'))).unwrap();
    assert_eq!(app.cycle_state.unwrap().selected, 1);
    app.handle_key(press(KeyCode::Char('k'))).unwrap();
    assert_eq!(app.cycle_state.unwrap().selected, 0);
    app.handle_key(press(KeyCode::Esc)).unwrap();
    assert!(matches!(app.mode, Mode::Board), "Esc leaves the mode");
}

#[test]
fn cycle_mode_h_and_l_jump_between_groups_and_clamp() {
    // Flat order: Default, Ongoing | Later | Historical. `l` lands on the
    // first entry of the next rendered group, `h` on the previous one, and
    // neither end wraps.
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    let selected = |app: &App| app.cycle_state.unwrap().selected;
    assert_eq!(selected(&app), 0);

    app.handle_key(press(KeyCode::Char('l'))).unwrap();
    assert_eq!(selected(&app), 2, "`l` jumps to the first Future entry");
    app.handle_key(press(KeyCode::Right)).unwrap();
    assert_eq!(selected(&app), 3, "the arrow jumps to Archived");
    app.handle_key(press(KeyCode::Char('l'))).unwrap();
    assert_eq!(selected(&app), 3, "the last group clamps");

    app.handle_key(press(KeyCode::Char('h'))).unwrap();
    assert_eq!(selected(&app), 2, "`h` jumps back to Future");
    app.handle_key(press(KeyCode::Left)).unwrap();
    assert_eq!(selected(&app), 0, "the arrow jumps back to Current");
    app.handle_key(press(KeyCode::Char('h'))).unwrap();
    assert_eq!(selected(&app), 0, "the first group clamps");
}

#[test]
fn cycle_mode_h_from_inside_a_group_lands_on_its_first_entry() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    // Ordinal 1 is `Ongoing`, the second Current entry.
    app.select_cycle_row(1);
    app.handle_key(press(KeyCode::Char('h'))).unwrap();
    assert_eq!(
        app.cycle_state.unwrap().selected,
        0,
        "the previous group is clamped to Current, whose first entry is ordinal 0"
    );
    app.handle_key(press(KeyCode::Char('l'))).unwrap();
    assert_eq!(
        app.cycle_state.unwrap().selected,
        2,
        "and `l` still reaches the next rendered group"
    );
}

#[test]
fn clicking_a_cycle_row_selects_it() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    // Draw first: the row rects are recorded by the renderer. The default
    // navigation takes 14 columns, the group heading is row 1, so the
    // second entry (`Ongoing`) is row 3.
    let _ = draw_board(&app, 80, 24);
    let action = app.handle_mouse(down_left(20, 3)).unwrap();
    assert_eq!(
        action,
        Action::CycleSelect(1),
        "a click on the second row maps to the second cycle"
    );
    app.select_cycle_row(1);
    assert_eq!(app.cycle_state.unwrap().selected, 1);
    assert!(matches!(app.mode, Mode::Cycle));
}

#[test]
fn cycle_mode_renders_on_a_tiny_terminal() {
    let (_tmp, mut app) = make_cycle_app();
    app.handle_key(press(KeyCode::F(4))).unwrap();
    for (width, height) in [(20_u16, 5_u16), (1, 1), (80, 3), (15, 24)] {
        let _ = draw_board(&app, width, height);
    }
}

/// The cycle the rail marks active is exactly the focused cycle, and only
/// while the Cycle mode is the top mode; the row is drawn bold.
#[test]
fn active_cycle_limb_is_marked_and_drawn_bold() {
    // Off the Cycle mode nothing is active, even with a cursor present.
    let (_tmp, app) = make_cycle_app();
    assert_eq!(app.active_cycle_name(), None);
    let cycle_node = |app: &App| {
        app.nav_tree()
            .into_iter()
            .find(|node| node.mode == TopMode::Cycle)
            .expect("the Cycles trunk exists")
    };
    assert!(
        cycle_node(&app)
            .branches
            .iter()
            .all(|branch| !branch.active)
    );

    let (_tmp, mut app) = make_cycle_app();
    app.activate_branch(&Action::SelectCycle("Ongoing".into()))
        .unwrap();
    assert_eq!(app.active_cycle_name().as_deref(), Some("Ongoing"));
    let marked: Vec<String> = cycle_node(&app)
        .branches
        .iter()
        .filter(|branch| branch.active)
        .map(|branch| branch.label.clone())
        .collect();
    assert_eq!(marked, vec!["Ongoing".to_string()]);

    let cells = draw_board(&app, 80, 24);
    let row_of = |prefix: &str| {
        (0..24u16)
            .find(|row| flush_line(&cells, 80, *row).starts_with(prefix))
            .unwrap_or_else(|| panic!("no rail row starts with {prefix:?}"))
    };
    let ongoing = row_of("  Ongoing");
    let later = row_of("  Later");
    let buffer = draw_buffer(&app, 80, 24);
    assert!(
        buffer[(2, ongoing)]
            .style()
            .add_modifier
            .contains(Modifier::BOLD),
        "the focused cycle limb is bold"
    );
    assert!(
        !buffer[(2, later)]
            .style()
            .add_modifier
            .contains(Modifier::BOLD),
        "a non-focused cycle limb is not bold"
    );
}

/// The milestone the rail marks active is the focused one, only in the
/// Milestones mode, and the row is drawn bold.
#[test]
fn active_milestone_limb_is_marked_and_drawn_bold() {
    let (_tmp, mut app) = make_app();
    let planner =
        crate::planning::Planner::from_config(app.store.config.clone(), app.project_root());
    planner
        .create_milestone_file("Backlog", None, None)
        .unwrap();
    planner.create_milestone_file("Q4", None, None).unwrap();

    // Config's milestones section shares the cursor but is not the F5 mode.
    app.open_settings(None);
    app.config_set_section(ConfigSection::Milestones);
    assert_eq!(app.active_milestone_name(), None);

    app.switch_top_mode(TopMode::Milestones).unwrap();
    assert_eq!(app.active_milestone_name().as_deref(), Some("Backlog"));
    let milestone_node = |app: &App| {
        app.nav_tree()
            .into_iter()
            .find(|node| node.mode == TopMode::Milestones)
            .expect("the Milestones trunk exists")
    };
    let marked: Vec<String> = milestone_node(&app)
        .branches
        .iter()
        .filter(|branch| branch.active)
        .map(|branch| branch.label.clone())
        .collect();
    assert_eq!(marked, vec!["Backlog".to_string()]);

    let cells = draw_board(&app, 80, 24);
    let row_of = |prefix: &str| {
        (0..24u16)
            .find(|row| flush_line(&cells, 80, *row).starts_with(prefix))
            .unwrap_or_else(|| panic!("no rail row starts with {prefix:?}"))
    };
    let backlog = row_of("  Backlog");
    let q4 = row_of("  Q4");
    let buffer = draw_buffer(&app, 80, 24);
    assert!(
        buffer[(2, backlog)]
            .style()
            .add_modifier
            .contains(Modifier::BOLD),
        "the focused milestone limb is bold"
    );
    assert!(
        !buffer[(2, q4)]
            .style()
            .add_modifier
            .contains(Modifier::BOLD),
        "a non-focused milestone limb is not bold"
    );

    // Moving the cursor moves the bold row with it.
    app.handle_key(press(KeyCode::Down)).unwrap();
    assert_eq!(app.active_milestone_name().as_deref(), Some("Q4"));
}

/// The Cycle mode's flat table lists exactly the focused cycle's issues
/// (and no others), each row a click target that opens the issue.
#[test]
fn cycle_mode_lists_the_focused_cycles_issues_and_opens_them() {
    let (_tmp, mut app) = make_cycle_app();
    app.activate_branch(&Action::SelectCycle("Historical".into()))
        .unwrap();
    let _ = draw_board(&app, 100, 30);
    assert_eq!(open_issue_regions(&app), vec!["alice/2026-01-03-old.md"]);

    // A cycle with no issues says so rather than drawing an empty box: the
    // fixture's `Later` cycle has none.
    let (_tmp, mut app) = make_cycle_app();
    app.activate_branch(&Action::SelectCycle("Later".into()))
        .unwrap();
    let cells = draw_board(&app, 100, 30);
    assert_eq!(open_issue_regions(&app), [] as [std::string::String; 0]);
    assert!(
        cells.concat().contains("No issues."),
        "an empty cycle says so"
    );

    let (_tmp, mut app) = make_cycle_app();
    app.activate_branch(&Action::SelectCycle("Ongoing".into()))
        .unwrap();
    let cells = draw_board(&app, 100, 30);
    assert_eq!(
        open_issue_regions(&app),
        vec![
            "alice/2026-01-01-done.md".to_string(),
            "alice/2026-01-02-open.md".to_string(),
        ],
        "exactly the Ongoing issues, and not Historical's"
    );
    let text = cells.concat();
    assert!(
        text.contains("issues — Ongoing"),
        "the table is titled: {text:?}"
    );
    assert!(text.contains("Issue 1") && text.contains("Issue 2"));
    assert!(
        !text.contains("Issue 3"),
        "another cycle's issue is not listed"
    );

    // A row is a click region resolving to its `OpenIssue`, hovers, and opens.
    let (region, filename) = {
        let regions = app.frame_hit_regions.borrow();
        let region = regions
            .iter()
            .find(|region| region.action == Action::OpenIssue("alice/2026-01-02-open.md".into()))
            .expect("the open issue recorded a click region");
        (region.rect, "alice/2026-01-02-open.md".to_string())
    };
    let _ = app.handle_mouse(moved_to(region.x + 1, region.y)).unwrap();
    assert!(
        app.is_hovered(&Action::OpenIssue(filename.clone())),
        "the hovered table row reads as hovered"
    );

    let action = app.handle_mouse(down_left(region.x + 1, region.y)).unwrap();
    assert_eq!(action, Action::OpenIssue(filename.clone()));
    app.open_issue_by_filename(&filename).unwrap();
    assert!(matches!(app.mode, Mode::Detail), "the row opens the issue");
    assert_eq!(app.detail.as_ref().unwrap().issue.number, 2);
}

/// The Milestones mode reuses the same table for the focused milestone.
#[test]
fn milestones_mode_lists_the_focused_milestones_issues_and_opens_them() {
    let (tmp, mut app) = make_app();
    let planner =
        crate::planning::Planner::from_config(app.store.config.clone(), app.project_root());
    planner
        .create_milestone_file("Backlog", None, None)
        .unwrap();
    planner.create_milestone_file("Q4", None, None).unwrap();
    let dir = tmp.path().join("issues");
    write_planning_issue(
        &dir,
        "2026-01-01-backlog.md",
        1,
        "Backlog work",
        "todo",
        &[],
        &["Backlog"],
    );
    write_planning_issue(&dir, "2026-01-02-q4.md", 2, "Q4 work", "todo", &[], &["Q4"]);
    app.handle_key(press(KeyCode::F(5))).unwrap();

    let cells = draw_board(&app, 100, 30);
    assert_eq!(open_issue_regions(&app), vec!["2026-01-01-backlog.md"]);
    let text = cells.concat();
    assert!(
        text.contains("issues — Backlog"),
        "the table is titled: {text:?}"
    );
    assert!(text.contains("Backlog work") && !text.contains("Q4 work"));

    // Moving to the next milestone re-points the table.
    app.handle_key(press(KeyCode::Down)).unwrap();
    let _ = draw_board(&app, 100, 30);
    assert_eq!(open_issue_regions(&app), vec!["2026-01-02-q4.md"]);

    let (region, filename) = {
        let regions = app.frame_hit_regions.borrow();
        let region = regions
            .iter()
            .find(|region| region.action == Action::OpenIssue("2026-01-02-q4.md".into()))
            .expect("the Q4 issue recorded a click region");
        (region.rect, "2026-01-02-q4.md".to_string())
    };
    let _ = app.handle_mouse(moved_to(region.x + 1, region.y)).unwrap();
    assert!(app.is_hovered(&Action::OpenIssue(filename.clone())));

    let action = app.handle_mouse(down_left(region.x + 1, region.y)).unwrap();
    assert_eq!(action, Action::OpenIssue(filename.clone()));
    app.open_issue_by_filename(&filename).unwrap();
    assert!(matches!(app.mode, Mode::Detail));
    assert_eq!(app.detail.as_ref().unwrap().issue.number, 2);
}

/// The rail is reachable and operable by keyboard: `h`/`Left` focus it when
/// the mode has no leftward target, `j`/`k` walk trunk and limb rows, and
/// `Enter` activates the focused row.
#[test]
fn rail_focus_walks_rows_and_activates_trunks_and_limbs() {
    let (_tmp, mut app) = make_branchy_app();
    let rows = app.nav_rows();
    let board_trunk = rows
        .iter()
        .position(|action| *action == Action::SwitchMode(TopMode::Board))
        .expect("the Board trunk is a rail row");

    // The board starts at its left edge, so `h` has no leftward target and
    // enters the rail on the Board trunk.
    let _ = app.handle_key(press(KeyCode::Char('h'))).unwrap();
    assert_eq!(app.nav_focus_index(), Some(board_trunk));

    // `j`/`k` walk trunk and limb rows.
    let _ = app.handle_key(press(KeyCode::Char('j'))).unwrap();
    assert_eq!(app.nav_focus_index(), Some(board_trunk + 1));
    assert_eq!(
        app.nav_rows()[board_trunk + 1],
        Action::SelectBoard("default".into())
    );
    let _ = app.handle_key(press(KeyCode::Up)).unwrap();
    assert_eq!(app.nav_focus_index(), Some(board_trunk));

    // Enter on a limb runs the limb's action (switch to `release`) and hands
    // the keyboard to the opened content.
    let _ = app.handle_key(press(KeyCode::Char('j'))).unwrap();
    let _ = app.handle_key(press(KeyCode::Char('j'))).unwrap();
    assert_eq!(
        app.nav_rows()[board_trunk + 2],
        Action::SelectBoard("release".into())
    );
    let _ = app.handle_key(press(KeyCode::Enter)).unwrap();
    assert_eq!(app.active_board_name(), "release");
    assert_eq!(app.top_mode, TopMode::Board);
    assert_eq!(
        app.nav_focus_index(),
        None,
        "Enter opens the row and moves the keyboard right"
    );
}

/// Every rail row — trunk and limb — highlights under the pointer.
#[test]
fn hovering_a_trunk_and_a_limb_row_highlights_each() {
    let (_tmp, mut app) = make_branchy_app();
    app.nav_display = NavDisplay::Default;
    let _ = draw_board(&app, 80, 24);

    // Row 0 is the New Issue trunk.
    let _ = app.handle_mouse(moved_to(0, 0)).unwrap();
    assert!(app.is_hovered(&Action::SwitchMode(TopMode::NewIssue)));
    let buffer = draw_buffer(&app, 80, 24);
    assert_eq!(
        buffer[(0, 0)].style().bg,
        Some(Color::DarkGray),
        "the hovered trunk is highlighted"
    );

    // Row 1 is the `bug` template limb.
    let _ = app.handle_mouse(moved_to(2, 1)).unwrap();
    assert!(app.is_hovered(&Action::NewFromTemplate("bug".into())));
    let buffer = draw_buffer(&app, 80, 24);
    assert_eq!(
        buffer[(2, 1)].style().bg,
        Some(Color::DarkGray),
        "the hovered limb is highlighted"
    );
}