Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Insights: needs_you_now counts tasks only AutoFix holds

Lin (kwant bot)7f9e73b0730a
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index de45bedb..ec46793d 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -462,7 +462,7 @@ const PERSON_ITEMS = new Set<NeedsYouItem['kind']>(['autofix_suggested', 'fix_ne
/**
* The "Needs you now" count: the cards the Needs you column holds across all work, so the tile and the
- * column never disagree. The server's `needs_you_now` leaves out tasks only AutoFix items hold.
+ * column never disagree. The server's `needs_you_now` counts the same tasks.
*/
export function needsYouCount(tasks: Task[]): number {
return tasks.filter((t) => columnOfTask(t) === 'needs_you').length;
diff --git a/src/server/missions/routes.rs b/src/server/missions/routes.rs
index a88887aa..8f78aea8 100644
--- a/src/server/missions/routes.rs
+++ b/src/server/missions/routes.rs
@@ -313,9 +313,16 @@ pub async fn insights(State(state): State<AppState>, Scope(space): Scope) -> Res
}
let all = state.db.list_tasks(&space, None, None, None, 1000).await.unwrap_or_default();
let flagged: std::collections::HashSet<String> = state.db.flagged_task_ids(&space).await.unwrap_or_default().into_iter().collect();
+ // The board's Needs-you column: tasks in needs_you, flagged ones, review tasks waiting on a
+ // check approval, and tasks AutoFix holds (fix_needed, autofix_suggested, workflow_change).
+ // Cancelled tasks aren't on the board.
let mut needs_you = 0;
- for t in &all {
- if t.state == "needs_you" || flagged.contains(&t.id) || (t.state == "review" && !super::check_approvals(&state, t).await.is_empty()) {
+ for t in all.iter().filter(|t| t.state != "cancelled") {
+ if t.state == "needs_you"
+ || flagged.contains(&t.id)
+ || (t.state == "review" && !super::check_approvals(&state, t).await.is_empty())
+ || !super::autofix::needs_you(&state, t).await.is_empty()
+ {
needs_you += 1;
}
}
diff --git a/tests/mission_autofix_test.rs b/tests/mission_autofix_test.rs
index e27e23d7..3c0f1040 100644
--- a/tests/mission_autofix_test.rs
+++ b/tests/mission_autofix_test.rs
@@ -798,3 +798,27 @@ async fn running_a_held_task_twice_with_one_key_replays_the_first_200() {
let released = e.state.db.task_events(&tid, 500).await.unwrap().iter().filter(|ev| ev.kind == "released").count();
assert_eq!(released, 1);
}
+
+#[tokio::test]
+async fn insights_count_tasks_only_autofix_holds_as_needing_the_person() {
+ let e = setup().await;
+ autofix(&e, "on", 25).await;
+ // A plain ready task waits on nobody
+ let _ready = person_task(&e, json!([])).await;
+ let insights = person(&e, "GET", "/api/missions/insights", None).await;
+ assert_eq!(insights["needs_you_now"], 0, "{insights}");
+ // A failed task held only by a fix_needed item sits in the board's Needs-you column, so it counts
+ let auth = person_task(&e, json!([])).await;
+ let started = Utc::now();
+ claim(&e, &auth).await;
+ runner::after_turn(&e.state, &auth, Some("Not logged in · Please run /login"), started).await;
+ let t = task(&e, &auth).await;
+ assert_eq!(t["state"], "failed", "{t}");
+ assert_eq!(kinds(&t["needs_you"]), vec!["fix_needed".to_string()], "{t}");
+ let insights = person(&e, "GET", "/api/missions/insights", None).await;
+ assert_eq!(insights["needs_you_now"], 1, "{insights}");
+ // Cancelled, it leaves the board and the count
+ e.state.db.exec_raw_for_test(&format!("UPDATE tasks SET state = 'cancelled' WHERE id = '{auth}'")).await.unwrap();
+ let insights = person(&e, "GET", "/api/missions/insights", None).await;
+ assert_eq!(insights["needs_you_now"], 0, "{insights}");
+}