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
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
//! TODOs activity-bar panel — surfaces `TODO` / `FIXME` / `XXX` /
//! `HACK` / `REVIEW` markers found in source-code comments across
//! the workspace. (#9)
//!
//! v1 scope: workspace-wide scan on activation + rescan via
//! `todos.refresh`. One row per hit: `TAG path:line title`.
//! Click → jump to the file at that line. Deletion / test-tags /
//! `.mnml/notes/` markdown checkbox integration are follow-ups.
//!
//! TODO (user ask, raised 2026-09-01 and again 2026-09-03: "what
//! happened to having tree sort on todos?") — a TREE view mode that
//! groups hits under their directory, collapsible, instead of the flat
//! list. It was discussed and queued but never started; this note is
//! so it stops being invisible.
//!
//! It does NOT belong in `ui::list_sort::ListSort`. Every mode there
//! is an ORDER over one flat list, and all three panels share them.
//! Grouping changes the SHAPE of the list — it adds header rows,
//! collapse state, and a second axis of navigation — so it wants its
//! own toggle beside the `sort:` chip (a `view:` chip, matching CLOUD
//! AGENTS), not a fourth sort mode. Folding it into ListSort would
//! force NOTES and FINDINGS to grow a tree they have no directory
//! structure for.
//!
//! Reuse `ui::tree_connectors` for the branch glyphs so the grouping
//! reads like the file tree rather than a second tree idiom.
use ratatui::{
Frame,
layout::Rect,
style::{Modifier, Style},
text::{Line, Span},
widgets::{Block, Paragraph},
};
use crate::app::App;
use crate::ui::theme;
/// One found marker. Populated by `App::todos_panel_refresh`.
#[derive(Debug, Clone)]
pub struct TodoHit {
pub tag: &'static str,
pub path: std::path::PathBuf,
pub line: u32,
pub title: String,
}
/// Marker patterns scanned in comments. Case-sensitive, matched
/// followed by non-alphanumeric so `TODOLIST` doesn't false-trip.
pub const MARKERS: &[&str] = &["TODO", "FIXME", "XXX", "HACK", "REVIEW"];
pub fn draw(frame: &mut Frame, app: &mut App, area: Rect) {
let t = theme::cur();
let bg = t.bg_darker;
frame.render_widget(Block::default().style(Style::default().bg(bg)), area);
if area.height < 2 || area.width < 8 {
return;
}
app.rects.todos_panel_rows.clear();
app.rects.todos_panel_refresh_chip = None;
app.rects.todos_panel_filter_input = None;
app.rects.todos_panel_kebab = None;
app.rects.todos_panel_new_chip = None;
// Trigger a background rescan the first time this panel appears
// in a session (todos_hits is empty and no scan yet).
if !app.todos_panel_scanned_once {
app.todos_panel_scanned_once = true;
app.todos_panel_refresh();
}
// Apply the `/`-filter to the hit list — matches tag, path, or
// title case-insensitively. Filter row is drawn between the
// section header and the results (parity with HTTP / Agents).
let filter_lc = app.todos_panel_filter.to_ascii_lowercase();
let filtered: Vec<(usize, &TodoHit)> = app
.todos_hits
.iter()
.enumerate()
.filter(|(_, hit)| {
if filter_lc.is_empty() {
return true;
}
hit.tag.to_ascii_lowercase().contains(&filter_lc)
|| hit
.path
.to_string_lossy()
.to_ascii_lowercase()
.contains(&filter_lc)
|| hit.title.to_ascii_lowercase().contains(&filter_lc)
})
.collect();
// 2026-08-24 (user ask) — TODOS header now sits alongside a
// right-aligned ↻ Refresh chip (was a bottom-of-panel
// "Rescan" row that didn't match the git-panel refresh idiom
// a scroll away). Routed through the shared
// `panel_chrome::draw_caps_header_with_refresh` helper so
// every future panel that wants a refresh chip gets the same
// shape.
// 2026-08-24 (user ask) — always show a count-in-parens
// (parity with FINDINGS): total when unfiltered, `M of N`
// when a filter narrows it.
// A `+` marks a capped scan: the number is a floor, not a total,
// and the sort order describes only what was scanned.
let cap = if app.todos_truncated { "+" } else { "" };
let subtitle = if filter_lc.is_empty() {
format!(" ({}{cap})", app.todos_hits.len())
} else {
format!(" ({} of {}{cap})", filtered.len(), app.todos_hits.len())
};
// The `sort:` chip is the same idiom as CLOUD AGENTS' `view:`
// chip — click cycles, right-click lists every mode with a ✓ on
// the current one.
// Pad to the widest mode label so the chip keeps a fixed width and
// cannot slide out from under a repeat-clicking pointer.
let sort_widest = crate::ui::list_sort::ListSort::all()
.iter()
.map(|m| m.label().chars().count())
.max()
.unwrap_or(0);
let sort_chip = crate::ui::panel_chrome::mode_chip_text(
"sort",
app.panel_sort("todos").label(),
sort_widest,
);
let (todos_sort, todos_refresh) = crate::ui::panel_chrome::draw_caps_header_with_chips(
frame,
Rect {
x: area.x,
y: area.y,
width: area.width,
height: 1,
},
"TODOS",
Some(&subtitle),
Some(&sort_chip),
bg,
&t,
app.config.ui.ascii_icons,
);
app.rects.todos_panel_sort_chip = todos_sort;
app.rects.todos_panel_refresh_chip = todos_refresh;
// Filter row (row 1). Matches `http_panel::draw` visual — chip
// background, magnifier glyph, `/ filter` placeholder, `▏` cursor
// when focused.
{
let y_filter = area.y + 1;
if y_filter < area.y + area.height {
let focused = app.todos_panel_filter_focused;
let bg_chip = crate::ui::panel_chrome::filter_chip_bg(&t);
let fg_chip = if app.todos_panel_filter.is_empty() && !focused {
t.comment
} else {
t.fg
};
let display = if app.todos_panel_filter.is_empty() {
crate::ui::filter_placeholder::for_state(focused).to_string()
} else {
app.todos_panel_filter.clone()
};
let cursor = if focused { "\u{258F}" } else { " " };
let pad = (area.width as usize).saturating_sub(3 + display.chars().count() + 1 + 1);
let line = Line::from(vec![
Span::styled(" ", Style::default().bg(bg)),
Span::styled(
format!("{} ", crate::ui::search_glyph::NERD),
Style::default().fg(t.comment).bg(bg_chip),
),
Span::styled(display, Style::default().fg(fg_chip).bg(bg_chip)),
Span::styled(cursor, Style::default().fg(t.cyan).bg(bg_chip)),
Span::styled(" ".repeat(pad), Style::default().bg(bg_chip)),
Span::styled(" ", Style::default().bg(bg)),
]);
let row_rect = Rect {
x: area.x,
y: y_filter,
width: area.width,
height: 1,
};
frame.render_widget(Paragraph::new(line), row_rect);
app.rects.todos_panel_filter_input = Some(row_rect);
}
}
// `+ New todo` occupies the row that was deliberately left blank
// for want of a CTA — the same reasoning that gave FINDINGS its
// chip. TODOS was then the only list panel with no way to create
// anything.
//
// 2026-09-03 (user: "the first todo shobund start 1 line down") —
// adding the chip ate the panel's only spacer, so the first row
// butted straight against a filled green chip. NOTES and FINDINGS
// both put their chip on `+2` and start their list on `+4`, keeping
// a blank row between; TODOS was starting on `+3`. Now all three
// agree.
let y = area.y + 2;
if y < area.y + area.height {
let label = "+ New todo";
let chip_w = crate::ui::action_button::chip_width(label);
let avail = area.width.saturating_sub(1);
let new_rect = Rect {
x: area.x + 1,
y,
width: chip_w.min(avail),
height: 1,
};
frame.render_widget(
Paragraph::new(crate::ui::action_button::chip_line(
label,
crate::ui::action_button::primary(&t),
)),
new_rect,
);
app.rects.todos_panel_new_chip = Some(new_rect);
}
// +2, not +1: one row for the chip itself, one blank spacer under
// it. Both the empty-state hint and the list start here, so they
// stay aligned with the `area.y + 4` geometry below.
let mut y = y + 2;
if app.todos_hits.is_empty() {
// Interpolate the same glyph the header refresh chip uses
// so the hint stays in sync in every mode.
let ascii = app.config.ui.ascii_icons;
let hint_msg = format!(
"No markers found — click {} in the header to rescan.",
crate::ui::refresh_glyph::for_ascii(ascii)
);
frame.render_widget(
Paragraph::new(Line::from(vec![
Span::styled(" ", Style::default().bg(bg)),
Span::styled(hint_msg, Style::default().fg(t.comment).bg(bg)),
])),
Rect {
x: area.x,
y,
width: area.width,
height: 1,
},
);
y += 1;
frame.render_widget(
Paragraph::new(Line::from(vec![
Span::styled(" ", Style::default().bg(bg)),
Span::styled(
"Scans for TODO / FIXME / XXX / HACK / REVIEW.",
Style::default()
.fg(t.comment)
.bg(bg)
.add_modifier(Modifier::DIM),
),
])),
Rect {
x: area.x,
y,
width: area.width,
height: 1,
},
);
y += 2;
} else if filtered.is_empty() {
crate::ui::empty_state::draw(
frame,
Rect {
x: area.x,
y,
width: area.width,
height: area.height.saturating_sub(y - area.y),
},
"No matches — Esc clears",
None,
bg,
&t,
);
y += 2;
} else {
// Clamp the cursor to the filtered length so a stale
// cursor after a filter narrows doesn't paint nothing.
let clamped_cursor = app.todos_panel_cursor.min(filtered.len().saturating_sub(1));
app.todos_panel_cursor = clamped_cursor;
// Content begins at `area.y + 4`, so FOUR rows are chrome:
// header, filter, `+ New todo` chip, spacer. The budget must
// match the start row exactly — reserving fewer rows than the
// chrome actually occupies runs the list past the bottom
// border; reserving more stops it short and makes a full panel
// look like the end of the list.
let visible_rows = (area.height as usize).saturating_sub(4);
let mut scroll = app.todos_panel_scroll;
let (first, shown, needs_sb) = crate::ui::panel_chrome::list_scroll_window(
&mut scroll,
clamped_cursor,
filtered.len(),
visible_rows,
);
app.todos_panel_scroll = scroll;
// Leave a column for the scrollbar only when one is needed.
let row_w = if needs_sb {
area.width.saturating_sub(1)
} else {
area.width
};
for (row_i, (idx, hit)) in filtered.iter().copied().enumerate().skip(first).take(shown) {
if y >= area.y + area.height {
break;
}
let is_focused_row = row_i == clamped_cursor;
let row_bg = if is_focused_row { t.bg2 } else { bg };
let rel = hit
.path
.strip_prefix(&app.workspace)
.unwrap_or(&hit.path)
.to_string_lossy()
.into_owned();
let tag_fg = match hit.tag {
"TODO" => t.blue,
"FIXME" => t.orange,
"XXX" | "HACK" => t.red,
"REVIEW" => t.purple,
_ => t.comment,
};
let row_rect = Rect {
x: area.x,
y,
width: row_w,
height: 1,
};
let path_line = format!(" {rel}:{}", hit.line);
// Budget the text against the ROW WIDTH, not a fixed 40
// characters. The old constant meant a long path pushed the
// title straight through the right border (user report:
// "the todos area has same issue where text goes to the
// right all the way up against the border").
//
// `RIGHT_PAD` is the blank cell the user asked for; the
// kebab is drawn over the row's right edge on the focused
// row, so it needs that gap too.
// 2 cells for the kebab + 1 blank between it and the last
// character of the row (user ask). Measured against `row_w`,
// not `area.width`, so the scrollbar column is excluded.
const KEBAB_W: usize = 2;
const RIGHT_PAD: usize = KEBAB_W + 1;
const MIN_TITLE: usize = 8;
let budget = (row_w as usize).saturating_sub(RIGHT_PAD);
let lead = 2 + hit.tag.chars().count() + 1;
// Clip the path first if it alone would fill the row, so a
// deep path can never squeeze the title out entirely.
let path_budget = budget.saturating_sub(lead + MIN_TITLE);
let path_line: String = if path_line.chars().count() > path_budget {
let keep = path_budget.saturating_sub(1);
path_line.chars().take(keep).collect::<String>() + "\u{2026}"
} else {
path_line
};
let title_budget = budget.saturating_sub(lead + path_line.chars().count());
let title: String = hit.title.chars().take(title_budget.min(40)).collect();
// Pad the highlight across to the kebab.
//
// The band used to close one cell past the title, which was
// right until the actions kebab appeared at the row's right
// edge — then a focused row read as a highlighted stretch, a
// dead gap, and a floating kebab. The row's content now ends
// AT the kebab, so the band runs to it (user report).
//
// `- 2` leaves the kebab's own two cells, which paint with
// the same background, so the run is continuous.
let used =
2 + hit.tag.chars().count() + path_line.chars().count() + 1 + title.chars().count();
// The band still runs the full row width — only the TEXT
// stops short. Subtracting RIGHT_PAD here too would reopen
// the dead gap between the text and the kebab that the
// 2026-08 fix closed.
let pad = (row_w as usize).saturating_sub(used);
frame.render_widget(
Paragraph::new(Line::from(vec![
// The selection highlight is INSET by one cell rather
// than running to the panel edge, and closes one cell
// past the last character. It used to start at column
// 0, so a focused row read as a full-width band
// welded to the panel's left edge (user report).
//
// Text still begins at column 2, matching FINDINGS /
// NOTES list rows and this panel's own hint rows —
// the first of those two cells is simply outside the
// highlight now.
// Two unhighlighted cells, then the band. Matches
// FINDINGS / NOTES at 3 cells to the text.
Span::styled(" ", Style::default().bg(bg)),
// The focused row's accent bar. mnml marks a selected
// row with a blue `▌` everywhere else it has one —
// the palette picker, the activity bar, the sessions
// panel, the Claude accounts view. This panel
// RESERVED the column but never painted the bar, so
// the only cue was a background shift, and the gutter
// read as empty space (user report: "when i think
// gutter i was thinking vertical COLORED bar like we
// do in sessions view").
Span::styled(
crate::ui::gutter::marker(is_focused_row),
Style::default().fg(t.green).bg(row_bg),
),
Span::styled(
hit.tag,
Style::default()
.fg(tag_fg)
.bg(row_bg)
.add_modifier(Modifier::BOLD),
),
Span::styled(path_line, Style::default().fg(t.comment).bg(row_bg)),
Span::styled(" ", Style::default().bg(row_bg)),
Span::styled(title, Style::default().fg(t.fg).bg(row_bg)),
// Runs to the kebab rather than stopping at the
// text — see `pad` above.
Span::styled(" ".repeat(pad), Style::default().bg(row_bg)),
])),
row_rect,
);
// The FILTERED position, not the index into `todos_hits`.
// `todos_panel_cursor` indexes the filtered list, so storing
// the raw index made a click set the cursor to a different
// TODO than the one clicked whenever a filter was active.
let _ = idx;
// Actions kebab, focused row only — the hover-reveal idiom
// the `+` menu uses. Visible when you are on the row, no
// marker repeated down all thirty-nine, and it leaves the
// other rows their full width for the path.
if is_focused_row && area.width > 4 {
let kr = Rect {
// `row_w`, not `area.width` — with a scrollbar
// present the kebab was painting ON the bar.
x: area.x + row_w - KEBAB_W as u16,
y,
width: KEBAB_W as u16,
height: 1,
};
frame.render_widget(
Paragraph::new(Line::from(Span::styled(
if app.config.ui.ascii_icons {
": "
} else {
"\u{22ee} "
},
Style::default().fg(t.comment).bg(row_bg),
))),
kr,
);
app.rects.todos_panel_kebab = Some((kr, row_i));
}
app.rects.todos_panel_rows.push((row_rect, row_i));
y += 1;
}
// Without this the panel simply stopped at the last drawn row —
// no bar, no cue — so a list twice the panel height read as the
// whole list (user: "it says 93 but it stops ... this makes me
// think there are no more to see").
// Content rect, so a wheel event over the list can be routed
// to this panel's scroll offset.
app.rects.todos_panel_area = Some(Rect {
x: area.x,
y: area.y + 4,
width: area.width,
height: visible_rows as u16,
});
if needs_sb {
let sb = Rect {
x: area.x + row_w,
y: area.y + 4,
width: 1,
height: visible_rows as u16,
};
crate::ui::scrollbar::paint_simple_scrollbar(
frame,
sb,
&t,
filtered.len(),
visible_rows,
first,
);
app.rects.scrollbars.push(crate::app::ScrollbarHit {
area: sb,
pane_id: 0,
total: filtered.len(),
viewport: visible_rows,
kind: crate::app::ScrollbarKind::TodosPanel,
});
}
y += 1;
}
// 2026-08-24 (user ask) — Rescan chip moved from a bottom-of-
// panel row into the top-right of the TODOS caps header via
// `panel_chrome::draw_caps_header_with_refresh` so it lines up
// with the git panel's refresh chip a scroll away. The rect
// now populates from the header helper above.
let _ = y;
}
/// Grab the first double-quoted or single-quoted string on the
/// slice — the Playwright/Jest test title when the modifier call
/// looks like `.fixme("title", async ({ page }) => …)`.
fn extract_first_quoted(s: &str) -> Option<String> {
let mut chars = s.char_indices().peekable();
while let Some((i, c)) = chars.next() {
if c == '"' || c == '\'' {
let quote = c;
let start = i + c.len_utf8();
for (j, cc) in chars.by_ref() {
if cc == quote {
return Some(s[start..j].chars().take(120).collect());
}
}
return None;
}
}
None
}
/// Playwright/Jest test-modifier markers picked up in `.spec.ts`,
/// `.test.ts`, `.spec.js`, `.test.js`. These are call-site tokens
/// (`test.fixme(...)`, `test.fail(...)`, `test.skip(...)`) that
/// tag a test as pending / expected-to-fail / disabled — user
/// feedback: they belong in the TODOs surface even though they're
/// not in a comment.
const TEST_MODIFIER_MARKERS: &[&str] = &["fixme", "fail", "skip"];
fn is_playwright_test_file(path: &std::path::Path) -> bool {
let name = path
.file_name()
.and_then(|s| s.to_str())
.unwrap_or_default();
name.ends_with(".spec.ts")
|| name.ends_with(".test.ts")
|| name.ends_with(".spec.js")
|| name.ends_with(".test.js")
}
/// Scan a file for marker patterns in comments. Cheap enough per
/// file for a workspace-wide scan (~200 typical), but skips large
/// files, binaries, and generated dirs.
pub fn scan_file(path: &std::path::Path) -> Vec<TodoHit> {
let Ok(meta) = std::fs::metadata(path) else {
return Vec::new();
};
if meta.len() > 1024 * 1024 {
return Vec::new(); // skip huge files
}
let Ok(content) = std::fs::read_to_string(path) else {
return Vec::new(); // non-UTF-8 → binary → skip
};
let is_markdown = path
.extension()
.and_then(|e| e.to_str())
.is_some_and(|e| e.eq_ignore_ascii_case("md") || e.eq_ignore_ascii_case("markdown"));
let mut out = Vec::new();
let scan_test_modifiers = is_playwright_test_file(path);
for (i, line) in content.lines().enumerate() {
// Playwright/Jest test modifiers first — `.fixme(` / `.fail(`
// / `.skip(` are call-site tokens, not comment markers, so
// they get their own detection path per line. FIXME wins
// (higher-severity mapping) if both match.
if scan_test_modifiers {
let mut matched = false;
for &modifier in TEST_MODIFIER_MARKERS {
let needle = format!(".{modifier}(");
if let Some(pos) = line.find(&needle) {
let tag: &'static str = match modifier {
"fixme" => "FIXME",
"fail" => "XXX",
"skip" => "REVIEW",
_ => continue,
};
let after = pos + needle.len();
// Grab the test title if the call is
// `.fixme("title", …)` — first quoted string on
// the same line.
let title = extract_first_quoted(&line[after..])
.unwrap_or_else(|| format!(".{modifier}(...)"));
out.push(TodoHit {
tag,
path: path.to_path_buf(),
line: (i + 1) as u32,
title,
});
matched = true;
break;
}
}
if matched {
continue;
}
}
for &tag in MARKERS {
if let Some(pos) = line.find(tag) {
// Rough "is this in a comment?" heuristic: at least
// one comment char (`//`, `#`, `/*`, `--`, `<!--`)
// appears BEFORE the marker on the same line.
let prefix = &line[..pos];
let looks_like_comment = prefix.contains("//")
|| prefix.contains('#')
|| prefix.contains("/*")
|| prefix.contains("--")
|| prefix.contains("<!--");
// MARKDOWN has no code comments — a `- TODO: …` line in
// prose IS the item, and requiring a comment char meant
// a whole TODO.md scanned to a single hit: the `#` in
// its own title heading. Accept a marker preceded only
// by list / heading / quote punctuation.
//
// Still anchored to the START of the line, so a passing
// mention of TODO mid-sentence is not collected.
let markdown_item = is_markdown
&& prefix
.trim_start_matches(|c: char| {
c.is_whitespace()
|| c.is_ascii_digit()
|| matches!(c, '-' | '*' | '+' | '#' | '>' | '.' | ')' | '[' | ']')
})
.is_empty();
if !looks_like_comment && !markdown_item {
continue;
}
// Confirm word-boundary on the right so `TODOLIST`
// doesn't match `TODO`.
let after = line[pos + tag.len()..].chars().next();
if let Some(c) = after
&& (c.is_alphanumeric() || c == '_')
{
continue;
}
let title: String = line[pos + tag.len()..]
.trim_start_matches([':', '(', ')', ' '])
.trim()
.chars()
.take(120)
.collect();
out.push(TodoHit {
tag,
path: path.to_path_buf(),
line: (i + 1) as u32,
title,
});
break; // one marker per line
}
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
/// BUG-HUNT 2026-09-03 — the TODOS walk stops at 1000 markers, so
/// which ones exist is decided by raw `read_dir` order. A workspace
/// with 3043 markers showed 1102, and filtering for a package with
/// 100 of them returned zero. Every sort mode then orders an
/// arbitrary subset — "Oldest first" is not the oldest in the
/// workspace, it is the oldest of whatever the walk happened to
/// reach.
///
/// The cap itself is right (it bounds a recursive scan). Being
/// SILENT about it is not.
#[test]
fn a_capped_scan_says_so_in_the_header() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = (0..crate::app::workspace_methods::TODOS_SCAN_CAP)
.map(|i| TodoHit {
tag: "TODO",
path: d.path().join(format!("f{i}.rs")),
line: 1,
title: "x".into(),
})
.collect();
let render = |app: &mut crate::app::App| -> String {
let (w, h) = (80u16, 12u16);
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
term.draw(|f| {
draw(
f,
app,
Rect {
x: 0,
y: 0,
width: w,
height: h,
},
)
})
.unwrap();
let buf = term.backend().buffer();
(0..w).map(|x| buf[(x, 0)].symbol()).collect()
};
app.todos_truncated = true;
let capped = render(&mut app);
assert!(
capped.contains("(1000+)"),
"a capped scan reports a plain total, so the count reads as \
complete: {capped:?}"
);
// And an uncapped scan must NOT wear the marker, or it means
// nothing.
app.todos_truncated = false;
let full = render(&mut app);
assert!(
full.contains("(1000)") && !full.contains("(1000+)"),
"an uncapped scan was marked as capped: {full:?}"
);
}
/// USER REPORT 2026-09-03 — "the first todo shobund start 1 line
/// down". Adding the `+ New todo` chip consumed the panel's only
/// spacer row, so the first row butted straight against a filled
/// green chip. NOTES and FINDINGS both keep a blank row there.
///
/// Asserts the SPACER, not a magic row number: the row directly
/// under the chip must be empty, and the first list row must come
/// after it.
#[test]
fn a_blank_row_separates_the_new_chip_from_the_first_row() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = vec![TodoHit {
tag: "REVIEW",
path: d.path().join("a.rs"),
line: 1,
title: "x".into(),
}];
let w = 80u16;
let mut term = Terminal::new(TestBackend::new(w, 12)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: w,
height: 12,
},
)
})
.unwrap();
let buf = term.backend().buffer();
let rows: Vec<String> = (0..12u16)
.map(|y| (0..w).map(|x| buf[(x, y)].symbol()).collect())
.collect();
let chip_y = rows
.iter()
.position(|r| r.contains("New todo"))
.expect("the + New todo chip did not render");
let row_y = rows
.iter()
.position(|r| r.contains("REVIEW"))
.expect("the list row did not render");
assert!(
rows[chip_y + 1].trim().is_empty(),
"no spacer under the chip — row {} reads {:?}",
chip_y + 1,
rows[chip_y + 1].trim()
);
assert_eq!(
row_y,
chip_y + 2,
"the first row is not one line below the spacer"
);
}
/// User report — the focused row's highlight started at column 0, so
/// it read as a full-width band welded to the panel's left edge; and
/// once the actions kebab appeared at the right edge, closing the
/// band just past the title left a dead gap with a floating kebab
/// beyond it. It should be inset one cell on the left and run
/// CONTINUOUSLY to the kebab on the right.
#[test]
fn the_focused_rows_highlight_is_inset_and_runs_to_the_kebab() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = vec![TodoHit {
tag: "TODO",
path: d.path().join("a.rs"),
line: 1,
title: "x".into(),
}];
let w = 80u16;
let mut term = Terminal::new(TestBackend::new(w, 12)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: w,
height: 12,
},
)
})
.unwrap();
let buf = term.backend().buffer();
let panel_bg = theme::cur().bg_darker;
let hl = theme::cur().bg2;
let mut row_y = None;
for y in 0..12u16 {
let line: String = (0..w).map(|x| buf[(x, y)].symbol()).collect();
if line.contains("TODO") && !line.contains("TODOS") {
row_y = Some(y);
break;
}
}
let y = row_y.expect("no list row rendered");
assert_eq!(
buf[(0, y)].bg,
panel_bg,
"column 0 is highlighted — the band still touches the panel edge"
);
assert_eq!(
buf[(1, y)].bg,
hl,
"the highlight does not start at column 1 — the list rows sit one \
cell in, so the accent lands under the filter row's magnifier"
);
// Continuous from column 1 through the kebab: no unhighlighted
// gap between the text and the kebab.
let gaps: Vec<u16> = (1..w - 1).filter(|&x| buf[(x, y)].bg != hl).collect();
assert!(
gaps.is_empty(),
"unhighlighted gap(s) at columns {gaps:?} — the band stops \
before the kebab instead of running to it"
);
// The kebab itself is inside the band, and is a click target.
assert!(
app.rects.todos_panel_kebab.is_some(),
"the focused row shows no actions kebab"
);
// The focused row carries the blue `▌` accent at column 2 — the
// selected-row idiom mnml uses in the palette picker, the
// activity bar and the sessions panel. The gutter column was
// reserved but never painted, so a focused row was distinguished
// only by its background: "when i think gutter i was thinking
// vertical COLORED bar like we do in sessions view".
assert_eq!(
buf[(1, y)].symbol(),
"▌",
"the focused row has no accent bar in its gutter"
);
assert_eq!(
buf[(1, y)].fg,
theme::cur().green,
"the accent bar is not the blue every other selected-row \
marker in mnml uses"
);
}
/// USER REPORT — after 9 items were appended to TODO.md the panel
/// count moved by ONE. "where are yours on this list, those 9".
///
/// `scan_file` required a comment character before the marker, so a
/// markdown list item (`- TODO: …`) never matched; the only hit in
/// a whole TODO.md was the `#` in its own title heading.
#[test]
fn markdown_list_items_are_collected_without_a_comment_char() {
let d = tempfile::tempdir().unwrap();
let f = d.path().join("TODO.md");
std::fs::write(
&f,
"# mnml TODO\n\n - TODO: first queued item\n - TODO: second queued item\n * FIXME: a starred one\n 1. TODO: a numbered one\n > TODO: a quoted one\n",
)
.unwrap();
let hits = scan_file(&f);
assert!(
hits.len() >= 6,
"markdown TODOs were skipped — only {} hit(s): {:?}",
hits.len(),
hits.iter().map(|h| h.title.clone()).collect::<Vec<_>>()
);
}
/// ...but a passing MENTION mid-sentence is still not an item, or
/// every doc discussing TODOs would flood the panel.
#[test]
fn a_mid_sentence_mention_in_markdown_is_not_collected() {
let d = tempfile::tempdir().unwrap();
let f = d.path().join("notes.md");
std::fs::write(
&f,
"The scanner looks for TODO markers in comments.\n Nothing here should be collected.\n",
)
.unwrap();
let hits = scan_file(&f);
assert!(
hits.is_empty(),
"a prose mention was collected as an item: {:?}",
hits.iter().map(|h| h.title.clone()).collect::<Vec<_>>()
);
}
/// Code files must be UNCHANGED — the comment requirement is what
/// stops `let todo = ...` from being collected there.
#[test]
fn code_files_still_require_a_comment_char() {
let d = tempfile::tempdir().unwrap();
let f = d.path().join("a.rs");
std::fs::write(
&f,
"let TODO_LIST = 1;\nlet x = \"TODO: not a comment\";\n// TODO: a real one\n",
)
.unwrap();
let hits = scan_file(&f);
assert_eq!(
hits.len(),
1,
"expected only the commented marker, got: {:?}",
hits.iter().map(|h| h.title.clone()).collect::<Vec<_>>()
);
}
/// USER ASK — "lets shorten from the right side these rows, this
/// should create 1 empty char on highlighted line between last char
/// and the kebab."
///
/// Also pins the kebab INSIDE the row: it was positioned from
/// `area.width`, so once a scrollbar took a column it painted on
/// top of the bar.
#[test]
fn the_focused_row_leaves_a_blank_cell_before_its_kebab() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = false;
app.todos_panel_scanned_once = true;
// Long titles so every row wants more width than it has, and
// enough of them to force a scrollbar.
app.todos_hits = (0..60)
.map(|i| TodoHit {
tag: "TODO",
path: d.path().join("CHANGELOG.md"),
line: 79,
title: format!("{i} a title far longer than the panel is wide, truly"),
})
.collect();
let (w, h) = (44u16, 16u16);
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: w,
height: h,
},
)
})
.unwrap();
let buf = term.backend().buffer();
let (kr, _) = app
.rects
.todos_panel_kebab
.expect("focused row has no kebab");
// A scrollbar IS present here (60 rows in 16), so the row is
// one cell narrower than the panel. `<= w` was too weak to
// catch the bug — it held with the kebab sitting exactly on
// the bar.
let sb = app
.rects
.scrollbars
.iter()
.find(|s| matches!(s.kind, crate::app::ScrollbarKind::TodosPanel))
.expect("setup: expected a scrollbar for 60 rows in 16");
assert!(
kr.x + kr.width <= sb.area.x,
"the kebab overlaps the scrollbar: kebab {kr:?}, bar at x={}",
sb.area.x
);
// The cell immediately left of the kebab must be blank.
let gap = buf[(kr.x - 1, kr.y)].symbol().to_string();
let row: String = (0..w).map(|x| buf[(x, kr.y)].symbol()).collect();
assert_eq!(
gap, " ",
"no blank cell between the row text and the kebab:\n{row:?}"
);
}
/// USER REPORT — "cant actually scroll though. tried mousewheel and
/// dragging scrollbar."
///
/// The panel had scroll STATE and painted a bar, but registered
/// neither a content rect (so wheel events could not be routed to
/// it) nor a `ScrollbarHit` (so the bar was paint-only, not a drag
/// target). Both absences are asserted here because both were
/// missing and either alone leaves the panel unscrollable by mouse.
#[test]
fn a_scrollable_panel_registers_its_wheel_area_and_scrollbar_hit() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = (0..90)
.map(|i| TodoHit {
tag: "TODO",
path: d.path().join(format!("f{i}.rs")),
line: 1,
title: format!("item{i}"),
})
.collect();
let (w, h) = (40u16, 20u16);
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: w,
height: h,
},
)
})
.unwrap();
let area = app
.rects
.todos_panel_area
.expect("no content rect — a wheel event over the list has nowhere to route");
assert!(area.height > 0, "content rect is zero-height: {area:?}");
let hit = app
.rects
.scrollbars
.iter()
.find(|s| matches!(s.kind, crate::app::ScrollbarKind::TodosPanel))
.expect("the scrollbar is paint-only — no drag target registered");
assert_eq!(hit.total, 90, "scrollbar reports the wrong total");
assert!(
hit.viewport > 0 && hit.viewport < hit.total,
"viewport {} vs total {} — a bar that cannot move",
hit.viewport,
hit.total
);
}
/// USER REPORT — "it says 93 but it stops 2 lines before the border
/// ... and no scrollbar. this makes me think there are no more to
/// see."
///
/// Two defects in one: the row budget reserved five chrome rows
/// when content starts three in, and there was NO SCROLL STATE at
/// all — everything past the first screenful was unreachable.
#[test]
fn a_long_list_fills_the_panel_and_shows_a_scrollbar() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = (0..90)
.map(|i| TodoHit {
tag: "TODO",
path: d.path().join(format!("f{i}.rs")),
line: 1,
title: format!("item{i}"),
})
.collect();
let (w, h) = (40u16, 20u16);
let render = |app: &mut crate::app::App| -> Vec<String> {
let mut term = Terminal::new(TestBackend::new(w, h)).unwrap();
term.draw(|f| {
draw(
f,
app,
Rect {
x: 0,
y: 0,
width: w,
height: h,
},
)
})
.unwrap();
let buf = term.backend().buffer();
(0..h)
.map(|y| (0..w).map(|x| buf[(x, y)].symbol()).collect::<String>())
.collect()
};
let rows = render(&mut app);
// Content starts at row 3, so rows 3..h-1 must all carry a TODO.
// The old budget left the last two blank, which is what made a
// full panel look like the end of the list.
let last = &rows[(h - 1) as usize];
assert!(
last.contains("TODO"),
"the bottom row of the panel is empty — the list stops short \
of the border:\n{last:?}"
);
// A list this long must advertise that there is more.
let painted: String = rows.join("");
assert!(
painted.contains('\u{2588}')
|| painted.contains('\u{2593}')
|| painted.contains('\u{2502}'),
"no scrollbar painted for 90 items in a 20-row panel"
);
// ...and the cursor must be able to REACH the end.
for _ in 0..89 {
app.todos_panel_cursor_down();
}
let rows = render(&mut app);
assert!(
rows.iter().any(|r| r.contains("item89")),
"the last item is unreachable — the panel never scrolled"
);
}
/// USER REPORT — "the todos area has same issue where text goes to
/// the right all the way up against the border."
///
/// The title was clipped to a fixed 40 chars regardless of panel
/// width, so a long path pushed the row straight through the edge.
#[test]
fn a_long_row_keeps_a_blank_cell_before_the_right_border() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true;
app.todos_hits = vec![TodoHit {
tag: "REVIEW",
path: d.path().join("src/app/a_very_deeply_nested_module_path.rs"),
line: 1998,
title: "a title long enough to run past any sane panel width".into(),
}];
// Narrow, like the real activity panel.
let w = 34u16;
let mut term = Terminal::new(TestBackend::new(w, 12)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: w,
height: 12,
},
)
})
.unwrap();
let buf = term.backend().buffer();
let mut saw_row = false;
for y in 0..12u16 {
let line: String = (0..w).map(|x| buf[(x, y)].symbol()).collect();
if !line.contains("REVIEW") {
continue;
}
saw_row = true;
// The assertion is that the TITLE SURVIVES, not that the
// last cell is blank.
//
// A blank last cell proves nothing: ratatui clips at the
// rect either way, so that held with the fix removed too —
// the first version of this test passed against the bug.
// What actually breaks without the width-derived budget is
// that a long path consumes the whole row and the title is
// pushed out entirely, which is the difference the user
// sees.
assert!(
line.contains("a title"),
"the path consumed the row and the title vanished:\n{line:?}"
);
assert!(
line.contains('\u{2026}'),
"the path was hard-clipped instead of elided:\n{line:?}"
);
}
assert!(saw_row, "no TODO row rendered at all");
}
/// User report — "the list appears too far left, shift 1 cell right".
///
/// The list rows carried a one-cell indent while FINDINGS and NOTES
/// list rows, and this panel's own hint and empty-state rows, all
/// used two. Asserted against a sibling panel rather than a literal
/// so the two cannot drift apart again silently.
#[test]
fn list_rows_are_indented_like_the_sibling_panels() {
use ratatui::Terminal;
use ratatui::backend::TestBackend;
let d = tempfile::tempdir().unwrap();
let mut app =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
app.config.ui.ascii_icons = true;
app.todos_panel_scanned_once = true; // don't kick off a rescan
app.todos_hits = vec![TodoHit {
tag: "TODO",
path: d.path().join("src/thing.rs"),
line: 12,
title: "wire the thing".into(),
}];
let mut term = Terminal::new(TestBackend::new(80, 12)).unwrap();
term.draw(|f| {
draw(
f,
&mut app,
Rect {
x: 0,
y: 0,
width: 80,
height: 12,
},
)
})
.unwrap();
let buf = term.backend().buffer();
let rows: Vec<String> = (0..12)
.map(|y| (0..80).map(|x| buf[(x, y)].symbol()).collect::<String>())
.collect();
// "TODOS" is the caps header; the list row is the other one.
let todo_row = rows
.iter()
.find(|r| r.contains("TODO") && !r.contains("TODOS"))
.unwrap_or_else(|| panic!("no TODO row rendered:\n{}", rows.join("\n")));
// Where the TEXT begins — not the leading-space count, which
// stopped measuring the indent once the focused row's accent
// bar started occupying the third gutter cell.
let text_start = |row: &str| {
row.chars()
.position(|c| c != ' ' && c != '▌')
.unwrap_or(usize::MAX)
};
let todos_col = text_start(todo_row);
// Render NOTES and compare against it directly. The docstring
// above has always claimed this was "asserted against a sibling
// panel"; it asserted a literal `3`, so the two could drift
// apart in either direction without this test noticing.
let mut napp =
crate::app::App::new(d.path().to_path_buf(), crate::config::Config::default()).unwrap();
napp.config.ui.ascii_icons = true;
let nd = crate::ui::notes_panel::notes_dir(d.path());
std::fs::create_dir_all(&nd).unwrap();
std::fs::write(nd.join("zzmarker.md"), "x").unwrap();
napp.notes_panel_files_cache = vec![nd.join("zzmarker.md")];
napp.notes_panel_scanned_once = true;
let mut nterm = Terminal::new(TestBackend::new(80, 12)).unwrap();
nterm
.draw(|f| {
crate::ui::notes_panel::draw(
f,
&mut napp,
Rect {
x: 0,
y: 0,
width: 80,
height: 12,
},
)
})
.unwrap();
let nbuf = nterm.backend().buffer();
let notes_row: String = (0..12)
.map(|y| (0..80).map(|x| nbuf[(x, y)].symbol()).collect::<String>())
.find(|r| r.contains("zzmarker"))
.expect("no NOTES list row rendered");
let notes_col = text_start(¬es_row);
assert_eq!(
todos_col, notes_col,
"TODOS text starts at column {todos_col}, NOTES at {notes_col} — \
the sibling panels have drifted apart:\n{todo_row:?}\n{notes_row:?}"
);
assert_eq!(
todos_col, 2,
"list text should start at column 2 (one inset cell + the \
accent-bar cell, which sits under the filter magnifier):\n{todo_row:?}"
);
}
#[test]
fn playwright_scanner_picks_up_fixme_and_fail_and_skip() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("example.spec.ts");
std::fs::write(
&path,
r#"import { test } from '@playwright/test';
test.fixme('renders survey card', async ({ page }) => {
await page.goto('/');
});
test.fail('editor accepts nested lists', async ({ page }) => {
await page.goto('/');
});
test.skip('legacy filter', async ({ page }) => { });
"#,
)
.unwrap();
let hits = scan_file(&path);
assert_eq!(hits.len(), 3);
assert_eq!(hits[0].tag, "FIXME");
assert_eq!(hits[0].title, "renders survey card");
assert_eq!(hits[1].tag, "XXX");
assert_eq!(hits[1].title, "editor accepts nested lists");
assert_eq!(hits[2].tag, "REVIEW");
assert_eq!(hits[2].title, "legacy filter");
}
#[test]
fn playwright_scanner_ignores_regular_files() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("index.ts");
std::fs::write(&path, "// TODO: hook this up\nconst x = 1;\n").unwrap();
let hits = scan_file(&path);
assert_eq!(hits.len(), 1);
assert_eq!(hits[0].tag, "TODO");
}
#[test]
fn extract_first_quoted_handles_single_and_double_quotes() {
assert_eq!(
extract_first_quoted(r#"("hello", async () => {})"#),
Some("hello".to_string())
);
assert_eq!(
extract_first_quoted(r#"('hi there', () => {})"#),
Some("hi there".to_string())
);
assert_eq!(extract_first_quoted("(no quotes here)"), None);
}
}