Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/chat-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ arboard = "3"
base64 = "0.22"
clap = { version = "4", features = ["derive"] }
crossterm = "0.29"
hex = "0.4.3"
ratatui = "0.29"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
17 changes: 12 additions & 5 deletions bin/chat-cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use std::path::{Path, PathBuf};
use anyhow::Result;
use arboard::Clipboard;
use crossbeam_channel::Receiver;
use logos_chat::{AccountDirectory, ChatClient, ChatStore, Event, RegistrationService, Transport};
use logos_chat::{
AccountDirectory, ChatClient, ChatStore, Event, LogosAuthVerifier, RegistrationService,
Transport,
};
use serde::{Deserialize, Serialize};

use crate::utils::now;
Expand Down Expand Up @@ -47,7 +50,7 @@ where
R: RegistrationService + AccountDirectory + Clone + Send + 'static,
S: ChatStore + Send + 'static,
{
pub client: ChatClient<T, R, S>,
pub client: ChatClient<LogosAuthVerifier, T, R, S>,
events: Receiver<Event>,
pub state: AppState,
/// Ephemeral command output — not persisted, cleared on chat switch.
Expand All @@ -65,7 +68,7 @@ where
S: ChatStore + Send,
{
pub fn new(
client: ChatClient<T, R, S>,
client: ChatClient<LogosAuthVerifier, T, R, S>,
events: Receiver<Event>,
user_name: &str,
data_dir: &Path,
Expand Down Expand Up @@ -253,7 +256,8 @@ where
Ok(Some("Help displayed".to_string()))
}
"/intro" => {
let address = self.client.addr().to_string();
// The address is bytes; hex is the shareable form users paste.
let address = hex::encode(self.client.addr());
self.add_system_message("── Your Address ──");
self.add_system_message(&address);
let clipboard_msg = match Clipboard::new().and_then(|mut cb| cb.set_text(&address))
Expand All @@ -268,10 +272,13 @@ where
if args.is_empty() {
return Ok(Some("Usage: /connect <address>".to_string()));
}
let Ok(address) = hex::decode(args) else {
return Ok(Some("Address must be hex".to_string()));
};
let initial = format!("Hello from {}!", self.user_name);
let chat_id = self
.client
.create_direct_conversation(args)
.create_direct_conversation(&address)
.map_err(|e| anyhow::anyhow!("{e:?}"))?;
self.client
.send_message(&chat_id, initial.as_bytes())
Expand Down
6 changes: 3 additions & 3 deletions bin/chat-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use anyhow::{Context, Result};
use clap::{Parser, ValueEnum};
use crossbeam_channel::Receiver;
use logos_chat::{
AccountDirectory, ChatClient, ChatStore, Event, LogosConfig, P2pConfig, RegistrationService,
RegistryPublishMode, Transport,
AccountDirectory, ChatClient, ChatStore, Event, LogosAuthVerifier, LogosConfig, P2pConfig,
RegistrationService, RegistryPublishMode, Transport,
};

use app::ChatApp;
Expand Down Expand Up @@ -161,7 +161,7 @@ fn db_path(cli: &Cli) -> Result<String> {
}

fn launch_tui<T, R, S>(
client: ChatClient<T, R, S>,
client: ChatClient<LogosAuthVerifier, T, R, S>,
events: Receiver<Event>,
cli: &Cli,
) -> Result<()>
Expand Down
Loading
Loading