chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -28,18 +28,26 @@ function recordAgentRunSnapshot(entry: AgentRunSnapshot) {
}
function ensureAgentRunListener() {
if (agentRunListenerStarted) return;
if (agentRunListenerStarted) {
return;
}
agentRunListenerStarted = true;
onAgentEvent((evt) => {
if (!evt) return;
if (evt.stream !== "lifecycle") return;
if (!evt) {
return;
}
if (evt.stream !== "lifecycle") {
return;
}
const phase = evt.data?.phase;
if (phase === "start") {
const startedAt = typeof evt.data?.startedAt === "number" ? evt.data.startedAt : undefined;
agentRunStarts.set(evt.runId, startedAt ?? Date.now());
return;
}
if (phase !== "end" && phase !== "error") return;
if (phase !== "end" && phase !== "error") {
return;
}
const startedAt =
typeof evt.data?.startedAt === "number" ? evt.data.startedAt : agentRunStarts.get(evt.runId);
const endedAt = typeof evt.data?.endedAt === "number" ? evt.data.endedAt : undefined;
@@ -68,23 +76,35 @@ export async function waitForAgentJob(params: {
const { runId, timeoutMs } = params;
ensureAgentRunListener();
const cached = getCachedAgentRun(runId);
if (cached) return cached;
if (timeoutMs <= 0) return null;
if (cached) {
return cached;
}
if (timeoutMs <= 0) {
return null;
}
return await new Promise((resolve) => {
let settled = false;
const finish = (entry: AgentRunSnapshot | null) => {
if (settled) return;
if (settled) {
return;
}
settled = true;
clearTimeout(timer);
unsubscribe();
resolve(entry);
};
const unsubscribe = onAgentEvent((evt) => {
if (!evt || evt.stream !== "lifecycle") return;
if (evt.runId !== runId) return;
if (!evt || evt.stream !== "lifecycle") {
return;
}
if (evt.runId !== runId) {
return;
}
const phase = evt.data?.phase;
if (phase !== "end" && phase !== "error") return;
if (phase !== "end" && phase !== "error") {
return;
}
const cached = getCachedAgentRun(runId);
if (cached) {
finish(cached);