style: cargo fmt for v1.7.99-alpha release gate
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
144c4a2872
commit
83bb589ea6
@@ -65,11 +65,13 @@ pub(super) async fn run_assist(
|
||||
"AssistQuery denied — sender not permitted by assistant policy"
|
||||
);
|
||||
// Silent on the wire (no airtime spent on denials); surface to the UI.
|
||||
let _ = state.event_tx.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: Some("denied".to_string()),
|
||||
});
|
||||
let _ = state
|
||||
.event_tx
|
||||
.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: Some("denied".to_string()),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,22 +79,31 @@ pub(super) async fn run_assist(
|
||||
{
|
||||
let mut inflight = state.assist_inflight.write().await;
|
||||
if !inflight.insert(asker) {
|
||||
warn!(from = asker, "AssistQuery dropped — asker already has one in flight");
|
||||
warn!(
|
||||
from = asker,
|
||||
"AssistQuery dropped — asker already has one in flight"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let _ = state.event_tx.send(super::super::types::MeshEvent::AssistQueryReceived {
|
||||
from_contact_id: asker,
|
||||
prompt: prompt.clone(),
|
||||
});
|
||||
let _ = state
|
||||
.event_tx
|
||||
.send(super::super::types::MeshEvent::AssistQueryReceived {
|
||||
from_contact_id: asker,
|
||||
prompt: prompt.clone(),
|
||||
});
|
||||
|
||||
let (backend, configured_model) = {
|
||||
let a = state.assistant.read().await;
|
||||
(a.backend.clone(), a.model.clone())
|
||||
};
|
||||
let is_claude = backend == "claude";
|
||||
let default_model = if is_claude { CLAUDE_DEFAULT_MODEL } else { DEFAULT_MODEL };
|
||||
let default_model = if is_claude {
|
||||
CLAUDE_DEFAULT_MODEL
|
||||
} else {
|
||||
DEFAULT_MODEL
|
||||
};
|
||||
let model = model_override
|
||||
.or(configured_model)
|
||||
.unwrap_or_else(|| default_model.to_string());
|
||||
@@ -108,20 +119,24 @@ pub(super) async fn run_assist(
|
||||
match result {
|
||||
Ok(answer) => {
|
||||
send_reply(&state, &reply, req_id, &answer).await;
|
||||
let _ = state.event_tx.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: None,
|
||||
});
|
||||
let _ = state
|
||||
.event_tx
|
||||
.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: None,
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(req_id, "AI query failed: {}", e);
|
||||
send_failure(&state, &reply, req_id, "AI unavailable").await;
|
||||
let _ = state.event_tx.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: Some(e.to_string()),
|
||||
});
|
||||
let _ = state
|
||||
.event_tx
|
||||
.send(super::super::types::MeshEvent::AssistResponseReady {
|
||||
req_id,
|
||||
to_contact_id: asker,
|
||||
error: Some(e.to_string()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +234,10 @@ async fn send_typed_chunks(state: &Arc<MeshState>, dest_contact_id: u32, req_id:
|
||||
let chunks: Vec<String> = if chars.is_empty() {
|
||||
vec![String::new()]
|
||||
} else {
|
||||
chars.chunks(CHUNK_CHARS).map(|c| c.iter().collect()).collect()
|
||||
chars
|
||||
.chunks(CHUNK_CHARS)
|
||||
.map(|c| c.iter().collect())
|
||||
.collect()
|
||||
};
|
||||
let last = chunks.len().saturating_sub(1);
|
||||
for (i, chunk) in chunks.into_iter().enumerate() {
|
||||
@@ -337,7 +355,10 @@ async fn call_claude(data_dir: &Path, model: &str, prompt: &str) -> anyhow::Resu
|
||||
let text = json
|
||||
.get("content")
|
||||
.and_then(|c| c.as_array())
|
||||
.and_then(|arr| arr.iter().find_map(|b| b.get("text").and_then(|t| t.as_str())))
|
||||
.and_then(|arr| {
|
||||
arr.iter()
|
||||
.find_map(|b| b.get("text").and_then(|t| t.as_str()))
|
||||
})
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
if text.trim().is_empty() {
|
||||
|
||||
@@ -340,9 +340,7 @@ async fn handle_channel_payload(
|
||||
// seeded peer instead of creating a duplicate chat thread. Not stored as
|
||||
// a chat message.
|
||||
if let Ok(text) = std::str::from_utf8(payload) {
|
||||
if let Some((did, ed_hex, x_hex)) =
|
||||
super::super::protocol::parse_identity_broadcast(text)
|
||||
{
|
||||
if let Some((did, ed_hex, x_hex)) = super::super::protocol::parse_identity_broadcast(text) {
|
||||
// Ignore our own identity echoed back by the radio/channel.
|
||||
if ed_hex.eq_ignore_ascii_case(&state.our_ed_pubkey_hex) {
|
||||
return;
|
||||
|
||||
@@ -433,7 +433,10 @@ pub(super) async fn run_mesh_session(
|
||||
our_ed_pubkey_hex,
|
||||
our_x25519_pubkey_hex,
|
||||
);
|
||||
if let Err(e) = device.send_channel_text(0, identity_advert.as_bytes()).await {
|
||||
if let Err(e) = device
|
||||
.send_channel_text(0, identity_advert.as_bytes())
|
||||
.await
|
||||
{
|
||||
warn!("Failed to broadcast archipelago identity: {}", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,11 @@ async fn fire_due(scheduler: &Arc<MeshScheduler>, state: &Arc<MeshState>) {
|
||||
if failed.contains(&m.id) {
|
||||
m.attempts += 1;
|
||||
if m.attempts >= MAX_ATTEMPTS {
|
||||
warn!(id = m.id, attempts = m.attempts, "Dropping undeliverable scheduled message");
|
||||
warn!(
|
||||
id = m.id,
|
||||
attempts = m.attempts,
|
||||
"Dropping undeliverable scheduled message"
|
||||
);
|
||||
to_remove.push(m.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user