v0.0.24: ETH display in TUI header/messages, web peer resolve, click-focus
TUI: - Header shows peer ETH address (resolved on /peer set) - Own messages show ETH format - Resolve display shows full formatted fingerprint (xxxx:xxxx:...) - peer_eth field stored on App for header display Web: - Pasting 0x address in peer input box now resolves via /v1/resolve/ - Send path resolves 0x/@ before encrypting - Click messages area → focuses text input - Own messages show ETH format Version: 0.0.23 → 0.0.24, SW cache wz-v4 → wz-v5 Build script: --local, --local-ship, --local-clean commands Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -371,6 +371,8 @@ impl App {
|
||||
if text.starts_with("/peer ") || text.starts_with("/p ") {
|
||||
let text = if text.starts_with("/p ") { format!("/peer {}", &text[3..]) } else { text.clone() };
|
||||
let raw = text[6..].trim().to_string();
|
||||
let is_eth_input = raw.starts_with("0x") || raw.starts_with("0X");
|
||||
let eth_input = if is_eth_input { Some(raw.clone()) } else { None };
|
||||
let fp = if raw.starts_with('@') {
|
||||
match self.resolve_alias(&raw[1..], client).await {
|
||||
Some(resolved) => resolved,
|
||||
@@ -389,9 +391,22 @@ impl App {
|
||||
self.add_message(ChatLine { sender: "system".into(), text: "Cannot set yourself as peer".into(), is_system: true, is_self: false, message_id: None, timestamp: Local::now() });
|
||||
return;
|
||||
}
|
||||
// Resolve peer ETH for display
|
||||
if is_eth_input {
|
||||
self.peer_eth = eth_input;
|
||||
} else {
|
||||
// Try to look up ETH for this fingerprint
|
||||
let resolve_url = format!("{}/v1/resolve/{}", client.base_url, normfp(&fp));
|
||||
if let Ok(resp) = client.client.get(&resolve_url).send().await {
|
||||
if let Ok(data) = resp.json::<serde_json::Value>().await {
|
||||
self.peer_eth = data.get("eth_address").and_then(|v| v.as_str()).map(String::from);
|
||||
}
|
||||
}
|
||||
}
|
||||
let display = self.peer_eth.as_deref().unwrap_or(&fp);
|
||||
self.add_message(ChatLine {
|
||||
sender: "system".into(),
|
||||
text: format!("Peer set to {}", fp),
|
||||
text: format!("Peer set to {}", display),
|
||||
is_system: true,
|
||||
is_self: false,
|
||||
message_id: None, timestamp: Local::now(),
|
||||
@@ -938,7 +953,11 @@ impl App {
|
||||
Ok(resp) => {
|
||||
if let Ok(data) = resp.json::<serde_json::Value>().await {
|
||||
if let Some(fp) = data.get("fingerprint").and_then(|v| v.as_str()) {
|
||||
self.add_message(ChatLine { sender: "system".into(), text: format!("{} → {}", addr, &fp[..fp.len().min(16)]), is_system: true, is_self: false, message_id: None, timestamp: Local::now() });
|
||||
// Format fingerprint with colons: xxxx:xxxx:xxxx:...
|
||||
let formatted: String = fp.chars().enumerate()
|
||||
.flat_map(|(i, c)| if i > 0 && i % 4 == 0 { vec![':', c] } else { vec![c] })
|
||||
.collect();
|
||||
self.add_message(ChatLine { sender: "system".into(), text: format!("{} → {}", addr, formatted), is_system: true, is_self: false, message_id: None, timestamp: Local::now() });
|
||||
return Some(fp.to_string());
|
||||
}
|
||||
if let Some(err) = data.get("error") {
|
||||
|
||||
@@ -48,10 +48,12 @@ impl App {
|
||||
.split(frame.area());
|
||||
|
||||
// Header
|
||||
let peer_str = self
|
||||
.peer_fp
|
||||
.as_deref()
|
||||
.unwrap_or("no peer");
|
||||
let peer_str = match (&self.peer_eth, &self.peer_fp) {
|
||||
(Some(eth), _) => format!("{}...", ð[..eth.len().min(12)]),
|
||||
(None, Some(fp)) => fp.clone(),
|
||||
(None, None) => "no peer".to_string(),
|
||||
};
|
||||
let peer_str = peer_str.as_str();
|
||||
let is_connected = self.connected.load(Ordering::Relaxed);
|
||||
let (conn_indicator, conn_color) = if is_connected {
|
||||
(" \u{25CF}", Color::Green) // ●
|
||||
|
||||
@@ -43,6 +43,8 @@ pub struct App {
|
||||
pub pending_files: Arc<Mutex<HashMap<String, PendingFileTransfer>>>,
|
||||
/// Our ETH address (derived from seed).
|
||||
pub our_eth: String,
|
||||
/// Current peer's ETH address (resolved on /peer set).
|
||||
pub peer_eth: Option<String>,
|
||||
/// Scroll offset from bottom (0 = pinned to newest).
|
||||
pub scroll_offset: usize,
|
||||
/// Whether the WebSocket connection is active.
|
||||
@@ -123,6 +125,7 @@ impl App {
|
||||
receipts: Arc::new(Mutex::new(HashMap::new())),
|
||||
pending_files: Arc::new(Mutex::new(HashMap::new())),
|
||||
our_eth,
|
||||
peer_eth: None,
|
||||
scroll_offset: 0,
|
||||
connected: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user