feat(app): M5 step 1, the admin backend under the management app

- datadir: the data folder layout, the location file (JARVIS_DATA_DIR wins),
  free space for the wizard.
- settings_edit: the fields the five settings screens edit; apply writes only
  non-defaults, keeps unknown keys and writes nothing unless the app's own
  check passes. A memory section reaches the worker's hello.
- secrets: config/secrets.dat, DPAPI for the Windows user; the services take
  the bot token from it before JARVIS_DISCORD_TOKEN.
- logs: the log hub behind the log screen (tabs, daily files kept 14 days,
  the recent error report, a zip under 10 MB, secrets and token-shaped text
  masked); the log macros and the worker's output feed it.

Spec: app/src/admin.spec.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:35:59 +09:00
parent 07c701be54
commit 390f6f0b86
18 changed files with 1457 additions and 19 deletions

View File

@@ -14,7 +14,7 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::{Child, Command};
use tokio::sync::{broadcast, Notify};
use crate::{debug_log, error_log};
use crate::error_log;
#[derive(Debug, Clone)]
pub struct WorkerProcessOptions {
@@ -124,7 +124,7 @@ impl WorkerProcess {
}
};
shared.lock().unwrap().child_pid = child.id();
debug_log!("worker", "voice worker started pid={:?} port={port}", child.id());
crate::info_log!("worker", "voice worker started pid={:?} port={port}", child.id());
let mut ready_rx = events.subscribe();
// The worker's own logs hold timings and counts only (voice_worker.spec.md).
if let Some(out) = child.stdout.take() {
@@ -133,10 +133,10 @@ impl WorkerProcess {
let mut lines = BufReader::new(out).lines();
while let Ok(Some(line)) = lines.next_line().await {
if line.starts_with("READY ") {
debug_log!("worker", "voice worker READY after {} ms", started.elapsed().as_millis());
crate::info_log!("worker", "voice worker READY after {} ms", started.elapsed().as_millis());
let _ = events.send(ProcessEvent::Ready);
} else {
debug_log!("worker", "{line}");
worker_line(&line);
}
}
});
@@ -145,7 +145,7 @@ impl WorkerProcess {
tokio::spawn(async move {
let mut lines = BufReader::new(err).lines();
while let Ok(Some(line)) = lines.next_line().await {
debug_log!("worker", "{line}");
worker_line(&line);
}
});
}
@@ -222,3 +222,14 @@ fn spawn(opts: &WorkerProcessOptions, token: &str, port: u16) -> std::io::Result
}
cmd.spawn()
}
/// A line the voice worker printed: on stderr with debug logging, and always to the log hub (its
/// own category picks the tab; warnings and tracebacks reach the log screen without debug logging).
fn worker_line(line: &str) {
if crate::log::debug_enabled() {
eprintln!("{}", crate::log::line("worker", line));
}
if let Some(hub) = crate::logs::installed() {
hub.push_worker(line);
}
}