Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ pub(super) struct Fixture {
pub(super) watch: Vec<Value>,
/// The records an `_acpmux/events` (history) page answers.
pub(super) history: Vec<Value>,
/// Records every history page answers after [`Fixture::history`], added while the fake runs.
pub(super) history_later: Arc<Mutex<Vec<Value>>>,
/// When set, the attach answer waits for one message on it (at most [`WAIT`]).
pub(super) attach_gate: Option<Arc<Mutex<Receiver<()>>>>,
/// When set, each history page and each prompt's acceptance waits for one message on it (at
/// most [`WAIT`], or until its sender is gone).
pub(super) events_gate: Option<Arc<Mutex<Receiver<()>>>>,
pub(super) prompt_gate: Option<Arc<Mutex<Receiver<()>>>>,
}

fn serve(
Expand Down Expand Up @@ -206,7 +212,12 @@ fn serve(
),
})),
"_acpmux/events" => {
Some(json!({"events": fixture.history, "hasMore": false, "lastSeq": 1}))
if let Some(gate) = &fixture.events_gate {
let _ = gate.lock().unwrap_or_else(|e| e.into_inner()).recv_timeout(WAIT);
}
let mut events = fixture.history.clone();
events.extend(fixture.history_later.lock().unwrap().iter().cloned());
Some(json!({"events": events, "hasMore": false, "lastSeq": 1}))
}
"_acpmux/typing" => {
typing_calls += 1;
Expand Down Expand Up @@ -239,6 +250,9 @@ fn serve(
reply
}
"session/prompt" => {
if let Some(gate) = &fixture.prompt_gate {
let _ = gate.lock().unwrap_or_else(|e| e.into_inner()).recv_timeout(WAIT);
}
let accepted = json!({"jsonrpc":"2.0","method":"_acpmux/prompt_accepted","params":{
"sessionId": SESSION, "promptId": params["_meta"]["acpmux"]["promptId"],
"turnId": "turn_1", "queued": false}});
Expand Down
Loading
Loading