fix(tools): harden scheduler limits and logs

Guard scheduler system actions against pending work, serialize diagnostic log transitions, and keep speed-limit saves truthful after backend failures.\n\nNo linked issue was found for this audit.
This commit is contained in:
NimBold
2026-07-15 03:00:46 +03:30
parent 45bbca0515
commit 80a29356e0
10 changed files with 290 additions and 74 deletions
+17 -3
View File
@@ -5,6 +5,8 @@ import { invoke } from '@tauri-apps/api/core';
let isPaused = true;
let initPromise: Promise<void> | null = null;
let logPauseTransition = Promise.resolve();
let logStreamTransition = Promise.resolve();
export const initLogger = () => {
if (!initPromise) {
@@ -15,9 +17,21 @@ export const initLogger = () => {
return initPromise;
};
export const setLogPaused = async (pause: boolean) => {
isPaused = pause;
await invoke('toggle_log_pause', { pause }).catch(console.error);
export const setLogPaused = (pause: boolean): Promise<void> => {
const transition = logPauseTransition.then(async () => {
await invoke('toggle_log_pause', { pause });
isPaused = pause;
});
logPauseTransition = transition.catch(() => undefined);
return transition;
};
export const setLogStreamActive = (active: boolean): Promise<void> => {
const transition = logStreamTransition.then(async () => {
await invoke('set_log_stream_active', { active });
});
logStreamTransition = transition.catch(() => undefined);
return transition;
};
export const getLogPaused = () => isPaused;