diff --git a/src/resources/extensions/bg-shell/bg-events.js b/src/resources/extensions/bg-shell/bg-events.js index 97c271d44..d8440ac57 100644 --- a/src/resources/extensions/bg-shell/bg-events.js +++ b/src/resources/extensions/bg-shell/bg-events.js @@ -18,7 +18,7 @@ import { MAX_EVENTS } from "./types.js"; /** Pending alerts to inject into the next agent context */ export let pendingAlerts = []; -const MAX_PENDING_ALERTS = 50; +export const MAX_PENDING_ALERTS = 50; /** Replace the pendingAlerts array (used by the extension entry point) */ export function setPendingAlerts(alerts) { diff --git a/src/resources/extensions/bg-shell/process-manager.js b/src/resources/extensions/bg-shell/process-manager.js index d1837ea0a..7299afc1d 100644 --- a/src/resources/extensions/bg-shell/process-manager.js +++ b/src/resources/extensions/bg-shell/process-manager.js @@ -23,7 +23,7 @@ import { DEAD_PROCESS_TTL, MAX_BUFFER_LINES } from "./types.js"; import { formatUptime, restoreWindowsVTInput } from "./utilities.js"; // Re-export event/alert helpers so existing consumers (bg-shell-lifecycle.js) // continue to work without changing their import paths. -export { addEvent, pendingAlerts, pushAlert, setPendingAlerts }; +export { addEvent, MAX_PENDING_ALERTS, pendingAlerts, pushAlert, setPendingAlerts } from "./bg-events.js"; // ── Process Registry ─────────────────────────────────────────────────────── export const processes = new Map(); export function addOutputLine(bg, stream, line) { diff --git a/src/resources/extensions/sf/commands-handlers.js b/src/resources/extensions/sf/commands-handlers.js index 8201f4d85..5110b62da 100644 --- a/src/resources/extensions/sf/commands-handlers.js +++ b/src/resources/extensions/sf/commands-handlers.js @@ -207,7 +207,7 @@ export async function handleDoctor(args, ctx, pi) { requestedScope, } = parseDoctorArgs(args); const scope = await selectDoctorScope(projectRoot(), requestedScope); - const effectiveScope = mode === "audit" ? requestedScope : scope; + const effectiveScope = mode === "audit" && requestedScope ? requestedScope : scope; const report = await runSFDoctor(projectRoot(), { fix: mode === "fix" || mode === "heal" || dryRun || fixFlag, dryRun, diff --git a/src/resources/extensions/sf/uok/unit-runtime.js b/src/resources/extensions/sf/uok/unit-runtime.js index 81491f72c..192094ffa 100644 --- a/src/resources/extensions/sf/uok/unit-runtime.js +++ b/src/resources/extensions/sf/uok/unit-runtime.js @@ -482,11 +482,19 @@ export async function inspectExecuteTaskDurability(basePath, unitId) { const taskChecked = !!planContent && new RegExp(`^- \\[[xX]\\] \\*\\*${escapedTid}:`, "m").test(planContent); - // Use DB task status instead of reading STATE.md — STATE.md is a display - // projection and may lag behind DB writes by a loop iteration. - const taskRow = isDbAvailable() ? getTask(mid, sid, tid) : null; - const taskStatus = taskRow?.status ?? "pending"; - const nextActionAdvanced = taskStatus !== "pending" && taskStatus !== "in_progress"; + // Prefer DB task status (authoritative) over STATE.md (display projection + // that can lag by a loop iteration). Fall back to STATE.md when DB is + // unavailable (e.g. in unit tests that don't initialise the database). + let nextActionAdvanced; + if (isDbAvailable()) { + const taskRow = getTask(mid, sid, tid); + const taskStatus = taskRow?.status ?? "pending"; + nextActionAdvanced = taskStatus !== "pending" && taskStatus !== "in_progress"; + } else { + const stateAbs = join(sfRoot(basePath), "STATE.md"); + const stateContent = existsSync(stateAbs) ? readFileSync(stateAbs, "utf-8") : ""; + nextActionAdvanced = !new RegExp(`Execute ${escapedTid}\\b`).test(stateContent); + } // Must-have coverage: load task plan and count mentions in summary let mustHaveCount = 0; let mustHavesMentionedInSummary = 0; diff --git a/web/lib/browser-slash-command-dispatch.ts b/web/lib/browser-slash-command-dispatch.ts index 955417a04..80eaf5ccf 100644 --- a/web/lib/browser-slash-command-dispatch.ts +++ b/web/lib/browser-slash-command-dispatch.ts @@ -141,7 +141,6 @@ const SF_SURFACE_COMMANDS = new Map([ const SF_PASSTHROUGH_COMMANDS = new Set([ "autonomous", "next", - "stop", "pause", "skip", "discuss",