fix(app): a worker run's late lines keep its run's secrets masked

Each worker run's log sink keeps the values masked when it started (its secrets in use), so a
line still being logged after a stop gave up waiting, and after the next start replaced the values
in use, is still masked. The debug echo on stderr is masked the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 10:19:15 +09:00
parent fba258821b
commit 71f9b0cd54
4 changed files with 87 additions and 9 deletions

View File

@@ -120,7 +120,18 @@ impl LogHub {
/// A line of the voice worker's output: its `[ category ]` prefix names the tab (stt, llm, tts,
/// else worker); a Python warning or traceback line is a warning.
/// Every value masked right now (stored and in use). A worker run keeps these for its lines
/// (`push_worker_masked`), so a line it writes late is masked even after the next start.
pub fn masked_values(&self) -> Vec<String> {
self.state.lock().unwrap().masked()
}
pub fn push_worker(&self, line: &str) {
self.push_worker_masked(line, &[]);
}
/// `push_worker`, also masking `extra` (the values of the run that wrote the line).
pub fn push_worker_masked(&self, line: &str, extra: &[String]) {
let (cat, text) = match line.strip_prefix('[').and_then(|r| r.split_once(']')) {
Some((c, rest)) => (c.trim(), rest.trim_start()),
None => ("worker", line),
@@ -131,14 +142,20 @@ impl LogHub {
};
let level = if text.contains("Error") || text.contains("Traceback") { Level::Error }
else if text.contains("Warning") { Level::Warn } else { Level::Info };
self.push_at(Local::now(), level, tab, text);
self.push_masked(Local::now(), level, tab, text, extra);
}
fn push_at(&self, at: DateTime<Local>, level: Level, tab: &str, text: &str) {
self.push_masked(at, level, tab, text, &[]);
}
fn push_masked(&self, at: DateTime<Local>, level: Level, tab: &str, text: &str, extra: &[String]) {
let mut s = self.state.lock().unwrap();
// Masked before it is kept or written, so a secret replaced or removed later (the hub then
// no longer knows the old value) never shows on the screen, in a copy, a file or an export.
let text = redact(text, &s.masked());
let mut masks = s.masked();
masks.extend(extra.iter().cloned());
let text = redact(text, &masks);
let line = LogLine { seq: s.next_seq, at_ms: at.timestamp_millis(), level, tab: tab.into(), text };
s.next_seq += 1;
if let Some(dir) = s.dir.clone() {