rho-coding-agent 2.15.0

A fast Rust agent harness with a small footprint and opinionated defaults
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
//! In-app `/sessions` hub: browse, resume, and delete saved sessions from
//! every directory, grouped by directory and by Git repository.

use std::path::{Path, PathBuf};

use ratatui::DefaultTerminal;

use super::sessions_hub_groups::{find_directory, DirectoryGroup, HubGroup};
use super::sessions_hub_tasks::{plural, DeleteOrigin, SessionsDelete};
use super::{
    picker::OverlayChrome, session_picker, statusline::path::compact_cwd, App, ComposerMode, Entry,
    InlineChoice, InlineChoiceModal, InlineChoiceOption, InlineChoicePending, InteractiveRuntime,
    PickerBadge, PickerBadgeTone, PickerCursor, PickerItem, PickerKeyHints, PickerLayout, UiPicker,
};
use crate::session::{is_cross_project, Session, SessionSummary, SessionTarget};

const TARGET_PREFIX: &str = "sessions-target:";

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(super) enum SessionsLocation {
    #[default]
    Root,
    Directory(PathBuf),
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) enum SessionsHubTarget {
    CleanupMissingWorkspaces,
    Directory(PathBuf),
    Session(SessionTarget),
}

#[derive(Debug)]
pub(super) struct SessionsPickerBuild {
    pub(super) picker: UiPicker,
    pub(super) targets: Vec<SessionsHubTarget>,
}

/// Open hub state. `groups` is the last loaded listing: drilling into a
/// directory and building prompts reads it instead of disk.
#[derive(Debug, Default)]
pub(super) struct SessionsHubState {
    location: SessionsLocation,
    targets: Vec<SessionsHubTarget>,
    root_targets: Vec<SessionsHubTarget>,
    groups: Vec<HubGroup>,
    /// The hub shows a placeholder until the first listing lands.
    loading: bool,
}

impl SessionsHubState {
    fn open_root(&mut self, targets: Vec<SessionsHubTarget>, groups: Vec<HubGroup>) {
        self.loading = false;
        self.location = SessionsLocation::Root;
        self.root_targets.clone_from(&targets);
        self.targets = targets;
        self.groups = groups;
    }

    fn directory(&self, cwd: &Path) -> Option<&DirectoryGroup> {
        find_directory(&self.groups, cwd)
    }

    fn missing_directories(&self) -> &[DirectoryGroup] {
        self.groups
            .iter()
            .find_map(|group| match group {
                HubGroup::Missing(missing) => Some(missing.as_slice()),
                HubGroup::Directory(_) | HubGroup::Repo { .. } => None,
            })
            .unwrap_or_default()
    }

    fn open_directory(&mut self, cwd: PathBuf, targets: Vec<SessionsHubTarget>) {
        self.location = SessionsLocation::Directory(cwd);
        self.targets = targets;
    }

    pub(super) fn navigate_back(&mut self) {
        self.location = SessionsLocation::Root;
        self.targets.clone_from(&self.root_targets);
    }

    pub(super) fn clear(&mut self) {
        *self = Self::default();
    }

    fn target(&self, value: &str) -> Option<SessionsHubTarget> {
        let index = value.strip_prefix(TARGET_PREFIX)?.parse::<usize>().ok()?;
        self.targets.get(index).cloned()
    }

    fn location(&self) -> SessionsLocation {
        self.location.clone()
    }
}

fn directory_count_label(count: usize) -> String {
    if count == 1 {
        "1 directory".to_string()
    } else {
        format!("{count} directories")
    }
}

fn target_value(index: usize) -> String {
    format!("{TARGET_PREFIX}{index}")
}

/// `label` names the row: "All sessions" under a directory's own section, or
/// the directory's short name inside a shared section.
fn directory_row(
    section: &str,
    label: &str,
    group: &DirectoryGroup,
    current_cwd: &Path,
    now: u64,
    value: String,
) -> PickerItem {
    let is_current = !is_cross_project(&group.cwd, current_cwd);
    let newest = group
        .sessions
        .iter()
        .map(|session| session.updated_at)
        .max()
        .unwrap_or_default();
    let updated = session_picker::format_updated_ago(newest, now);
    PickerItem {
        section: Some(section.to_owned()),
        label: format!("{label} · {}", group.sessions.len()),
        detail: None,
        preview: Some(format!("newest {updated}")),
        badge: is_current.then(|| PickerBadge {
            text: "current dir".into(),
            tone: PickerBadgeTone::Selected,
        }),
        value,
        selection_verb: Some("browse"),
        allow_filter_completion: true,
    }
}

fn session_row(
    section: Option<&str>,
    session: &SessionSummary,
    current_session: Option<&SessionTarget>,
    current_cwd: &Path,
    now: u64,
    value: String,
) -> PickerItem {
    let target = session.target();
    let is_current = current_session == Some(&target);
    let short_id = session_picker::short_session_id(&session.id);
    let title = session
        .title
        .as_deref()
        .or(session.first_user_message.as_deref())
        .map(session_picker::preview_text)
        .unwrap_or_else(|| format!("session {short_id}"));
    // Row preview: age, then the latest prompt when it adds something new.
    let updated = session_picker::format_updated_ago(session.updated_at, now);
    let preview = match session
        .last_user_message
        .as_deref()
        .map(session_picker::preview_text)
        .filter(|last_user| last_user != &title)
    {
        Some(last_user) => format!("{updated} · last: {last_user}"),
        None => updated,
    };
    PickerItem {
        section: section.map(str::to_owned),
        label: title,
        detail: None,
        preview: Some(preview),
        badge: is_current.then(|| PickerBadge {
            text: "current".into(),
            tone: PickerBadgeTone::Selected,
        }),
        value,
        selection_verb: Some(if is_current {
            "close"
        } else if is_cross_project(&session.cwd, current_cwd) {
            "unavailable"
        } else {
            "resume"
        }),
        allow_filter_completion: true,
    }
}

fn cleanup_missing_workspaces_row(missing: &[DirectoryGroup], value: String) -> PickerItem {
    let session_count = missing.iter().map(|group| group.sessions.len()).sum();
    let directory_count = missing.len();
    PickerItem {
        section: Some("CLEAN UP".into()),
        label: "Delete sessions for missing directories".into(),
        detail: None,
        preview: Some(directory_count_label(directory_count)),
        badge: Some(PickerBadge {
            text: plural(session_count, "session"),
            tone: PickerBadgeTone::Warning,
        }),
        value,
        selection_verb: Some("clean up"),
        allow_filter_completion: true,
    }
}

fn manage_sessions_picker(title: impl Into<String>, items: Vec<PickerItem>) -> UiPicker {
    UiPicker::manage_sessions(title, items)
        .with_key_hints(PickerKeyHints {
            tab_complete: false,
            row_delete: true,
            ..Default::default()
        })
        .with_layout(PickerLayout::Overlay)
        .with_overlay_chrome(OverlayChrome {
            nav_label: " SESSIONS".into(),
            detail_label: None,
            nav_keys_hint: "↑↓ items".into(),
        })
        .with_restore_status("sessions")
}

/// Section title for directories that no longer exist.
const MISSING_SECTION: &str = "MISSING DIRECTORIES";

/// Root list builder: section rows plus the target behind each row.
struct HubRows<'a> {
    items: Vec<PickerItem>,
    targets: Vec<SessionsHubTarget>,
    current_session: Option<&'a SessionTarget>,
    current_cwd: &'a Path,
    now: u64,
}

impl HubRows<'_> {
    fn next_value(&mut self, target: SessionsHubTarget) -> String {
        self.targets.push(target);
        target_value(self.targets.len() - 1)
    }

    fn directory(&mut self, section: &str, label: &str, group: &DirectoryGroup) {
        let value = self.next_value(SessionsHubTarget::Directory(group.cwd.clone()));
        let row = directory_row(section, label, group, self.current_cwd, self.now, value);
        self.items.push(row);
    }

    fn sessions(&mut self, section: &str, group: &DirectoryGroup) {
        for session in &group.sessions {
            let value = self.next_value(SessionsHubTarget::Session(session.target()));
            let row = session_row(
                Some(section),
                session,
                self.current_session,
                self.current_cwd,
                self.now,
                value,
            );
            self.items.push(row);
        }
    }
}

/// Root list: one section per group, current directory first. Single
/// directories list their sessions inline; multi-worktree repositories inline
/// only the current directory; missing directories get a cleanup row and
/// never inline.
pub(super) fn hub_picker(
    groups: &[HubGroup],
    current_session: Option<&SessionTarget>,
    current_cwd: &Path,
    now: u64,
) -> SessionsPickerBuild {
    let mut rows = HubRows {
        items: Vec::new(),
        targets: Vec::new(),
        current_session,
        current_cwd,
        now,
    };
    // Cleanup leads the list so stale directories are noticed first.
    let missing = groups.iter().find_map(|group| match group {
        HubGroup::Missing(missing) => Some(missing),
        HubGroup::Directory(_) | HubGroup::Repo { .. } => None,
    });
    if let Some(missing) = missing {
        let value = rows.next_value(SessionsHubTarget::CleanupMissingWorkspaces);
        rows.items
            .push(cleanup_missing_workspaces_row(missing, value));
    }
    for group in groups {
        match group {
            HubGroup::Directory(directory) => {
                rows.directory(&directory.display, "All sessions", directory);
                rows.sessions(&directory.display, directory);
            }
            HubGroup::Repo { display, worktrees } => {
                for worktree in worktrees {
                    rows.directory(display, &worktree.name, &worktree.directory);
                    if !is_cross_project(&worktree.directory.cwd, current_cwd) {
                        rows.sessions(display, &worktree.directory);
                    }
                }
            }
            HubGroup::Missing(missing) => {
                for directory in missing {
                    rows.directory(MISSING_SECTION, &directory.display, directory);
                }
            }
        }
    }
    SessionsPickerBuild {
        picker: manage_sessions_picker("Sessions", rows.items),
        targets: rows.targets,
    }
}

/// Child list scoped to one directory's sessions.
pub(super) fn directory_picker(
    group: &DirectoryGroup,
    current_session: Option<&SessionTarget>,
    current_cwd: &Path,
    now: u64,
) -> SessionsPickerBuild {
    let targets = group
        .sessions
        .iter()
        .map(SessionSummary::target)
        .map(SessionsHubTarget::Session)
        .collect::<Vec<_>>();
    let items = group
        .sessions
        .iter()
        .enumerate()
        .map(|(index, session)| {
            session_row(
                None,
                session,
                current_session,
                current_cwd,
                now,
                target_value(index),
            )
        })
        .collect();
    SessionsPickerBuild {
        picker: manage_sessions_picker(group.display.clone(), items),
        targets,
    }
}

impl App {
    pub(super) fn current_session_target(&self) -> Option<SessionTarget> {
        self.info
            .session
            .session_id
            .as_ref()
            .map(|id| SessionTarget::new(id.clone(), self.info.runtime.cwd.clone()))
    }

    /// `/sessions`: open the hub at once and list sessions in the background.
    pub(super) fn execute_sessions_command(&mut self) {
        if self.refuse_while_sessions_delete_runs() {
            return;
        }
        self.sessions_hub_state.clear();
        self.sessions_hub_state.loading = true;
        self.input_ui.set_composer(ComposerMode::Picker(
            manage_sessions_picker("Sessions", Vec::new()).with_empty_message("loading sessions…"),
        ));
        self.set_status("loading sessions");
        self.start_sessions_load();
    }

    /// Fill the loading hub with the listing. Dropped when the user closed
    /// the hub first, so a late listing never reopens it.
    pub(super) fn fill_sessions_hub(&mut self, groups: anyhow::Result<Vec<HubGroup>>) {
        let hub_waiting = self.sessions_hub_state.loading
            && matches!(self.input_ui.composer(), ComposerMode::Picker(picker) if picker.is_manage_sessions());
        if !hub_waiting {
            return;
        }
        match groups {
            Ok(groups) => {
                // Keep anything typed into the search box while loading.
                let cursor = match self.input_ui.composer() {
                    ComposerMode::Picker(picker) => Some(picker.cursor()),
                    _ => None,
                };
                self.show_sessions_hub(groups);
                if let (Some(cursor), ComposerMode::Picker(picker)) =
                    (cursor.as_ref(), self.input_ui.composer_mut())
                {
                    picker.restore_cursor(cursor);
                }
            }
            Err(error) => {
                self.sessions_hub_state.clear();
                self.input_ui.set_composer(ComposerMode::Input);
                self.insert_entry(&Entry::Error(format!("could not open sessions: {error}")));
                self.set_status("sessions failed");
            }
        }
    }

    /// Show the root hub for `groups`.
    fn show_sessions_hub(&mut self, groups: Vec<HubGroup>) {
        if groups.is_empty() {
            self.sessions_hub_state.clear();
            self.input_ui.set_composer(ComposerMode::Input);
            self.set_status("no saved sessions");
            return;
        }
        let current = self.current_session_target();
        let build = hub_picker(
            &groups,
            current.as_ref(),
            &self.info.runtime.cwd,
            session_picker::now_unix_secs(),
        );
        self.sessions_hub_state.open_root(build.targets, groups);
        self.input_ui
            .set_composer(ComposerMode::Picker(build.picker));
        self.set_status("sessions");
    }

    /// Rebuild the open hub from a fresh listing after a delete, keeping the
    /// open directory and cursor.
    pub(super) fn refresh_sessions_hub(&mut self, groups: Vec<HubGroup>) {
        let location = self.sessions_hub_state.location();
        let cursor = match self.input_ui.composer() {
            ComposerMode::Picker(picker) => Some(picker.cursor()),
            _ => None,
        };
        self.show_sessions_hub(groups);
        if let SessionsLocation::Directory(cwd) = location {
            if matches!(self.input_ui.composer(), ComposerMode::Picker(_)) {
                self.open_directory_sessions(&cwd, cursor.as_ref());
            }
        } else if let (Some(cursor), ComposerMode::Picker(picker)) =
            (cursor.as_ref(), self.input_ui.composer_mut())
        {
            picker.restore_cursor(cursor);
        }
    }

    pub(super) async fn submit_sessions_selection(
        &mut self,
        value: &str,
        terminal: &mut DefaultTerminal,
        agent: &mut InteractiveRuntime,
    ) -> anyhow::Result<()> {
        let Some(target) = self.sessions_hub_state.target(value) else {
            self.input_ui.set_composer(ComposerMode::Input);
            self.insert_entry(&Entry::Error(
                "sessions selection expired; reopen /sessions".into(),
            ));
            self.set_status("sessions selection failed");
            return Ok(());
        };
        match target {
            SessionsHubTarget::CleanupMissingWorkspaces => {
                self.prompt_cleanup_missing_session_directories()
            }
            SessionsHubTarget::Session(target) => {
                if self.current_session_target().as_ref() == Some(&target) {
                    self.input_ui.set_composer(ComposerMode::Input);
                    self.sessions_hub_state.clear();
                    self.set_status("already in this session");
                    return Ok(());
                }
                if is_cross_project(&target.cwd, &self.info.runtime.cwd) {
                    self.set_status("start Rho in that directory to resume this session");
                    return Ok(());
                }
                // The session may be in the batch being deleted.
                if self.refuse_while_sessions_delete_runs() {
                    return Ok(());
                }
                self.submit_resume_target(&target, terminal, agent).await
            }
            SessionsHubTarget::Directory(cwd) => {
                self.open_directory_sessions(&cwd, None);
                Ok(())
            }
        }
    }

    /// Drill into one directory's sessions from the loaded listing.
    fn open_directory_sessions(&mut self, cwd: &Path, cursor: Option<&PickerCursor>) {
        let current = self.current_session_target();
        let Some(group) = self.sessions_hub_state.directory(cwd) else {
            self.sessions_hub_state.navigate_back();
            self.set_status("no saved sessions for this directory");
            return;
        };
        let mut build = directory_picker(
            group,
            current.as_ref(),
            &self.info.runtime.cwd,
            session_picker::now_unix_secs(),
        );
        if let Some(cursor) = cursor {
            build.picker.restore_cursor(cursor);
        }
        self.sessions_hub_state
            .open_directory(cwd.to_path_buf(), build.targets);
        self.open_child_picker(build.picker);
    }

    pub(super) fn prompt_delete_selected_sessions_item(&mut self) -> anyhow::Result<()> {
        let Some(value) = self.selected_sessions_item_value() else {
            return Ok(());
        };
        if self.refuse_while_sessions_delete_runs() {
            return Ok(());
        }
        let Some(target) = self.sessions_hub_state.target(&value) else {
            self.set_status("sessions selection expired; reopen /sessions");
            return Ok(());
        };
        match target {
            SessionsHubTarget::CleanupMissingWorkspaces => {
                self.prompt_cleanup_missing_session_directories()
            }
            SessionsHubTarget::Session(target) => {
                if self.current_session_target().as_ref() == Some(&target) {
                    self.set_status("cannot delete the current session");
                    return Ok(());
                }
                self.prompt_delete_session(target)
            }
            SessionsHubTarget::Directory(cwd) => self.prompt_delete_directory_sessions(&cwd),
        }
    }

    fn prompt_delete_directory_sessions(&mut self, cwd: &Path) -> anyhow::Result<()> {
        // List fresh so "all sessions" includes any saved since the hub
        // loaded. One workspace is an index query, well under a millisecond.
        let targets = Session::list(cwd)?
            .iter()
            .map(SessionSummary::target)
            .collect::<Vec<_>>();
        let count = targets.len();
        let display = compact_cwd(cwd);
        let choice = InlineChoice::new(
            format!("Delete all sessions in {display}?"),
            format!(
                "Removes {} saved in this directory, with transcripts, cached web content, and their subagent runs. The current session is kept. Usage history is kept.",
                plural(count, "session")
            ),
            vec![
                InlineChoiceOption::available(
                    "delete",
                    'd',
                    "Delete all",
                    "Permanently remove every saved session in this directory",
                ),
                InlineChoiceOption::available(
                    "cancel",
                    'c',
                    "Cancel",
                    "Keep the sessions and return to the picker",
                )
                .with_alternate_shortcut('n'),
            ],
        )?;
        self.open_session_choice(
            choice,
            InlineChoicePending::DeleteDirectorySessions {
                cwd: cwd.to_path_buf(),
                targets,
            },
            "confirm delete directory sessions",
        )
    }

    fn prompt_cleanup_missing_session_directories(&mut self) -> anyhow::Result<()> {
        if self.refuse_while_sessions_delete_runs() {
            return Ok(());
        }
        let missing = self.sessions_hub_state.missing_directories();
        let targets = missing
            .iter()
            .flat_map(|group| group.sessions.iter().map(SessionSummary::target))
            .collect::<Vec<_>>();
        let directory_count = missing.len();
        if targets.is_empty() {
            self.set_status("no sessions need cleanup");
            return Ok(());
        }
        let choice = InlineChoice::new(
            "Delete sessions for missing directories?",
            format!(
                "Permanently removes {} saved for {} that no longer exist, with transcripts, cached web content, and their subagent runs. Usage history is kept.",
                plural(targets.len(), "session"),
                directory_count_label(directory_count)
            ),
            vec![
                InlineChoiceOption::available(
                    "delete",
                    'd',
                    "Delete all",
                    "Remove every saved session whose workspace directory no longer exists",
                ),
                InlineChoiceOption::available(
                    "cancel",
                    'c',
                    "Cancel",
                    "Keep the sessions and return to the picker",
                )
                .with_alternate_shortcut('n'),
            ],
        )?;
        self.open_session_choice(
            choice,
            InlineChoicePending::CleanupMissingSessionDirectories { targets },
            "confirm session cleanup",
        )
    }

    pub(super) fn open_session_choice(
        &mut self,
        choice: InlineChoice,
        pending: InlineChoicePending,
        status: &'static str,
    ) -> anyhow::Result<()> {
        let previous = self.input_ui.take_composer();
        let ComposerMode::Picker(parent) = previous else {
            self.input_ui.set_composer(previous);
            anyhow::bail!("session confirmation requires an active picker");
        };
        self.input_ui
            .set_composer(ComposerMode::InlineChoice(InlineChoiceModal {
                choice,
                pending,
                parent_picker: Some(Box::new(parent)),
            }));
        self.set_status(status);
        Ok(())
    }

    /// Answer a session delete confirmation. On "delete", the picker returns
    /// at once and the delete runs in the background.
    pub(super) fn submit_sessions_delete_choice(
        &mut self,
        value: &str,
        request: SessionsDelete,
        parent: Option<Box<UiPicker>>,
    ) {
        let origin = match parent.as_deref() {
            Some(picker) if picker.is_resume_session() => DeleteOrigin::Resume,
            _ => DeleteOrigin::Hub,
        };
        self.restore_session_choice_parent(parent);
        if value != "delete" {
            return;
        }
        // Prompts refuse while a delete runs; this catches one confirmed
        // after a delete started behind the open prompt.
        if self.refuse_while_sessions_delete_runs() {
            return;
        }
        self.start_sessions_delete(request, origin);
    }

    pub(super) fn restore_session_choice_parent(&mut self, parent: Option<Box<UiPicker>>) {
        let Some(parent) = parent else {
            self.input_ui.set_composer(ComposerMode::Input);
            self.sessions_hub_state.clear();
            return;
        };
        let status = parent.restore_status();
        self.input_ui.set_composer(ComposerMode::Picker(*parent));
        self.set_status(status);
    }

    fn selected_sessions_item_value(&self) -> Option<String> {
        match self.input_ui.composer() {
            ComposerMode::Picker(picker) if picker.is_manage_sessions() => {
                picker.selected_item().map(|item| item.value.clone())
            }
            _ => None,
        }
    }
}

#[cfg(test)]
#[path = "sessions_hub_tests.rs"]
mod tests;