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
//! Left-bottom panel: Global Environments — activate one for substitution,
//! link one to the active collection, edit variables, and load/save `.vars`
//! files. Resolved secret values are shown but never editable (their provider
//! reference is the source of truth).
use eframe::egui::{self, RichText};
use crate::environment::{EnvVar, ValueSource};
use crate::i18n::Strings;
use super::app::{Dialog, GuiApp, OpenKind, PromptKind, SaveKind};
fn source_label(source: ValueSource) -> Option<&'static str> {
match source {
ValueSource::Literal => None,
ValueSource::ProcessEnv => Some("env"),
ValueSource::Ssm => Some("ssm"),
ValueSource::OnePassword => Some("1password"),
ValueSource::Unknown => Some("?"),
}
}
fn env_source_label(s: &Strings, source: crate::env_panel::EnvSource) -> &'static str {
match source {
crate::env_panel::EnvSource::Both => s.gui_env_source_both,
crate::env_panel::EnvSource::Global => s.gui_env_source_global,
crate::env_panel::EnvSource::Workspace => s.gui_env_source_workspace,
}
}
fn has_workspace(app: &GuiApp) -> bool {
app.session
.collections
.get(app.active_ci())
.and_then(|c| c.workspace_root.as_deref())
.is_some()
}
fn workspace_files(app: &GuiApp) -> Vec<std::path::PathBuf> {
app.session
.collections
.get(app.active_ci())
.map(|c| c.workspace_env_files())
.unwrap_or_default()
}
fn effective_source(app: &GuiApp) -> crate::env_panel::EnvSource {
if has_workspace(app) {
app.session.env_source
} else {
// The source picker is hidden without a Workspace tab; forcing "Both"
// here avoids reopening the app on a remembered Workspace-only choice
// that would make ordinary global environments appear to vanish.
crate::env_panel::EnvSource::Both
}
}
/// The panel's rows: the open Workspace's environment files (loaded or not)
/// followed by every other loaded environment, narrowed by the filter box.
/// See [`crate::env_panel`], which both front-ends share so they list the same
/// things in the same order.
#[cfg(test)]
fn env_rows(app: &GuiApp) -> Vec<crate::env_panel::EnvRow> {
env_rows_from(app, &workspace_files(app))
}
/// [`env_rows`] against a file list already in hand. The panel needs the same
/// list three times over — the rows, the unfiltered rows behind the "no
/// matches" message, and the empty state — and gathering it once is what keeps
/// those from being three passes over the workspace scan per frame.
fn env_rows_from(app: &GuiApp, files: &[std::path::PathBuf]) -> Vec<crate::env_panel::EnvRow> {
crate::env_panel::rows(
&app.session.global_envs,
files,
&app.env_query,
effective_source(app),
)
}
pub fn ui(app: &mut GuiApp, ui: &mut egui::Ui) {
let theme = app.theme;
let ci = app.active_ci();
let (
lbl_environments,
lbl_load,
tip_load,
tip_new,
lbl_no_envs,
lbl_active,
tip_active,
lbl_linked,
tip_linked,
lbl_delete,
lbl_save,
) = {
let s = &app.strings;
(
s.gui_environments,
s.gui_load_ellipsis,
s.gui_load_vars_tooltip,
s.gui_new_environment,
s.gui_no_environments,
s.gui_active,
s.gui_active_tooltip,
s.gui_linked,
s.gui_linked_tooltip,
s.gui_delete,
s.gui_save_ellipsis,
)
};
super::widgets::panel_header(ui, &theme, lbl_environments, |ui| {
if ui.button(lbl_load).on_hover_text(tip_load).clicked() {
super::menu::open_via_picker(app, OpenKind::Environment);
}
if ui
.button(super::icons::PLUS)
.on_hover_text(tip_new)
.clicked()
{
app.dialog = Some(Dialog::Prompt {
kind: PromptKind::NewEnvName,
text: String::new(),
});
}
});
// Filter box. Always shown rather than hidden behind a toggle: a workspace
// of a few hundred environments is unusable without it, and an empty box is
// one line of panel for a permanently useful control.
ui.horizontal(|ui| {
ui.add(
egui::TextEdit::singleline(&mut app.env_query)
.hint_text(app.strings.gui_env_filter_hint)
.desired_width(f32::INFINITY),
);
});
if has_workspace(app) {
ui.horizontal_wrapped(|ui| {
for source in [
crate::env_panel::EnvSource::Both,
crate::env_panel::EnvSource::Global,
crate::env_panel::EnvSource::Workspace,
] {
if ui
.selectable_label(
app.session.env_source == source,
env_source_label(&app.strings, source),
)
.clicked()
{
app.session.env_source = source;
app.session.save();
}
}
});
}
ui.separator();
let files = workspace_files(app);
let rows = env_rows_from(app, &files);
let rows_for_source =
crate::env_panel::rows(&app.session.global_envs, &files, "", effective_source(app));
let active = app.session.active_env_id;
let linked = app.session.collections[ci].linked_env_id;
// One-shot: consumed on the frame that shows the row, so a later manual
// collapse isn't fought by a request that never expires.
let reveal_target = app.reveal_env;
let mut activate: Option<u64> = None;
let mut link: Option<u64> = None;
let mut delete: Option<u64> = None;
let mut save: Option<u64> = None;
let mut open_file: Option<std::path::PathBuf> = None;
let mut changed = false;
egui::ScrollArea::vertical()
.auto_shrink([false, false])
.show(ui, |ui| {
// Truncate long environment names so they can't report a content
// width wider than the panel (see the note in `requests.rs` — an
// over-wide panel leaves an unpainted strip while being dragged).
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);
if rows.is_empty() {
ui.add_space(6.0);
// "Nothing loaded" and "the filter hid everything" are
// different problems with different fixes.
let empty = if app.session.global_envs.is_empty() && files.is_empty() {
lbl_no_envs
} else if rows_for_source.is_empty() {
app.strings.gui_env_source_no_matches
} else if app.env_query.trim().is_empty() {
lbl_no_envs
} else {
app.strings.gui_env_filter_no_matches
};
ui.colored_label(theme.dim, empty);
}
for row in &rows {
// Workspace files that have not been opened yet still use the
// same collapsible row as loaded environments: clicking one is
// the user's "expand" gesture, so it loads the file and the
// next frame reveals the variables. Keeping the id path-based
// means the row does not inherit state from a filtered-out
// neighbour, and does not change shape when it becomes loaded.
let Some(id) = row.env_id() else {
let Some(path) = row.file().map(|p| p.to_path_buf()) else {
continue;
};
let state_id = egui::Id::new(("env-path", path.clone()));
let state = egui::collapsing_header::CollapsingState::load_with_default_open(
ui.ctx(),
state_id,
false,
);
if state.is_open() {
open_file = Some(path.clone());
}
let text = RichText::new(format!("{} {}", super::icons::FOLDER, row.name))
.color(theme.dim);
let header = super::widgets::tree_header_marked(
ui,
("env-path", path.clone()),
false,
false,
text,
None,
|_ui| {},
)
.on_hover_text(app.strings.gui_env_open_workspace_tooltip);
if header.clicked() {
open_file = Some(path);
}
continue;
};
let idx = match app.session.global_envs.iter().position(|e| e.id == id) {
Some(i) => i,
None => continue,
};
let is_active = active == Some(id);
let is_linked = linked == Some(id);
let name = app.session.global_envs[idx].name.clone();
let from_git = app.session.global_envs[idx].git_origin.is_some();
// The active environment is marked the way the terminal UI
// marks it — a leading tick in the "ok" colour with the name to
// match — plus a filled band behind the row, because a GUI list
// is sparse enough that colour alone is easy to skim past.
// A folder icon marks the environments that came from the open
// workspace, so the panel's two sources stay distinguishable.
let header = format!(
"{}{}{}",
if is_active {
format!("{} ", super::icons::PASS)
} else {
String::new()
},
if row.workspace {
format!("{} ", super::icons::FOLDER)
} else if from_git {
format!("{} ", super::icons::GIT)
} else {
String::new()
},
name,
);
let mut text = RichText::new(header);
if is_active {
text = text.color(theme.ok).strong();
} else {
text = text.color(theme.text);
}
// Opening a `.vars` file from the workspace tree reveals it
// here: loading it alone would leave the user looking at a
// collapsed row and no sign anything had happened.
let reveal = reveal_target == Some(id);
let id_salt = app.session.global_envs[idx]
.path
.as_ref()
.filter(|_| row.workspace)
.map(|path| ("env-path", path.clone()))
.unwrap_or_else(|| ("env", std::path::PathBuf::from(id.to_string())));
let header = super::widgets::tree_header_marked(
ui,
id_salt,
false,
reveal,
text,
is_active.then_some(theme.ok),
|ui| {
// Wrap the action buttons so their fixed widths can't
// overflow (and report an over-wide content size) when
// the panel is dragged narrow — they flow onto a second
// line instead. This is also robust to longer
// translations of the button labels.
ui.horizontal_wrapped(|ui| {
if super::widgets::selectable(ui, is_active, lbl_active)
.on_hover_text(tip_active)
.clicked()
{
activate = Some(id);
}
if super::widgets::selectable(ui, is_linked, lbl_linked)
.on_hover_text(tip_linked)
.clicked()
{
link = Some(id);
}
if ui.button(lbl_save).clicked() {
save = Some(id);
}
if ui
.button(RichText::new(lbl_delete).color(theme.err))
.clicked()
{
delete = Some(id);
}
});
ui.add_space(4.0);
if var_editor(
ui,
&theme,
&app.strings,
&mut app.session.global_envs[idx].vars,
) {
changed = true;
}
},
);
// Scroll the revealed row into view — the panel is short and a
// workspace can hold more environments than fit in it.
if reveal {
header.scroll_to_me(Some(egui::Align::Center));
}
}
});
// Whether or not the row was found, the request is spent after one frame.
app.reveal_env = None;
if let Some(path) = open_file {
// Opening reveals it, so the row visibly becomes a loaded environment
// rather than just quietly changing colour somewhere in a long list.
app.reveal_env = app.session.open_workspace_environment(&path);
if app.reveal_env.is_none() {
let id = egui::Id::new(("env-path", path));
let mut state = egui::collapsing_header::CollapsingState::load_with_default_open(
ui.ctx(),
id,
false,
);
state.set_open(false);
state.store(ui.ctx());
}
app.session.save();
}
if let Some(id) = activate {
app.session.set_active_env(Some(id));
}
if let Some(id) = link {
app.session.set_linked_env(ci, Some(id));
}
if let Some(id) = delete {
app.session.delete_environment(id);
}
if let Some(id) = save {
super::menu::save_via_picker(app, SaveKind::Environment(id));
}
if changed {
for col in &mut app.session.collections {
col.invalidate_request_json();
}
}
}
/// Editable variable table for one environment. Literal values are editable in
/// place; secret-backed values show their provider and resolution state and are
/// not directly editable (the `.vars` reference is the source of truth).
fn var_editor(
ui: &mut egui::Ui,
theme: &super::theme::GuiTheme,
s: &Strings,
vars: &mut Vec<EnvVar>,
) -> bool {
let mut changed = false;
let mut remove: Option<usize> = None;
// Give the key ~40% of the free width so it grows with the panel instead of
// staying a fixed sliver next to the filling value (see `split_key_width`).
let key_w = super::widgets::split_key_width(ui, 42.0);
egui::Grid::new("env_vars")
.num_columns(2)
.spacing([8.0, 4.0])
.striped(true)
.min_col_width(0.0)
.show(ui, |ui| {
for i in 0..vars.len() {
let source = vars[i].source;
if super::widgets::sized_key(
ui,
key_w,
&mut vars[i].key,
s.gui_hint_key_upper,
theme.text,
)
.changed()
{
changed = true;
}
// The value cell is the grid's last column so it stretches to
// fill the panel; the remove ✕ is right-aligned inside it (see
// the note in `widgets::kv_editor`).
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui
.button(RichText::new(super::icons::CLOSE).color(theme.err))
.clicked()
{
remove = Some(i);
}
match source_label(source) {
None => {
// Literal: editable value.
if ui
.add(
egui::TextEdit::singleline(&mut vars[i].value)
.desired_width(f32::INFINITY)
.hint_text(s.gui_hint_value),
)
.changed()
{
vars[i].raw = vars[i].value.clone();
vars[i].modified = true;
changed = true;
}
}
Some(provider) => {
ui.with_layout(
egui::Layout::left_to_right(egui::Align::Center),
|ui| {
ui.label(
RichText::new(format!("{{{{ {provider} }}}}"))
.color(theme.subst),
);
if vars[i].loading {
ui.spinner();
ui.colored_label(theme.pending, s.gui_resolving);
} else if vars[i].resolved {
ui.colored_label(theme.dim, "••••••");
} else {
ui.colored_label(theme.err, s.gui_unresolved);
}
},
);
}
}
});
ui.end_row();
}
});
if let Some(i) = remove {
vars.remove(i);
changed = true;
}
if ui.button(s.gui_add_variable).clicked() {
vars.push(EnvVar::user(String::new(), String::new()));
changed = true;
}
changed
}
#[cfg(test)]
mod tests {
use super::*;
/// Every string the frame painted, so a row can be checked for by the name
/// the user reads rather than by poking at internal state.
fn painted_text(shapes: &[egui::epaint::ClippedShape]) -> Vec<String> {
fn walk(shape: &egui::epaint::Shape, out: &mut Vec<String>) {
match shape {
egui::epaint::Shape::Text(t) => out.push(t.galley.text().to_string()),
egui::epaint::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
_ => {}
}
}
let mut out = Vec::new();
for c in shapes {
walk(&c.shape, &mut out);
}
out
}
/// A real screen rect matters: the list lives in a `ScrollArea`, which culls
/// anything it believes is offscreen.
fn draw(app: &mut GuiApp) -> Vec<String> {
let ctx = egui::Context::default();
let mut input = egui::RawInput::default();
input.screen_rect = Some(egui::Rect::from_min_size(
egui::pos2(0.0, 0.0),
egui::vec2(320.0, 600.0),
));
let out = ctx.run_ui(input, |panel| super::ui(app, panel));
painted_text(&out.shapes)
}
fn draw_with_workspace_file_expanded(app: &mut GuiApp, path: &std::path::Path) -> Vec<String> {
let ctx = egui::Context::default();
let id = egui::Id::new(("env-path", path.to_path_buf()));
let mut state =
egui::collapsing_header::CollapsingState::load_with_default_open(&ctx, id, false);
state.set_open(true);
state.store(&ctx);
let mut input = egui::RawInput::default();
input.screen_rect = Some(egui::Rect::from_min_size(
egui::pos2(0.0, 0.0),
egui::vec2(320.0, 600.0),
));
let out = ctx.run_ui(input, |panel| super::ui(app, panel));
painted_text(&out.shapes)
}
fn app_with_workspace(tag: &str) -> (GuiApp, std::path::PathBuf) {
let dir = std::env::temp_dir().join(format!(
"paperboy_gui_envs_{tag}_{}_{:?}",
std::process::id(),
std::thread::current().id()
));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join("dev.vars"), "TOKEN=t\n").unwrap();
std::fs::write(
dir.join("Prod AU.json"),
r#"{"environment":{"name":"Prod AU","values":[{"key":"url","value":"https://x"}]}}"#,
)
.unwrap();
// A Postman *collection* shares the `.json` extension and must not be
// mistaken for an environment.
std::fs::write(
dir.join("orders.json"),
r#"{"info":{"name":"orders"},"item":[]}"#,
)
.unwrap();
let mut session = crate::session::Session::default();
session.collections.clear();
let ci = session.open_workspace(dir.clone());
session.active_tab = ci;
(GuiApp::for_test(session), dir)
}
/// The panel shows the open workspace's environment files alongside the
/// global ones, whether or not they have been opened yet.
#[test]
fn the_panel_merges_workspace_environment_files_with_the_global_ones() {
let (mut app, dir) = app_with_workspace("merge");
app.session
.load_environment_text("hand-made".into(), "A=1\n", None, None);
let names: Vec<String> = env_rows(&app).iter().map(|r| r.name.clone()).collect();
assert_eq!(
names,
vec!["Prod AU", "dev", "hand-made"],
"workspace files first, in tree order, then everything else"
);
assert!(
env_rows(&app)[..2].iter().all(|r| r.workspace),
"and the workspace ones are flagged, so they can be marked in the list"
);
let painted = draw(&mut app);
for name in ["Prod AU", "dev", "hand-made"] {
assert!(
painted.iter().any(|t| t.contains(name)),
"{name} should be drawn, painted: {painted:?}"
);
}
assert!(
!painted.iter().any(|t| t.contains("orders")),
"a collection is not an environment"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// The filter box narrows the list by name — the point of it being that a
/// workspace can hold hundreds of environments.
#[test]
fn the_filter_box_narrows_the_list_to_matching_names() {
let (mut app, dir) = app_with_workspace("filter");
app.session
.load_environment_text("hand-made".into(), "A=1\n", None, None);
app.env_query = "PROD".into();
assert_eq!(
env_rows(&app)
.iter()
.map(|r| r.name.clone())
.collect::<Vec<_>>(),
vec!["Prod AU"],
"case-insensitive substring match"
);
let painted = draw(&mut app);
assert!(painted.iter().any(|t| t.contains("Prod AU")));
assert!(
!painted.iter().any(|t| t.contains("hand-made")),
"the filtered-out rows are gone from the frame: {painted:?}"
);
app.env_query = "zzz".into();
assert!(env_rows(&app).is_empty());
let painted = draw(&mut app);
assert!(
painted
.iter()
.any(|t| t.contains(app.strings.gui_env_filter_no_matches)),
"and an empty result says so rather than looking like an empty panel: {painted:?}"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// The GUI uses the shared source selector before drawing, so its helper
/// narrows the same rows the visible panel does.
#[test]
fn the_source_selector_narrows_the_gui_environment_rows() {
let (mut app, dir) = app_with_workspace("source");
app.session
.load_environment_text("hand-made".into(), "A=1\n", None, None);
app.session.env_source = crate::env_panel::EnvSource::Workspace;
assert_eq!(
env_rows(&app)
.iter()
.map(|r| (r.name.as_str(), r.workspace))
.collect::<Vec<_>>(),
vec![("Prod AU", true), ("dev", true)]
);
app.session.env_source = crate::env_panel::EnvSource::Global;
assert_eq!(
env_rows(&app)
.iter()
.map(|r| (r.name.as_str(), r.workspace))
.collect::<Vec<_>>(),
vec![("hand-made", false)]
);
app.env_query = "made".into();
assert_eq!(
env_rows(&app)
.iter()
.map(|r| r.name.as_str())
.collect::<Vec<_>>(),
vec!["hand-made"],
"source and name filters compose"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// Opening a listed workspace file turns its row into the environment it
/// became, rather than adding a second row for the same file.
#[test]
fn opening_a_workspace_environment_replaces_its_row_instead_of_duplicating_it() {
let (mut app, dir) = app_with_workspace("open");
let path = dir.join("dev.vars");
let id = app.session.open_workspace_environment(&path).unwrap();
let rows = env_rows(&app);
assert_eq!(rows.len(), 2, "still one row per file: {rows:?}");
let dev = rows.iter().find(|r| r.name == "dev").unwrap();
assert!(dev.workspace && dev.env_id() == Some(id));
let _ = std::fs::remove_dir_all(&dir);
}
/// Workspace environment files that have not been opened yet still present
/// as expandable rows, so the affordance does not appear only after use.
#[test]
fn unopened_workspace_environment_rows_are_drawn_with_a_caret() {
let (mut app, dir) = app_with_workspace("unopened-caret");
let painted = draw(&mut app);
assert!(
painted
.iter()
.any(|t| t == super::super::icons::CARET_RIGHT),
"an unopened workspace environment should show a collapsed caret: {painted:?}"
);
assert!(
painted.iter().any(|t| t.contains("Prod AU")),
"the workspace environment row should be visible: {painted:?}"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// Expanding an unopened workspace environment is the load gesture: the row
/// becomes a loaded environment instead of first changing into a different
/// kind of row that needs a second click.
#[test]
fn expanding_an_unopened_workspace_environment_loads_the_file() {
let (mut app, dir) = app_with_workspace("expand-loads");
assert!(app.session.global_envs.is_empty());
let _ = draw_with_workspace_file_expanded(&mut app, &dir.join("Prod AU.json"));
assert_eq!(app.session.global_envs.len(), 1);
let rows = env_rows(&app);
let prod = rows.iter().find(|r| r.name == "Prod AU").unwrap();
assert!(
prod.workspace && prod.env_id().is_some(),
"the clicked workspace row should now be loaded: {rows:?}"
);
let _ = std::fs::remove_dir_all(&dir);
}
/// Loaded environment rows always show the disclosure affordance: right
/// when collapsed, down when a reveal opens the row.
#[test]
fn loaded_environment_rows_keep_a_caret_before_and_after_expanding() {
let mut app = GuiApp::for_test(crate::session::Session::default());
let id = app
.session
.load_environment_text("dev".into(), "TOKEN=t\n", None, None)
.unwrap();
let painted = draw(&mut app);
assert!(
painted
.iter()
.any(|t| t == super::super::icons::CARET_RIGHT),
"a never-opened row should still show a collapsed caret: {painted:?}"
);
app.reveal_env = Some(id);
let painted = draw(&mut app);
assert!(
painted.iter().any(|t| t == super::super::icons::CARET_DOWN),
"an opened row should show the expanded caret: {painted:?}"
);
}
}