huskies: merge 535_bug_chat_status_number_and_mcp_tool_status_still_read_from_filesystem_broken_after_530

This commit is contained in:
dave
2026-04-10 19:01:31 +00:00
parent bc2b1e244c
commit 40893a8cb1
2 changed files with 105 additions and 60 deletions
+22 -10
View File
@@ -158,19 +158,13 @@ pub(super) async fn tool_status(args: &Value, ctx: &AppContext) -> Result<String
let root = ctx.state.get_project_root()?;
// Read from CRDT/DB content store — verify the item is in 2_current.
let typed_item = crate::pipeline_state::read_typed(story_id)
// Read from CRDT/DB content store — works for stories in any pipeline stage.
let _typed_item = crate::pipeline_state::read_typed(story_id)
.map_err(|e| format!("Failed to read pipeline state: {e}"))?
.ok_or_else(|| format!(
"Story '{story_id}' not found in work/2_current/. Check the story_id and ensure it is in the current stage."
"Story '{story_id}' not found in the pipeline."
))?;
if typed_item.stage.dir_name() != "2_current" {
return Err(format!(
"Story '{story_id}' not found in work/2_current/. Check the story_id and ensure it is in the current stage."
));
}
let contents = crate::db::read_content(story_id).ok_or_else(|| {
format!("Story '{story_id}' has no content in the content store.")
})?;
@@ -334,7 +328,7 @@ mod tests {
let ctx = crate::http::context::AppContext::new_test(tmp.path().to_path_buf());
let result = tool_status(&json!({"story_id": "999_story_nonexistent"}), &ctx).await;
assert!(result.is_err());
assert!(result.unwrap_err().contains("not found in work/2_current/"));
assert!(result.unwrap_err().contains("not found in the pipeline"));
}
#[tokio::test]
@@ -362,4 +356,22 @@ mod tests {
assert_eq!(ac[1]["text"], "Second criterion");
assert_eq!(ac[1]["checked"], true);
}
#[tokio::test]
async fn tool_status_works_for_story_in_backlog() {
let tmp = tempdir().unwrap();
crate::db::ensure_content_store();
let story_content = "---\nname: Backlog Story\n---\n\n## Acceptance Criteria\n\n- [ ] One thing\n";
crate::db::write_item_with_content("9887_story_backlog_test", "1_backlog", story_content);
let ctx = crate::http::context::AppContext::new_test(tmp.path().to_path_buf());
let result = tool_status(&json!({"story_id": "9887_story_backlog_test"}), &ctx)
.await
.unwrap();
let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
assert_eq!(parsed["story_id"], "9887_story_backlog_test");
assert_eq!(parsed["front_matter"]["name"], "Backlog Story");
}
}