refactor: Remove workflow-related commands and overlays from the application
This commit is contained in:
@@ -81,9 +81,7 @@ pub enum Action {
|
||||
ModelList,
|
||||
AbortTurn,
|
||||
Compact,
|
||||
RunWorkflow {
|
||||
script: String,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
/// Apply an `Action` to the application state.
|
||||
@@ -394,11 +392,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
state.workflow_engine.agents.clear();
|
||||
state.workflow_engine.findings.clear();
|
||||
}
|
||||
if message.to_lowercase().contains("complete")
|
||||
&& state.misc.overlay == Overlay::Workflow
|
||||
{
|
||||
state.misc.overlay = Overlay::None;
|
||||
}
|
||||
// popup removed, no overlay to reset
|
||||
state.push_toast(Toast {
|
||||
kind: ToastKind::Info,
|
||||
message: message.clone(),
|
||||
@@ -435,9 +429,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
crate::dto::chat::message::Role::System,
|
||||
format!("✓ {message}"),
|
||||
));
|
||||
if state.misc.overlay == Overlay::Workflow {
|
||||
state.misc.overlay = Overlay::None;
|
||||
}
|
||||
// overlay removed
|
||||
state.dirty = true;
|
||||
} else if kind == "workflow_error" {
|
||||
state.push_toast(Toast {
|
||||
@@ -450,9 +442,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
crate::dto::chat::message::Role::System,
|
||||
format!("✗ {message}"),
|
||||
));
|
||||
if state.misc.overlay == Overlay::Workflow {
|
||||
state.misc.overlay = Overlay::None;
|
||||
}
|
||||
// overlay removed
|
||||
state.dirty = true;
|
||||
} else {
|
||||
state.push_toast(Toast::new(ToastKind::Info, message));
|
||||
@@ -537,18 +527,14 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
status,
|
||||
});
|
||||
}
|
||||
if state.misc.overlay != Overlay::Workflow {
|
||||
state.misc.overlay = Overlay::Workflow;
|
||||
}
|
||||
// popup removed
|
||||
state.dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if turn_finished {
|
||||
maybe_trigger_review(state);
|
||||
if state.misc.overlay == Overlay::Workflow {
|
||||
state.misc.overlay = Overlay::None;
|
||||
}
|
||||
|
||||
}
|
||||
if turn_finished || state.dirty {
|
||||
state.dirty = true;
|
||||
@@ -610,89 +596,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
|
||||
state.dirty = true;
|
||||
}
|
||||
|
||||
Action::RunWorkflow { script } => {
|
||||
// Open the Workflow overlay so the user can see progress.
|
||||
state.misc.overlay = Overlay::Workflow;
|
||||
state.dirty = true;
|
||||
|
||||
// Reset engine state before starting.
|
||||
state.workflow_engine.agents.clear();
|
||||
state.workflow_engine.findings.clear();
|
||||
|
||||
let turn_events = state.turn_events.clone();
|
||||
let turn_events_live = state.turn_events.clone();
|
||||
|
||||
state.push_toast(Toast::new(
|
||||
ToastKind::Info,
|
||||
format!("Starting workflow: {}…", script.chars().take(40).collect::<String>()),
|
||||
));
|
||||
|
||||
let session_dir = state.session_dir.clone();
|
||||
let workspace_roots = state.workspace_roots.clone();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use crate::app::workflow::script::{ScriptPrimitive, ScriptOptions, WorkflowScript};
|
||||
use crate::app::workflow::engine::{LiveStateFn, AgentStatus};
|
||||
|
||||
// Parse the script string:
|
||||
// "prompt1 | prompt2 | prompt3" → Parallel of 3 agents
|
||||
// "prompt1 -> prompt2" → Pipeline of 2 stages
|
||||
// "prompt" → single Agent
|
||||
let parts_pipe: Vec<&str> = script.split('|').map(str::trim).collect();
|
||||
let parts_arrow: Vec<&str> = script.split("->").map(str::trim).collect();
|
||||
|
||||
let primitive = if parts_pipe.len() > 1 {
|
||||
ScriptPrimitive::Parallel(
|
||||
parts_pipe.iter().map(|p| ScriptPrimitive::Agent(p.to_string())).collect()
|
||||
)
|
||||
} else if parts_arrow.len() > 1 {
|
||||
ScriptPrimitive::Pipeline(
|
||||
parts_arrow.iter().map(|p| ScriptPrimitive::Agent(p.to_string())).collect()
|
||||
)
|
||||
} else {
|
||||
ScriptPrimitive::Agent(script.clone())
|
||||
};
|
||||
|
||||
let wf = WorkflowScript {
|
||||
name: script.chars().take(40).collect(),
|
||||
description: script.clone(),
|
||||
script: primitive,
|
||||
options: ScriptOptions::default(),
|
||||
};
|
||||
|
||||
// Build a live-state callback that pushes WorkflowAgentUpdate events
|
||||
// into the turn_events queue so the TUI panel updates in real time.
|
||||
let live: LiveStateFn = Arc::new(move |agent_id: String, agent_name: String, status: AgentStatus| {
|
||||
if let Ok(mut q) = turn_events_live.lock() {
|
||||
q.push_back(crate::app::state::runtime::TurnEvent::WorkflowAgentUpdate {
|
||||
agent_id: agent_id.clone(),
|
||||
agent_name,
|
||||
status,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let args: HashMap<String, String> = HashMap::new();
|
||||
let no_abort: Option<std::sync::Arc<std::sync::atomic::AtomicBool>> = None;
|
||||
let result = crate::app::workflow::engine::run_workflow_tracked(
|
||||
&wf, &args, &no_abort, Some(&live), &session_dir, &workspace_roots,
|
||||
);
|
||||
|
||||
let (kind, message) = match result {
|
||||
Ok(summary) => ("workflow_done".to_string(), summary),
|
||||
Err(e) => ("workflow_error".to_string(), format!("Workflow failed: {e}")),
|
||||
};
|
||||
|
||||
if let Ok(mut q) = turn_events.lock() {
|
||||
q.push_back(crate::app::state::runtime::TurnEvent::SystemNote {
|
||||
kind,
|
||||
message,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,12 +60,7 @@ pub fn apply_command(command: Command) -> Vec<Action> {
|
||||
Command::Compact => {
|
||||
vec![Action::Compact]
|
||||
}
|
||||
Command::WorkflowOpen => {
|
||||
vec![Action::OpenOverlay(Overlay::Workflow)]
|
||||
}
|
||||
Command::WorkflowRun { script } => {
|
||||
vec![Action::RunWorkflow { script }]
|
||||
}
|
||||
|
||||
Command::TodoOpen => {
|
||||
vec![Action::OpenOverlay(Overlay::Todo)]
|
||||
}
|
||||
|
||||
@@ -87,8 +87,7 @@ const COMMANDS: &[&str] = &[
|
||||
"/model",
|
||||
"/model ls",
|
||||
"/model add",
|
||||
"/workflow",
|
||||
"/workflow run",
|
||||
|
||||
"/todo",
|
||||
"/usage",
|
||||
"/compact",
|
||||
|
||||
@@ -50,7 +50,6 @@ pub enum Overlay {
|
||||
Settings,
|
||||
Bash,
|
||||
QuitConfirm,
|
||||
Workflow,
|
||||
|
||||
KeyInput,
|
||||
Editor,
|
||||
|
||||
Reference in New Issue
Block a user