TUI chat interface with real-time E2E encrypted messaging

`warzone chat [peer-fp] -s <server>` launches an interactive terminal UI:
- Header: your fingerprint, peer fingerprint, server URL
- Message area: color-coded (green=you, yellow=peer, cyan=system)
- Input bar with cursor at bottom
- Background polling every 2s for incoming messages
- Full X3DH + Double Ratchet on send/receive
- Session persistence across messages

Commands in TUI:
- /peer <fingerprint> — set who you're chatting with
- /info — show your fingerprint
- /quit or /q or Esc or Ctrl+C — exit

Usage:
  warzone chat "6baf:6d0b:4541:9cae:f06b:83da:69bc:05ee" -s http://localhost:7700

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-26 22:59:08 +04:00
parent 6d4a09a0c6
commit a298c9430c
3 changed files with 510 additions and 6 deletions

View File

@@ -49,6 +49,8 @@ enum Commands {
},
/// Launch interactive TUI chat
Chat {
/// Peer fingerprint to chat with (optional, can set with /peer in TUI)
peer: Option<String>,
/// Server URL
#[arg(short, long, default_value = "http://localhost:7700")]
server: String,
@@ -80,8 +82,16 @@ async fn main() -> anyhow::Result<()> {
Commands::Recv { server } => {
cli::recv::run(&server).await?;
}
Commands::Chat { server } => {
println!("TODO: launch TUI connected to {}", server);
Commands::Chat { peer, server } => {
// Auto-register
let _ = cli::init::register_with_server(&server).await;
let seed = keystore::load_seed()?;
let identity = seed.derive_identity();
let our_fp = identity.public_identity().fingerprint.to_string();
let db = storage::LocalDb::open()?;
tui::run_tui(our_fp, peer, server, identity, db).await?;
}
}