fix(runtime): isolate agent state by project (#101)
This commit is contained in:
@ -461,7 +461,12 @@ impl GetProjectWorkState {
|
||||
input: GetProjectWorkStateInput,
|
||||
) -> Result<ProjectWorkState, AppError> {
|
||||
let manifest = self.contexts.load_manifest(&input.project).await?;
|
||||
let live_by_agent = live_by_agent(self.live.live_agent_snapshots());
|
||||
let live_by_agent = live_by_agent(
|
||||
self.live
|
||||
.live_agent_snapshots()
|
||||
.into_iter()
|
||||
.filter(|snapshot| snapshot.project_id == input.project.id),
|
||||
);
|
||||
let undelivered_completions = match &self.background_tasks {
|
||||
Some(store) => Some(store.list_undelivered_completions().await),
|
||||
None => None,
|
||||
@ -482,11 +487,12 @@ impl GetProjectWorkState {
|
||||
// Tickets are crossed with the busy state: only an agent absent from
|
||||
// the manifest is dropped (this loop only visits manifest entries), so
|
||||
// the manifest boundary is naturally preserved.
|
||||
let busy = self.input.busy_state(agent.id);
|
||||
let runtime_key = domain::RuntimeAgentKey::new(input.project.id, agent.id);
|
||||
let busy = self.input.busy_state(runtime_key);
|
||||
let busy_ticket = busy.ticket();
|
||||
let tickets = self
|
||||
.queue
|
||||
.queue_for(agent.id)
|
||||
.queue_for(runtime_key)
|
||||
.into_iter()
|
||||
.map(|snapshot| ticket_state(snapshot, busy_ticket))
|
||||
.collect();
|
||||
@ -810,7 +816,9 @@ fn preview(text: &str, max_chars: usize) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn live_by_agent(snapshots: Vec<LiveSessionSnapshot>) -> HashMap<AgentId, LiveSessionSnapshot> {
|
||||
fn live_by_agent(
|
||||
snapshots: impl IntoIterator<Item = LiveSessionSnapshot>,
|
||||
) -> HashMap<AgentId, LiveSessionSnapshot> {
|
||||
let mut out = HashMap::new();
|
||||
for snapshot in snapshots {
|
||||
out.entry(snapshot.agent_id).or_insert(snapshot);
|
||||
|
||||
Reference in New Issue
Block a user