forked from NationTech/harmony
feat(examples/tui): add TUI example with harmony integration
- Create `Cargo.toml` for the new TUI example under `examples/tui` - Implement basic `main.rs` that initializes Maestro and launches the TUI - Update `harmony_tui/src/lib.rs` to handle async score execution gracefully
This commit is contained in:
@@ -61,7 +61,7 @@ enum HarmonyTuiEvent {
|
||||
impl HarmonyTUI {
|
||||
pub fn new(maestro: Maestro) -> Self {
|
||||
let maestro = Arc::new(maestro);
|
||||
let (handle, sender) = Self::start_channel(maestro.clone());
|
||||
let (_handle, sender) = Self::start_channel(maestro.clone());
|
||||
let score = ScoreListWidget::new(Self::scores_list(&maestro), sender);
|
||||
|
||||
HarmonyTUI {
|
||||
@@ -83,14 +83,17 @@ impl HarmonyTUI {
|
||||
HarmonyTuiEvent::LaunchScore(score_item) => {
|
||||
let maestro = maestro.clone();
|
||||
|
||||
let interpretation_result =
|
||||
let joinhandle_result =
|
||||
tokio::spawn(async move { maestro.interpret(score_item.0).await })
|
||||
.await;
|
||||
|
||||
match interpretation_result {
|
||||
Ok(success) => info!("Score execution successful {success:?}"),
|
||||
Err(e) => {
|
||||
error!("Score execution failed {:#?}", e);
|
||||
match joinhandle_result {
|
||||
Ok(interpretation_result) => match interpretation_result {
|
||||
Ok(success) => info!("Score execution successful {success:?}"),
|
||||
Err(error) => error!("Score failed {error:?}"),
|
||||
},
|
||||
Err(joinhandle_failure) => {
|
||||
error!("Score execution TASK FAILED! {:#?}", joinhandle_failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user