fix: restore autoStartTime on resume + replace empty catch blocks (#3585)

- auto.ts: restore s.autoStartTime from meta.autoStartTime in both
  custom workflow and milestone resume paths, with Date.now() fallback
  and zero-guard
- auto.ts: replace 3 empty catch blocks with logWarning calls
- guided-flow.ts: replace empty catch with logWarning call
- interrupted-session.ts: add autoStartTime to PausedSessionMetadata
This commit is contained in:
Derek Pearson 2026-04-09 15:31:11 -04:00
parent de6f3ecb2d
commit 228dccf3f4
3 changed files with 10 additions and 5 deletions

View file

@ -1164,8 +1164,9 @@ export async function startAuto(
s.activeRunDir = meta.activeRunDir ?? null;
s.originalBasePath = meta.originalBasePath || base;
s.stepMode = meta.stepMode ?? requestedStepMode;
s.autoStartTime = meta.autoStartTime || Date.now();
s.paused = true;
try { unlinkSync(pausedPath); } catch { /* non-fatal */ }
try { unlinkSync(pausedPath); } catch (e) { logWarning("session", `pause file cleanup failed: ${e instanceof Error ? e.message : String(e)}`, { file: "auto.ts" }); }
ctx.ui.notify(
`Resuming paused custom workflow${meta.activeRunDir ? ` (${meta.activeRunDir})` : ""}.`,
"info",
@ -1197,21 +1198,24 @@ export async function startAuto(
s.pausedSessionFile = meta.sessionFile ?? null;
s.pausedUnitType = meta.unitType ?? null;
s.pausedUnitId = meta.unitId ?? null;
s.autoStartTime = meta.autoStartTime || Date.now();
s.paused = true;
try { unlinkSync(pausedPath); } catch { /* non-fatal */ }
try { unlinkSync(pausedPath); } catch (e) { logWarning("session", `pause file cleanup failed: ${e instanceof Error ? e.message : String(e)}`, { file: "auto.ts" }); }
ctx.ui.notify(
`Resuming paused session for ${meta.milestoneId}${meta.worktreePath && existsSync(meta.worktreePath) ? ` (worktree)` : ""}.`,
"info",
);
}
} else if (existsSync(pausedPath)) {
try { unlinkSync(pausedPath); } catch { /* non-fatal */ }
try { unlinkSync(pausedPath); } catch (e) { logWarning("session", `stale pause file cleanup failed: ${e instanceof Error ? e.message : String(e)}`, { file: "auto.ts" }); }
}
}
} catch (err) {
// Malformed or missing — proceed with fresh bootstrap
logWarning("session", `paused-session restore failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts" });
}
// Guard against zero/missing autoStartTime after resume (#3585)
if (!s.autoStartTime || s.autoStartTime <= 0) s.autoStartTime = Date.now();
}
if (!s.paused) {

View file

@ -1314,8 +1314,8 @@ export async function showSmartEntry(
if (interrupted.pausedSession) {
try {
unlinkSync(join(gsdRoot(basePath), "runtime", "paused-session.json"));
} catch {
// Non-fatal stale metadata cleanup.
} catch (e) {
logWarning("guided", `stale pause file cleanup failed: ${(e as Error).message}`, { file: "guided-flow.ts" });
}
}
} else if (interrupted.classification === "recoverable") {

View file

@ -33,6 +33,7 @@ export interface PausedSessionMetadata {
unitId?: string;
activeEngineId?: string;
activeRunDir?: string | null;
autoStartTime?: number;
}
export interface InterruptedSessionAssessment {