Skip to main content

purple_ssh/app/
keys_state.rs

1//! Consolidated Keys-tab state. Owns the discovered key list, the
2//! cursor for the master pane, the persistent activity log, and the
3//! in-flight push state.
4//!
5//! Mirrors the `TunnelState` / `ContainersOverviewState` pattern: one
6//! sub-struct per top-level tab so the `App` god-struct stays flat and
7//! every tab has a single field to consult, mutate, or snapshot.
8
9use ratatui::widgets::ListState;
10
11use super::KeyPushState;
12use crate::key_activity::KeyActivityLog;
13use crate::ssh_keys::SshKeyInfo;
14
15#[derive(Default)]
16pub struct KeysState {
17    /// Discovered SSH key files under `~/.ssh/`. Populated by
18    /// `ssh_keys::discover_keys` at startup, after host reloads, and
19    /// after successful pushes. Empty until first discover completes.
20    pub list: Vec<SshKeyInfo>,
21    /// Cursor in the Keys-tab master pane. `select()` index matches
22    /// either `list` directly or `filtered_key_indices(list, query)`
23    /// when a search query is active (translation happens at use sites).
24    pub list_state: ListState,
25    /// Persistent per-alias activity log. Loaded once at startup,
26    /// appended on every connect, flushed to `~/.purple/key_activity.json`.
27    /// Drives the activity chart and last-touch hints in the Keys tab.
28    pub activity: KeyActivityLog,
29    /// Push (ssh-copy-id equivalent) run state.
30    pub push: KeyPushState,
31}