feat: add engine alive indicator, debug mode, and orchestrator retry logic

This commit is contained in:
Loic Coenen
2026-05-20 20:59:58 +00:00
committed by Loic Coenen (aider)
parent e79c2ac116
commit f2993eac80
5 changed files with 139 additions and 28 deletions

View File

@@ -3,6 +3,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
@@ -15,8 +16,15 @@
#include "script.h"
#include <CarlaHost.h>
/* ---------- engine alive indicator ---------- */
static bool engine_running = false;
static bool debug_mode = false;
/* ---------- FIFO command helper ---------- */
int send_command(const char *cmd) {
if (debug_mode) {
fprintf(stderr, "DEBUG: send_command(%s)\n", cmd);
}
const char *fifo_path = getenv("LOOPER_CMD_FIFO");
if (!fifo_path) fifo_path = "/tmp/looper_cmd";
int fd = open(fifo_path, O_WRONLY | O_NONBLOCK);
@@ -162,7 +170,7 @@ static void draw_grid(void) {
}
clear();
attron(A_BOLD);
mvprintw(0,0,"JACK Looper - Client (FIFO only)");
mvprintw(0,0,"JACK Looper - Client (FIFO only) %s", engine_running ? "[online]" : "[offline]");
attroff(A_BOLD);
for (int r=0; r<GRID_ROWS; r++)
for (int c=0; c<GRID_COLS; c++)
@@ -181,6 +189,7 @@ static void draw_grid(void) {
void tui_init(void) {
initscr();
cbreak(); noecho(); keypad(stdscr, TRUE); curs_set(0);
debug_mode = (getenv("LOOPER_DEBUG") != NULL);
if (!has_colors()) { endwin(); fprintf(stderr,"No colors\n"); exit(1); }
start_color();
init_pair(COLOR_EMPTY, COLOR_WHITE, COLOR_BLACK);
@@ -234,6 +243,9 @@ void tui_run(void) {
close(fd);
}
/* Check if engine is alive by testing existence of status FIFO */
engine_running = (access(STATUS_FIFO, F_OK) == 0);
/* read any available note events (for script macros) */
int nfd = open(NOTES_FIFO, O_RDONLY | O_NONBLOCK);
if (nfd >= 0) {