fix(call-to-play): compact terminal histories
The 4,096-event store retained every completed call forever and local commands only reported that they reached the queue. Once the bound was reached, GUI actions could therefore fail with no user-visible result. The CLI snapshot wait could also be satisfied by an unrelated live event. Keep the complete event and chat history for every active call so late joiners receive full context. When the creator starts or cancels a call, replace its history with a single terminal tombstone; this bounds retained payload while still healing peers that missed the live terminal action. Publish commands now reply with the actual store result, and CLI snapshots use a direct reply. Test Plan: - `just fmt` -- passed - `just clippy` -- passed - `just test` -- passed, including full-cap terminal compaction - `just build` -- passed - `just peer-cli-tests S48` -- passed - `git diff --cached --check` -- passed
This commit is contained in:
@@ -40,6 +40,7 @@ use tauri_plugin_shell::{
|
||||
use tokio::sync::{
|
||||
RwLock,
|
||||
mpsc::{UnboundedReceiver, UnboundedSender},
|
||||
oneshot,
|
||||
};
|
||||
use tracing::{Event, Level, Metadata, Subscriber, field::Visit};
|
||||
use tracing_subscriber::{
|
||||
@@ -285,7 +286,10 @@ async fn request_call_to_play_events(
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
if peer_ctrl.send(PeerCommand::GetCallToPlayEvents).is_err() {
|
||||
if peer_ctrl
|
||||
.send(PeerCommand::GetCallToPlayEvents { reply: None })
|
||||
.is_err()
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
Ok(state.inner().local_peer_id.read().await.clone())
|
||||
@@ -295,16 +299,18 @@ async fn request_call_to_play_events(
|
||||
async fn publish_call_to_play(
|
||||
event: CallToPlayEvent,
|
||||
state: tauri::State<'_, LanSpreadState>,
|
||||
) -> tauri::Result<bool> {
|
||||
) -> Result<bool, String> {
|
||||
let peer_ctrl = state.inner().peer_ctrl.read().await.clone();
|
||||
let Some(peer_ctrl) = peer_ctrl else {
|
||||
log::warn!("Peer system not initialized yet");
|
||||
return Ok(false);
|
||||
};
|
||||
|
||||
Ok(peer_ctrl
|
||||
.send(PeerCommand::PublishCallToPlay(event))
|
||||
.is_ok())
|
||||
let (reply, result) = oneshot::channel();
|
||||
peer_ctrl
|
||||
.send(PeerCommand::PublishCallToPlay { event, reply })
|
||||
.map_err(|err| err.to_string())?;
|
||||
result.await.map_err(|err| err.to_string())?.map(|()| true)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user