fix question answer sender and self-cancel feedback loop
This commit is contained in:
parent
e50173f3e1
commit
d8e64742f4
3 changed files with 31 additions and 12 deletions
|
|
@ -112,7 +112,10 @@ pub fn handle_answer(
|
|||
.answer(id, answer, answerer)
|
||||
.map_err(|e| format!("{e:#}"))?;
|
||||
tracing::info!(%id, %answerer, %asker, "question answered");
|
||||
coord.notify_agent(
|
||||
// Use answerer as the broker `from` so the asker's terminal shows
|
||||
// the real name (agent or "operator") instead of "system".
|
||||
coord.notify_agent_from(
|
||||
answerer,
|
||||
&asker,
|
||||
&hive_sh4re::HelperEvent::QuestionAnswered {
|
||||
id,
|
||||
|
|
@ -149,15 +152,22 @@ pub fn handle_cancel_loose_end(
|
|||
.map_err(|e| format!("{e:#}"))?;
|
||||
let sentinel = format!("[cancelled by {canceller}]");
|
||||
tracing::info!(%id, %canceller, %asker, "question cancelled");
|
||||
coord.notify_agent(
|
||||
&asker,
|
||||
&hive_sh4re::HelperEvent::QuestionAnswered {
|
||||
id,
|
||||
question,
|
||||
answer: sentinel.clone(),
|
||||
answerer: canceller.to_owned(),
|
||||
},
|
||||
);
|
||||
// Only notify the asker if they didn't cancel it themselves.
|
||||
// Self-cancels are already known to the canceller — sending
|
||||
// a QuestionAnswered back would cause the harness to process
|
||||
// its own cancel as an incoming answer.
|
||||
if asker != canceller {
|
||||
coord.notify_agent_from(
|
||||
canceller,
|
||||
&asker,
|
||||
&hive_sh4re::HelperEvent::QuestionAnswered {
|
||||
id,
|
||||
question,
|
||||
answer: sentinel.clone(),
|
||||
answerer: canceller.to_owned(),
|
||||
},
|
||||
);
|
||||
}
|
||||
coord.emit_question_resolved(id, &sentinel, canceller, true, target.as_deref());
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue