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.

Mission board: an optional check never creates a needs_you item

Lin (kwant bot)55703559878d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 613b3fde..b889775a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
and blocked work. Turn it on in Settings → Mission board. It works on phone and desktop.
### Changed
+- **An optional check never shows as needing you.** While a required check is still running, an
+ optional check waiting for your OK no longer counts in "Needs you now" or shows the amber "Waiting
+ for you" block on the receipt. You can still allow it from its row.
- **A card says "Needs you" only when a check that counts waits for your OK.** A task whose required
check is still running while an optional check waits now reads as still checking, with a grey
"1 optional check waiting" note. The quiet "Not run" optional check on a verified task has a grey
diff --git a/docs/mission-control.md b/docs/mission-control.md
index b90bbfde..6190dec3 100644
--- a/docs/mission-control.md
+++ b/docs/mission-control.md
@@ -122,7 +122,9 @@ outcome_checks(id, task_id, kind, spec JSON, required, approved, status, output_
in `review`; one waiting for approval also shows as a `check_approval` item in the task's
`needs_you` and counts in Insights `needs_you_now`. The person's own Verify (a passed `person`
check) doesn't wait for unapproved checks, but approved checks still have to pass. Optional checks
- (`required: false`) are shown but never hold, fail or verify a task.
+ (`required: false`) are shown but never hold, fail or verify a task. An optional check waiting for
+ approval is never a `needs_you` item and never counts in `needs_you_now`; it can still be approved,
+ and `checks_summary.needs_approval` counts it.
- A task with no checks stays in `review` ("not checked") until a peer review or the person verifies it.
`checks_summary` on each task: `{"status": "not_checked" | "pending" | "passed" | "failed",
@@ -207,7 +209,7 @@ claim conflict), 403 (bot token on a person route).
"needs_you": [{"kind": "question"|"approval"|"human_step"|"check_approval", "id", "text"}],
"checks_summary": {"status","passed","failed","needs_approval","required_needs_approval","total"}}
// needs_you: question/approval/human_step while working or needs_you; check_approval (id = the
-// check's id, approve it with POST /api/checks/:id/approve) while in review
+// check's id, approve it with POST /api/checks/:id/approve) while in review, for required checks only
// TaskDetail = {"task": Task, "checks": [Check], "evidence": [Evidence], "events": [Event]} (events oldest first, max 500)
// MissionDetail = {"mission": Mission, "tasks": [Task]}
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index 1a355e72..4a68264e 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -41,7 +41,7 @@ export interface Mission {
}
export interface NeedsYouItem {
- /** check_approval: a check waits for the person's OK (id = the check's id); only on tasks in review. */
+ /** check_approval: a required check waits for the person's OK (id = the check's id); only on tasks in review. Optional checks never appear here. */
kind: 'question' | 'approval' | 'human_step' | 'check_approval';
id: string;
text: string;
diff --git a/src/server/missions/mod.rs b/src/server/missions/mod.rs
index 197610a7..674980a2 100644
--- a/src/server/missions/mod.rs
+++ b/src/server/missions/mod.rs
@@ -475,13 +475,15 @@ pub async fn needs_you(state: &AppState, task: &Task) -> Vec<Value> {
.collect()
}
-/// A task in review waits on the person for each check that needs their approval
-/// (`{"kind": "check_approval", "id": <check id>, "text"}`).
+/// A task in review waits on the person for each required check that needs their approval
+/// (`{"kind": "check_approval", "id": <check id>, "text"}`). An optional check can't hold the
+/// task, so it never lands here; it can still be approved, and `checks_summary.needs_approval`
+/// still counts it.
pub async fn check_approvals(state: &AppState, task: &Task) -> Vec<Value> {
let checks = state.db.list_checks(&task.id).await.unwrap_or_default();
checks
.iter()
- .filter(|c| !c.approved)
+ .filter(|c| c.required && !c.approved)
.map(|c| {
let text = format!("Allow this check: {} {}", c.kind, c.spec_value());
json!({"kind": "check_approval", "id": c.id, "text": text.chars().take(200).collect::<String>()})
diff --git a/tests/mission_control_test.rs b/tests/mission_control_test.rs
index 2c5f91d1..37b9b148 100644
--- a/tests/mission_control_test.rs
+++ b/tests/mission_control_test.rs
@@ -526,3 +526,41 @@ async fn a_failing_optional_check_on_a_verified_task_is_recorded_and_the_task_st
assert_eq!(t["task"]["spent_tokens"], before["task"]["spent_tokens"]);
assert_eq!(t["task"]["needs_you"], json!([]));
}
+
+#[tokio::test]
+async fn only_a_required_check_waiting_for_approval_needs_the_person() {
+ let e = setup().await;
+ let (m, tasks) = mission(&e, 200_000, json!([
+ {"title": "A slow", "owner": e.bot.id, "checks": [{"kind": "file_exists", "spec": {"path": "slow.txt"}}]},
+ {"title": "B own", "owner": e.bot.id}])).await;
+ let (slow, own) = (id(&tasks[0]), id(&tasks[1]));
+ let dir = folder(&e, &id(&m)).await;
+ std::fs::write(dir.join("slow.txt"), "done").unwrap();
+ let token = turn(&e, &e.bot, "t-required-only").await;
+
+ // A required check still running plus the owner's optional check waiting: nothing is on the person
+ ok(&e, &token, "task_claim", json!({"task_id": slow})).await;
+ ok(&e, &token, "task_request_check", json!({"task_id": slow, "kind": "file_exists", "spec": {"path": "slow.txt"}, "required": false})).await;
+ let required = e.state.db.list_checks(&slow).await.unwrap().into_iter().find(|c| c.required).unwrap();
+ assert!(e.state.db.start_check(&required.id).await.unwrap(), "the required check is mid-run");
+ ok(&e, &token, "task_update", json!({"task_id": slow, "status": "review"})).await;
+ let t = task(&e, &slow).await;
+ assert_eq!(t["task"]["state"], "review", "{t}");
+ let s = &t["task"]["checks_summary"];
+ assert_eq!((s["needs_approval"].as_u64(), s["required_needs_approval"].as_u64()), (Some(1), Some(0)), "{s}");
+ assert_eq!(t["task"]["needs_you"], json!([]), "an optional check never needs the person: {t}");
+ let insights = person(&e, "GET", "/api/missions/insights", None).await;
+ assert_eq!(insights["needs_you_now"], 0, "{insights}");
+
+ // Control: the owner's own required check waits for the person, and does land in needs_you
+ ok(&e, &token, "task_claim", json!({"task_id": own})).await;
+ let added = ok(&e, &token, "task_request_check", json!({"task_id": own, "kind": "file_exists", "spec": {"path": "slow.txt"}})).await;
+ ok(&e, &token, "task_update", json!({"task_id": own, "status": "review"})).await;
+ let t = task(&e, &own).await;
+ assert_eq!(t["task"]["state"], "review", "{t}");
+ let items = t["task"]["needs_you"].as_array().unwrap();
+ assert_eq!(items.len(), 1, "{t}");
+ assert_eq!((items[0]["kind"].as_str(), items[0]["id"].as_str()), (Some("check_approval"), added["checks"][0]["id"].as_str()));
+ let insights = person(&e, "GET", "/api/missions/insights", None).await;
+ assert_eq!(insights["needs_you_now"], 1, "{insights}");
+}