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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Documents: read the extraction before the case, so a read letter never shows "reading…"
Lin (kwant bot)45569eddbfbb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9b77643c..2e48c630 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).- **A restart no longer leaves an audit running.** An audit cut off mid-turn by a restart ends`interrupted` and says so in the task's history; one still waiting to start runs after the restart(or is skipped if the auditor was turned off).+- **A read letter always shows its updated case.** Opening a document right as it finished reading+ could show the case still titled "Letter (reading…)".- **"Answer in chat" works when that chat is already open.** On the Mission board, "Answer in chat" and"Open the chat it came from" now close the board and show the chat even when it's the one alreadyselected underneath; before, nothing visible happened.diff --git a/src/server/document_routes.rs b/src/server/document_routes.rsindex 4cb04a61..9319a774 100644--- a/src/server/document_routes.rs+++ b/src/server/document_routes.rs@@ -89,10 +89,14 @@ pub struct DocumentView {}async fn document_view(state: &AppState, case_id: &str) -> Res {+ // The extraction first: the reader writes the case and reminders before the extraction's+ // status, so a view that sees the letter read also sees the case it updated. Read the other+ // way round, a poll landing between those writes got "read" with the case still "reading…"+ let extraction = state.db.document_extraction(case_id).await.map_err(db_error)?;let Some(c) = state.db.zombie_case(case_id).await.map_err(db_error)?.filter(|c| !c.redacted && c.source == "document") else {return Err(error(StatusCode::NOT_FOUND, "no such letter"));};- let extraction = match state.db.document_extraction(case_id).await.map_err(db_error)? {+ let extraction = match extraction {Some(e) => Some(extraction_view(state, e).await),None => None,};diff --git a/tests/documents_test.rs b/tests/documents_test.rsindex 9e4ec475..d5a6afeb 100644--- a/tests/documents_test.rs+++ b/tests/documents_test.rs@@ -373,6 +373,32 @@ async fn an_uncertain_deadline_waits_for_the_person_and_schedules_nothing() {assert_eq!(v["case"]["deadline"].as_str().unwrap().get(..10), Some("2026-11-30"));}+/// The view never shows a letter read with its case still "reading…": the reader writes the case+/// before the status, so the view reads the status first. Polled flat out while letters are read+/// (the flake: `case.title` "Letter (reading…)" next to `status: read`).+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn a_letter_shown_read_always_has_its_case_updated() {+ let e = setup_with(Stub::new(Ok(water_bill_answer().to_string()))).await;+ for n in 0..15u8 {+ let photo = e.upload("slip.png", &png(100 + n)).await;+ let (s, v) = e.create(&[&photo]).await;+ assert_eq!(s, StatusCode::ACCEPTED, "{v}");+ let case_id = v["case_id"].as_str().unwrap().to_string();+ let mut done = false;+ for _ in 0..20_000 {+ let (s, v) = e.person("GET", &format!("/api/documents/{case_id}"), None).await;+ assert_eq!(s, StatusCode::OK, "{v}");+ if v["extraction"]["status"] != "running" {+ assert_ne!(v["case"]["title"], "Letter (reading…)", "letter {n}: {v}");+ done = true;+ break;+ }+ tokio::task::yield_now().await;+ }+ assert!(done, "letter {n} was never read");+ }+}+#[tokio::test]async fn a_text_pdf_and_a_photo_are_read_in_one_model_call() {let logs = Logs::global();