Skip to content

Commit aa7b8d7

Browse files
pmaxhoganclaude
andcommitted
fix(app): rebase onto main, re-home debug-mode watchdog into the #312 quit drain
Rebases wave-1-debug-diag onto origin/main now that #310-#316 merged (#312's quit-path restructuring in particular). Structural follow-up: - The debug-logging-mode watchdog (debug_mode.rs) previously used the detached memlog.rs pattern (no shutdown tracking). #312 replaced the old shutdown_orchestrators() with a proper ShutdownHandles/ drain_shutdown_handles structure that every other periodic background task (updater, telemetry, iostat, and now #311's bottleneck sampler) registers into for a no-orphan quit drain. Re-homed the watchdog into that same structure: a new DebugModeRuntime (task + shutdown watch, no shared hub - the watchdog only reads/writes settings directly) on AppState, set_debug_mode_task/shutdown_debug_mode_task mirroring set_bottleneck_task/shutdown_bottleneck_task exactly, a debug_mode field on ShutdownHandles, and spawn_watchdog now runs the same select!-on-shutdown-or-tick loop bottleneck_hub/iostat_hub use instead of a bare loop. - Added app_state::tests::debug_mode_runtime_task_and_shutdown_round_trip, mirroring bottleneck's round-trip test. - privacy.png (light+dark) and 9 shell.spec.ts baselines (light+dark) regenerated via `just visual-update` (Docker) - the shell baselines drifted independently of this PR's own diff (same delta across every scenario in both themes), consistent with normal headless-Chromium rendering drift between visual-update runs; all 106 visual specs pass against the regenerated set. No other conflicts: README.md, dtos.rs, settings.rs's redaction code, en-US.json, Activity.vue, and fixtures.ts all auto-merged cleanly with #311's bottleneck-tile additions coexisting alongside this PR's debug logging toggle and diagnostic-bundle changes. Verified after rebase: cargo test -p driven-app --lib (494 passed), cargo clippy --workspace --all-targets -- -D warnings (clean), cargo fmt --all --check (clean), pnpm lint (0 errors), pnpm format:check (clean), pnpm test:unit (861 passed, 64 files), pnpm build / vue-tsc (clean). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xKUm9vH4ifb5LHR5szy1v
1 parent c34856a commit aa7b8d7

21 files changed

Lines changed: 38 additions & 1 deletion

src-tauri/src/app_state.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub struct AppState {
309309
/// sampling runtime (the Activity dashboard's Bottleneck stat tile).
310310
bottleneck: BottleneckRuntime,
311311
/// issue #309: the debug-logging-mode 24h auto-off watchdog's task handle
312-
/// + shutdown signal, so the app-quit drain joins it with no orphan
312+
/// and shutdown signal, so the app-quit drain joins it with no orphan
313313
/// (mirrors [`UpdaterRuntime`]/[`IostatRuntime`]). No shared "hub" field
314314
/// like those two - the watchdog only reads/writes the persisted settings
315315
/// KV directly, nothing else on `AppState` needs to observe it.
@@ -2180,6 +2180,43 @@ pub(crate) mod tests {
21802180
let _ = std::fs::remove_dir_all(dir);
21812181
}
21822182

2183+
#[tokio::test]
2184+
async fn debug_mode_runtime_task_and_shutdown_round_trip() {
2185+
// Issue #309: the debug-logging-mode watchdog's runtime bookkeeping.
2186+
// No hub getter to cover (unlike bottleneck/iostat) - just the
2187+
// set/shutdown task pair, mirrors
2188+
// `bottleneck_runtime_hub_task_and_shutdown_round_trip`.
2189+
let (state, dir) = temp_state().await;
2190+
let app_state = AppState::new(
2191+
state,
2192+
HashMap::new(),
2193+
RemoteMode::Fake,
2194+
default_fake_registry(),
2195+
);
2196+
2197+
// No task registered yet: shutdown is a safe no-op.
2198+
assert!(app_state.shutdown_debug_mode_task().is_none());
2199+
2200+
// Register a task that exits promptly on the shutdown signal (the
2201+
// real watchdog's own shape), then confirm shutdown signals + hands
2202+
// back the handle so the quit drain can join it.
2203+
let (shutdown_tx, mut shutdown_rx) = watch::channel(false);
2204+
let task = tokio::spawn(async move {
2205+
let _ = shutdown_rx.changed().await;
2206+
});
2207+
app_state.set_debug_mode_task(task, shutdown_tx);
2208+
2209+
let handle = app_state
2210+
.shutdown_debug_mode_task()
2211+
.expect("the just-registered task round-trips");
2212+
handle.await.unwrap();
2213+
2214+
// Taken: a second shutdown call is again a safe no-op.
2215+
assert!(app_state.shutdown_debug_mode_task().is_none());
2216+
2217+
let _ = std::fs::remove_dir_all(dir);
2218+
}
2219+
21832220
#[tokio::test]
21842221
async fn vss_helper_manager_installs_and_shutdown_is_noop() {
21852222
// Issue #25: AppState owns the least-privilege VSS helper broker manager -
161 Bytes
Loading
1.29 KB
Loading
1.39 KB
Loading
1.4 KB
Loading
1.18 KB
Loading
1.4 KB
Loading
1.41 KB
Loading
1.18 KB
Loading
444 Bytes
Loading

0 commit comments

Comments
 (0)