huskies: merge 1143 story Decouple LLM environmental awareness from chat transport — persona-keyed sessions and a real-time event subscription
This commit is contained in:
@@ -132,6 +132,34 @@ pub fn subscribe_status(tx: mpsc::UnboundedSender<WsResponse>, mut subscription:
|
||||
});
|
||||
}
|
||||
|
||||
/// Spawn a background task that forwards real-time pipeline-transition events to
|
||||
/// the client, filtered to those visible to `persona` based on its scope filter.
|
||||
///
|
||||
/// Each matching event is delivered as a [`WsResponse::PipelineEvent`] frame.
|
||||
/// Events that occur while no subscriber is connected are NOT delivered here;
|
||||
/// [`crate::llm_session::assemble_prompt_context`] catches up on those at turn time.
|
||||
pub fn subscribe_persona_pipeline_events(tx: mpsc::UnboundedSender<WsResponse>, persona: String) {
|
||||
let Some(mut rx) = crate::pipeline_event_bus::subscribe() else {
|
||||
return;
|
||||
};
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(event) => {
|
||||
if crate::pipeline_event_bus::event_matches_persona(&event, &persona) {
|
||||
let line = crate::pipeline_event_bus::render_event(&event);
|
||||
if tx.send(WsResponse::PipelineEvent { line }).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(broadcast::error::RecvError::Lagged(_)) => continue,
|
||||
Err(broadcast::error::RecvError::Closed) => break,
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Spawn a background task that forwards reconciliation events to the client.
|
||||
pub fn subscribe_reconciliation(
|
||||
tx: mpsc::UnboundedSender<WsResponse>,
|
||||
|
||||
@@ -127,6 +127,13 @@ pub enum WsResponse {
|
||||
StatusUpdate {
|
||||
event: StatusEvent,
|
||||
},
|
||||
/// A real-time pipeline-transition event pushed to the client as it happens.
|
||||
///
|
||||
/// Carries the same compact audit-line format used in `<system-reminder>`
|
||||
/// blocks so that LLM-aware clients can consume it without additional parsing.
|
||||
PipelineEvent {
|
||||
line: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -23,6 +23,7 @@ pub use dispatch::{
|
||||
};
|
||||
pub use io::{
|
||||
check_onboarding, load_initial_pipeline_state, load_recent_logs, load_wizard_state,
|
||||
subscribe_logs, subscribe_reconciliation, subscribe_status, subscribe_watcher,
|
||||
subscribe_logs, subscribe_persona_pipeline_events, subscribe_reconciliation, subscribe_status,
|
||||
subscribe_watcher,
|
||||
};
|
||||
pub use message::{WizardStepInfo, WsResponse};
|
||||
|
||||
Reference in New Issue
Block a user