mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:14:58 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -24,7 +24,9 @@ const ABORT_TRIGGERS = new Set(["stop", "esc", "abort", "wait", "exit", "interru
|
||||
const ABORT_MEMORY = new Map<string, boolean>();
|
||||
|
||||
export function isAbortTrigger(text?: string): boolean {
|
||||
if (!text) return false;
|
||||
if (!text) {
|
||||
return false;
|
||||
}
|
||||
const normalized = text.trim().toLowerCase();
|
||||
return ABORT_TRIGGERS.has(normalized);
|
||||
}
|
||||
@@ -49,15 +51,21 @@ function resolveSessionEntryForKey(
|
||||
store: Record<string, SessionEntry> | undefined,
|
||||
sessionKey: string | undefined,
|
||||
) {
|
||||
if (!store || !sessionKey) return {};
|
||||
if (!store || !sessionKey) {
|
||||
return {};
|
||||
}
|
||||
const direct = store[sessionKey];
|
||||
if (direct) return { entry: direct, key: sessionKey };
|
||||
if (direct) {
|
||||
return { entry: direct, key: sessionKey };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
function resolveAbortTargetKey(ctx: MsgContext): string | undefined {
|
||||
const target = ctx.CommandTargetSessionKey?.trim();
|
||||
if (target) return target;
|
||||
if (target) {
|
||||
return target;
|
||||
}
|
||||
const sessionKey = ctx.SessionKey?.trim();
|
||||
return sessionKey || undefined;
|
||||
}
|
||||
@@ -67,7 +75,9 @@ function normalizeRequesterSessionKey(
|
||||
key: string | undefined,
|
||||
): string | undefined {
|
||||
const cleaned = key?.trim();
|
||||
if (!cleaned) return undefined;
|
||||
if (!cleaned) {
|
||||
return undefined;
|
||||
}
|
||||
const { mainKey, alias } = resolveMainSessionAlias(cfg);
|
||||
return resolveInternalSessionKey({ key: cleaned, alias, mainKey });
|
||||
}
|
||||
@@ -77,18 +87,26 @@ export function stopSubagentsForRequester(params: {
|
||||
requesterSessionKey?: string;
|
||||
}): { stopped: number } {
|
||||
const requesterKey = normalizeRequesterSessionKey(params.cfg, params.requesterSessionKey);
|
||||
if (!requesterKey) return { stopped: 0 };
|
||||
if (!requesterKey) {
|
||||
return { stopped: 0 };
|
||||
}
|
||||
const runs = listSubagentRunsForRequester(requesterKey);
|
||||
if (runs.length === 0) return { stopped: 0 };
|
||||
if (runs.length === 0) {
|
||||
return { stopped: 0 };
|
||||
}
|
||||
|
||||
const storeCache = new Map<string, Record<string, SessionEntry>>();
|
||||
const seenChildKeys = new Set<string>();
|
||||
let stopped = 0;
|
||||
|
||||
for (const run of runs) {
|
||||
if (run.endedAt) continue;
|
||||
if (run.endedAt) {
|
||||
continue;
|
||||
}
|
||||
const childKey = run.childSessionKey?.trim();
|
||||
if (!childKey || seenChildKeys.has(childKey)) continue;
|
||||
if (!childKey || seenChildKeys.has(childKey)) {
|
||||
continue;
|
||||
}
|
||||
seenChildKeys.add(childKey);
|
||||
|
||||
const cleared = clearSessionQueues([childKey]);
|
||||
@@ -130,7 +148,9 @@ export async function tryFastAbortFromMessage(params: {
|
||||
const stripped = isGroup ? stripMentions(raw, ctx, cfg, agentId) : raw;
|
||||
const normalized = normalizeCommandBody(stripped);
|
||||
const abortRequested = normalized === "/stop" || isAbortTrigger(stripped);
|
||||
if (!abortRequested) return { handled: false, aborted: false };
|
||||
if (!abortRequested) {
|
||||
return { handled: false, aborted: false };
|
||||
}
|
||||
|
||||
const commandAuthorized = ctx.CommandAuthorized;
|
||||
const auth = resolveCommandAuthorization({
|
||||
@@ -138,7 +158,9 @@ export async function tryFastAbortFromMessage(params: {
|
||||
cfg,
|
||||
commandAuthorized,
|
||||
});
|
||||
if (!auth.isAuthorizedSender) return { handled: false, aborted: false };
|
||||
if (!auth.isAuthorizedSender) {
|
||||
return { handled: false, aborted: false };
|
||||
}
|
||||
|
||||
const abortKey = targetKey ?? auth.from ?? auth.to;
|
||||
const requesterSessionKey = targetKey ?? ctx.SessionKey ?? abortKey;
|
||||
@@ -161,7 +183,9 @@ export async function tryFastAbortFromMessage(params: {
|
||||
store[key] = entry;
|
||||
await updateSessionStore(storePath, (nextStore) => {
|
||||
const nextEntry = nextStore[key] ?? entry;
|
||||
if (!nextEntry) return;
|
||||
if (!nextEntry) {
|
||||
return;
|
||||
}
|
||||
nextEntry.abortedLastRun = true;
|
||||
nextEntry.updatedAt = Date.now();
|
||||
nextStore[key] = nextEntry;
|
||||
|
||||
Reference in New Issue
Block a user