perf(ui,watchdog): adaptive UI polling and zero-UCI cached settings context

- Feat(ui): implement adaptive polling in runtimeUiState service (1s -> 2s during active tasks, 10s idle)
- Perf(controller): cache settings snapshot in current_tick_ctx across all probe setting() calls to eliminate repeated uci_core.get_all()
- Perf(controller): reuse ctx.proxy_port in probe_proxy to eliminate duplicate proxy_port() evaluation
- Perf(watchdog): guard adaptive_normal_interval behind 120s check and clear tick context at tick boundary
- Test: add static and behavioral assertions in tests/watchdog_adaptive_intervals.sh
This commit is contained in:
Dushnilin
2026-09-15 08:37:43 +03:00
parent 1c7feb4aac
commit d6d39dac81
5 changed files with 88 additions and 10 deletions
@@ -6814,7 +6814,9 @@ function applyUiStateToStore(uiState) {
// src/tachyon/services/runtimeUiState.service.ts
var RUNTIME_UI_STATE_REFRESH_MIN_INTERVAL_MS = 500;
var RUNTIME_UI_STATE_IDLE_POLL_INTERVAL_MS = 1e4;
var RUNTIME_UI_STATE_ACTIVE_POLL_INTERVAL_MS = 500;
var RUNTIME_UI_STATE_ACTIVE_INITIAL_POLL_INTERVAL_MS = 1e3;
var RUNTIME_UI_STATE_ACTIVE_SLOW_POLL_INTERVAL_MS = 2e3;
var RUNTIME_UI_STATE_ACTIVE_SLOW_THRESHOLD_MS = 4e3;
var RUNTIME_UI_STATE_HIDDEN_POLL_INTERVAL_MS = 6e4;
var runtimeUiStateRefreshPromise = null;
var lastRuntimeUiStateRefreshAt = 0;
@@ -6823,6 +6825,7 @@ var runtimeStateResumeRefreshRegistered = false;
var runtimeStatePollTimer = null;
var runtimeStatePollingStarted = false;
var runtimeStateHasRunningAction = false;
var runningActionStartedAt = 0;
var runtimeUiStateListeners = /* @__PURE__ */ new Set();
function isDocumentVisible() {
return typeof document === "undefined" || !document.visibilityState || document.visibilityState === "visible";
@@ -6836,7 +6839,15 @@ function getNextPollDelay() {
if (!isDocumentVisible()) {
return RUNTIME_UI_STATE_HIDDEN_POLL_INTERVAL_MS;
}
return runtimeStateHasRunningAction ? RUNTIME_UI_STATE_ACTIVE_POLL_INTERVAL_MS : RUNTIME_UI_STATE_IDLE_POLL_INTERVAL_MS;
if (!runtimeStateHasRunningAction) {
runningActionStartedAt = 0;
return RUNTIME_UI_STATE_IDLE_POLL_INTERVAL_MS;
}
if (runningActionStartedAt === 0) {
runningActionStartedAt = Date.now();
}
const elapsed = Date.now() - runningActionStartedAt;
return elapsed < RUNTIME_UI_STATE_ACTIVE_SLOW_THRESHOLD_MS ? RUNTIME_UI_STATE_ACTIVE_INITIAL_POLL_INTERVAL_MS : RUNTIME_UI_STATE_ACTIVE_SLOW_POLL_INTERVAL_MS;
}
function scheduleRuntimeUiStatePoll(delay = getNextPollDelay()) {
if (!runtimeStatePollingStarted || runtimeStatePollTimer || typeof window === "undefined") {
@@ -6872,6 +6883,9 @@ async function refreshRuntimeUiState({
return void 0;
}
lastRuntimeUiStateRefreshAt = now;
if (force) {
runningActionStartedAt = now;
}
const promise = TachyonShellMethods.getUiState().then((response) => {
if (!response.success) {
return void 0;
@@ -6879,6 +6893,9 @@ async function refreshRuntimeUiState({
applyUiStateToStore(response.data);
lastRuntimeUiState = response.data;
runtimeStateHasRunningAction = hasRunningAction(response.data);
if (!runtimeStateHasRunningAction) {
runningActionStartedAt = 0;
}
notifyRuntimeUiStateListeners(response.data);
return response.data;
}).catch((error) => {