Skip to content

Commit 699f402

Browse files
committed
feat(orchestrator): wire todo pipeline via Bus event + auto-poke
Completes the Codebuff-style orchestrator pipeline: * BusEvent::TodoOrchestratorToggle { session_id, enabled } added * activate_auto_poke / deactivate_auto_poke publish the toggle * Server client_lifecycle.rs subscribes and sets agent.set_todo_orchestrator_enabled(enabled) With orchestrator.rs (Agent::poll_todo_pipeline) + run_once_capture hook, the end-to-end flow is: 1. User creates todos via TodoTool 2. /poke activates auto-poke (publishes BusEvent) 3. Server flips agent.todo_orchestrator_enabled = true 4. After each turn, poll_todo_pipeline spawns sub-agents (planner/file-picker/editor/reviewer/basher) for incomplete todos 5. BusEvent::TodoUpdated broadcasts after each save
1 parent be5ef97 commit 699f402

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

crates/jcode-app-core/src/server/client_lifecycle.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,17 @@ pub(super) async fn handle_client(
789789
});
790790
}
791791
}
792+
Ok(BusEvent::TodoOrchestratorToggle { session_id, enabled }) => {
793+
if session_id == client_session_id {
794+
let mut guard = agent.lock().await;
795+
guard.set_todo_orchestrator_enabled(enabled);
796+
crate::logging::info(&format!(
797+
"[orchestrator] toggled {} for session {}",
798+
if enabled { "ON" } else { "OFF" },
799+
session_id,
800+
));
801+
}
802+
}
792803
Ok(BusEvent::CompactionFinished) => {
793804
let agent = Arc::clone(&agent);
794805
let tx = client_event_tx.clone();

crates/jcode-base/src/bus.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ pub enum SessionUpdateStatus {
360360
pub enum BusEvent {
361361
ToolUpdated(ToolEvent),
362362
TodoUpdated(TodoEvent),
363+
/// Toggle orchestrator pipeline on/off for a session.
364+
TodoOrchestratorToggle { session_id: String, enabled: bool },
363365
SubagentStatus(SubagentStatus),
364366
ManualToolCompleted(ManualToolCompleted),
365367
BatchProgress(BatchProgress),

crates/jcode-tui/src/tui/app/commands.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ pub(super) fn clear_queued_poke_messages(app: &mut App) -> usize {
104104
pub(super) fn disable_auto_poke(app: &mut App) -> usize {
105105
let cleared = clear_queued_poke_messages(app);
106106
app.auto_poke_incomplete_todos = false;
107+
crate::bus::Bus::global().publish(crate::bus::BusEvent::TodoOrchestratorToggle {
108+
session_id: app.session.id.clone(),
109+
enabled: false,
110+
});
107111
cleared
108112
}
109113

@@ -252,6 +256,11 @@ pub(super) fn activate_auto_poke(app: &mut App) -> PokeActivation {
252256
let incomplete = incomplete_poke_todos(app);
253257
app.auto_poke_incomplete_todos = true;
254258
app.set_status_notice("Poke: ON");
259+
// Broadcast orchestrator enable so the Agent spawns sub-agents.
260+
crate::bus::Bus::global().publish(crate::bus::BusEvent::TodoOrchestratorToggle {
261+
session_id: app.session.id.clone(),
262+
enabled: true,
263+
});
255264

256265
if incomplete.is_empty() {
257266
return PokeActivation::EnabledNoIncomplete;

0 commit comments

Comments
 (0)