-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(tui): count unreconciled subagents against the cap #2505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -938,7 +938,7 @@ fn test_running_count_ignores_running_status_without_task_handle() { | |
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_running_count_ignores_finished_task_handles() { | ||
| async fn test_running_count_counts_running_agents_until_status_reconciles() { | ||
| let mut manager = SubAgentManager::new(PathBuf::from("."), 1); | ||
| let (input_tx, _input_rx) = mpsc::unbounded_channel(); | ||
| let mut agent = SubAgent::new( | ||
|
|
@@ -953,17 +953,14 @@ async fn test_running_count_ignores_finished_task_handles() { | |
| "boot_test".to_string(), | ||
| ); | ||
| agent.status = SubAgentStatus::Running; | ||
| let handle = tokio::spawn(async {}); | ||
| handle.await.expect("dummy task should finish immediately"); | ||
| agent.task_handle = Some(tokio::spawn(async {})); | ||
| if let Some(handle) = agent.task_handle.as_ref() { | ||
| while !handle.is_finished() { | ||
| tokio::task::yield_now().await; | ||
| } | ||
| let finished_handle = tokio::spawn(async {}); | ||
| while !finished_handle.is_finished() { | ||
| tokio::task::yield_now().await; | ||
| } | ||
| agent.task_handle = Some(finished_handle); | ||
|
Comment on lines
+956
to
+960
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a busy-yield loop ( let (tx, rx) = tokio::sync::oneshot::channel();
let finished_handle = tokio::spawn(async move {
let _ = tx.send(());
});
let _ = rx.await;
while !finished_handle.is_finished() {
tokio::task::yield_now().await;
}
agent.task_handle = Some(finished_handle); |
||
| manager.agents.insert(agent.id.clone(), agent); | ||
|
|
||
| assert_eq!(manager.running_count(), 0); | ||
| assert_eq!(manager.running_count(), 1); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for
agent.task_handle.is_none()followed by returningfalseand then returningtruecan be simplified to directly returningagent.task_handle.is_some(). This is more idiomatic and concise.