feat(tui): compose and read private messages

Add private messaging to the TUI:
- 'm' opens the command bar in message mode; type '<recipient> <text>' and
  Enter sends it via the client;
- incoming messages are polled each tick into an inbox;
- 'i' toggles a centered inbox popup listing sent/received messages.

The shared command bar now carries a mode (search vs message) so the prefix,
submit action and shortcut hints follow what is being typed.
This commit is contained in:
michel
2026-07-19 13:38:36 +02:00
parent f6127411d7
commit 05b06ec2ec
5 changed files with 189 additions and 18 deletions
+32
View File
@@ -32,6 +32,29 @@ pub enum FocusedPane {
Downloads,
}
/// What the shared command bar is currently capturing input for.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommandBarMode {
Search,
Message,
}
/// Direction of a private message relative to the local user.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MessageDirection {
Incoming,
Outgoing,
}
/// A private message shown in the inbox popup.
pub struct ChatMessage {
pub direction: MessageDirection,
/// The other party: the sender for incoming, the recipient for outgoing.
pub peer: String,
pub text: String,
}
#[allow(clippy::struct_excessive_bools)]
pub struct AppState {
// Searches
pub searches: Vec<SearchEntry>,
@@ -62,6 +85,11 @@ pub struct AppState {
pub command_bar_active: bool,
pub command_bar_input: String,
pub command_bar_cursor_position: usize,
pub command_bar_mode: CommandBarMode,
// Private messages
pub messages: Vec<ChatMessage>,
pub show_messages: bool,
// Pane areas for mouse interaction
pub searches_pane_area: Option<Rect>,
@@ -104,6 +132,10 @@ impl AppState {
command_bar_active: false,
command_bar_input: String::new(),
command_bar_cursor_position: 0,
command_bar_mode: CommandBarMode::Search,
messages: Vec::new(),
show_messages: false,
searches_pane_area: None,
results_pane_area: None,
+2 -1
View File
@@ -2,6 +2,7 @@ mod app_state;
mod file_display_data;
pub use app_state::{
AppState, DownloadEntry, FocusedPane, SearchEntry, SearchStatus,
AppState, ChatMessage, CommandBarMode, DownloadEntry, FocusedPane,
MessageDirection, SearchEntry, SearchStatus,
};
pub use file_display_data::FileDisplayData;