mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:11:23 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -11,7 +11,9 @@ import { formatForLog } from "./ws-log.js";
|
||||
*/
|
||||
function shouldSuppressHeartbeatBroadcast(runId: string): boolean {
|
||||
const runContext = getAgentRunContext(runId);
|
||||
if (!runContext?.isHeartbeat) return false;
|
||||
if (!runContext?.isHeartbeat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const cfg = loadConfig();
|
||||
@@ -52,22 +54,32 @@ export function createChatRunRegistry(): ChatRunRegistry {
|
||||
|
||||
const shift = (sessionId: string) => {
|
||||
const queue = chatRunSessions.get(sessionId);
|
||||
if (!queue || queue.length === 0) return undefined;
|
||||
if (!queue || queue.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const entry = queue.shift();
|
||||
if (!queue.length) chatRunSessions.delete(sessionId);
|
||||
if (!queue.length) {
|
||||
chatRunSessions.delete(sessionId);
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
|
||||
const remove = (sessionId: string, clientRunId: string, sessionKey?: string) => {
|
||||
const queue = chatRunSessions.get(sessionId);
|
||||
if (!queue || queue.length === 0) return undefined;
|
||||
if (!queue || queue.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const idx = queue.findIndex(
|
||||
(entry) =>
|
||||
entry.clientRunId === clientRunId && (sessionKey ? entry.sessionKey === sessionKey : true),
|
||||
);
|
||||
if (idx < 0) return undefined;
|
||||
if (idx < 0) {
|
||||
return undefined;
|
||||
}
|
||||
const [entry] = queue.splice(idx, 1);
|
||||
if (!queue.length) chatRunSessions.delete(sessionId);
|
||||
if (!queue.length) {
|
||||
chatRunSessions.delete(sessionId);
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
|
||||
@@ -137,7 +149,9 @@ export function createAgentEventHandler({
|
||||
chatRunState.buffers.set(clientRunId, text);
|
||||
const now = Date.now();
|
||||
const last = chatRunState.deltaSentAt.get(clientRunId) ?? 0;
|
||||
if (now - last < 150) return;
|
||||
if (now - last < 150) {
|
||||
return;
|
||||
}
|
||||
chatRunState.deltaSentAt.set(clientRunId, now);
|
||||
const payload = {
|
||||
runId: clientRunId,
|
||||
@@ -202,12 +216,18 @@ export function createAgentEventHandler({
|
||||
const shouldEmitToolEvents = (runId: string, sessionKey?: string) => {
|
||||
const runContext = getAgentRunContext(runId);
|
||||
const runVerbose = normalizeVerboseLevel(runContext?.verboseLevel);
|
||||
if (runVerbose) return runVerbose === "on";
|
||||
if (!sessionKey) return false;
|
||||
if (runVerbose) {
|
||||
return runVerbose === "on";
|
||||
}
|
||||
if (!sessionKey) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const { cfg, entry } = loadSessionEntry(sessionKey);
|
||||
const sessionVerbose = normalizeVerboseLevel(entry?.verboseLevel);
|
||||
if (sessionVerbose) return sessionVerbose === "on";
|
||||
if (sessionVerbose) {
|
||||
return sessionVerbose === "on";
|
||||
}
|
||||
const defaultVerbose = normalizeVerboseLevel(cfg.agents?.defaults?.verboseDefault);
|
||||
return defaultVerbose === "on";
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user