From c9bbd2e2e8ae575577e0d77d1454be714bcb46f3 Mon Sep 17 00:00:00 2001 From: arko33 <221298156+arko33@users.noreply.github.com> Date: Thu, 22 Oct 2026 01:51:16 +0700 Subject: [PATCH 1/2] fix: empty-autopsy fallback cleared + runtime metric count made dynamic + dock label from data + probe backoff --- packages/ghost/lib/probes.mjs | 16 ++++++++++++++++ src/components/playground/AutopsyPanel.tsx | 9 ++++++--- src/components/playground/TimelineDock.tsx | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/ghost/lib/probes.mjs b/packages/ghost/lib/probes.mjs index 707ab94..ad707e4 100644 --- a/packages/ghost/lib/probes.mjs +++ b/packages/ghost/lib/probes.mjs @@ -31,7 +31,23 @@ export function createProbes({ url, intervalMs = 4000, fetchImpl = globalThis.fe } } + // Back off when the target keeps failing (wrong URL, app down, no + // /api/health): keep the last sample slot moving but stop hammering the + // app — 5 straight failures slow the cadence 8x, 10 straight 30x. + let consecutiveFailures = 0; + function reschedule() { + if (state.timer) clearInterval(state.timer); + const slot = intervalMs * (consecutiveFailures >= 10 ? 30 : consecutiveFailures >= 5 ? 8 : 1); + state.timer = setInterval(() => void sample(), slot); + state.timer.unref?.(); + } + function push(ts, metrics, failed) { + if (failed) consecutiveFailures += 1; else consecutiveFailures = 0; + if (consecutiveFailures === 5 || consecutiveFailures === 10) { + // keep the slot bookkeeping correct while the cadence backs off + reschedule(); + } state.out({ ts, metrics, probeFailed: failed }); } diff --git a/src/components/playground/AutopsyPanel.tsx b/src/components/playground/AutopsyPanel.tsx index d31d742..919d8cb 100644 --- a/src/components/playground/AutopsyPanel.tsx +++ b/src/components/playground/AutopsyPanel.tsx @@ -210,7 +210,7 @@ export default function AutopsyPanel({
Runtime metrics - 28 samples + {session.metrics.length} samples
Fix prompt - + {autopsy?.fixPrompt ? : null}
-

{autopsy.fixPrompt}

+

+ {autopsy?.fixPrompt ?? + "No anomaly detected — nothing to heal yet. Keep recording; the engine drafts the heal prompt if a sample breaches a threshold."} +

); diff --git a/src/components/playground/TimelineDock.tsx b/src/components/playground/TimelineDock.tsx index 161caff..f7f70e9 100644 --- a/src/components/playground/TimelineDock.tsx +++ b/src/components/playground/TimelineDock.tsx @@ -106,8 +106,8 @@ export default function TimelineDock({