Implement TUI init insert and generate workflows

This commit is contained in:
Hermes Agent
2026-08-10 09:22:55 +00:00
parent 977eb236da
commit 6ea184cbc1
8 changed files with 1213 additions and 32 deletions

View File

@@ -16,6 +16,7 @@ use ironstorage::{
};
use crate::app::{AsyncPayload, AsyncResult, RequestToken};
use crate::workflow::WorkflowSubmission;
pub struct AsyncExecutor {
sender: Sender<AsyncResult>,
@@ -23,16 +24,22 @@ pub struct AsyncExecutor {
tasks: Mutex<Vec<thread::JoinHandle<()>>>,
}
#[derive(Debug, Eq, PartialEq)]
#[derive(Debug)]
pub enum AuthenticationEvent {
Granted(String),
Failed(String),
Granted(AuthenticationTarget),
Failed { workflow: bool, message: String },
Expired,
}
#[derive(Debug)]
pub enum AuthenticationTarget {
Entry(String),
Workflow(Box<WorkflowSubmission>),
}
struct AuthenticationCompletion {
generation: u64,
entry: String,
target: AuthenticationTarget,
result: Result<NativeAuthenticationHandle, String>,
}
@@ -64,7 +71,15 @@ impl AuthenticationCoordinator {
})
}
pub fn request(&mut self, entry: String) {
pub fn request_entry(&mut self, entry: String) {
self.request(AuthenticationTarget::Entry(entry));
}
pub fn request_workflow(&mut self, submission: Box<WorkflowSubmission>) {
self.request(AuthenticationTarget::Workflow(submission));
}
fn request(&mut self, target: AuthenticationTarget) {
self.generation = self.generation.wrapping_add(1);
let generation = self.generation;
let session = self.session.clone();
@@ -76,7 +91,7 @@ impl AuthenticationCoordinator {
.map_err(|error| error.to_string());
let _ignored = sender.send(AuthenticationCompletion {
generation,
entry,
target,
result,
});
});
@@ -91,11 +106,14 @@ impl AuthenticationCoordinator {
match completion.result {
Ok(handle) => {
self.handle = Some(handle);
Some(AuthenticationEvent::Granted(completion.entry))
Some(AuthenticationEvent::Granted(completion.target))
}
Err(error) => {
self.handle = None;
Some(AuthenticationEvent::Failed(error))
Some(AuthenticationEvent::Failed {
workflow: matches!(completion.target, AuthenticationTarget::Workflow(_)),
message: error,
})
}
}
}
@@ -104,7 +122,10 @@ impl AuthenticationCoordinator {
let handle = self.handle.as_ref()?;
if let Err(error) = handle.touch_user_activity() {
self.handle = None;
return Some(AuthenticationEvent::Failed(error.to_string()));
return Some(AuthenticationEvent::Failed {
workflow: false,
message: error.to_string(),
});
}
None
}
@@ -118,7 +139,10 @@ impl AuthenticationCoordinator {
Ok(false) => None,
Err(error) => {
self.handle = None;
Some(AuthenticationEvent::Failed(error.to_string()))
Some(AuthenticationEvent::Failed {
workflow: false,
message: error.to_string(),
})
}
}
}