Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Name the open_loops 500-row cap once and pin the Request Log page's retention fields

garrytan373f4537ff05
diff --git a/src/core/ops/loops.ts b/src/core/ops/loops.ts
index e773ef3716..bb7a865193 100644
--- a/src/core/ops/loops.ts
+++ b/src/core/ops/loops.ts
@@ -390,6 +390,8 @@ function renderText(groups: CounterpartyGroup[], none: NoCounterpartyLoops | nul
return lines.join('\n');
}
+const OPEN_LOOPS_ROW_CAP = 500;
+
const open_loops: Operation = {
name: 'open_loops',
mutating: false,
@@ -481,10 +483,10 @@ const open_loops: Operation = {
...(p.loop_type ? { loopType: p.loop_type as LoopType } : {}),
...(p.counterparty ? { counterparty: p.counterparty as string } : {}),
...(loopId === undefined ? {} : { loopId }),
- limit: 501,
+ limit: OPEN_LOOPS_ROW_CAP + 1,
});
- const capped = loops.length > 500;
- if (capped) loops.length = 500;
+ const capped = loops.length > OPEN_LOOPS_ROW_CAP;
+ if (capped) loops.length = OPEN_LOOPS_ROW_CAP;
const freshness = await googleSourceFreshness(ctx, scope);
const noGoogleSources = freshness.sources.length === 0;
if (!trusted && noGoogleSources && !freshness.failed && loops.length === 0) ctx.emitNotice?.(noGoogleInScopeNotice(scope.sourceIds ?? (scope.sourceId ? [scope.sourceId] : [])));
diff --git a/test/serve-http-admin-request-log-retention.test.ts b/test/serve-http-admin-request-log-retention.test.ts
index 3a5c87edfc..f4e27c6a03 100644
--- a/test/serve-http-admin-request-log-retention.test.ts
+++ b/test/serve-http-admin-request-log-retention.test.ts
@@ -19,6 +19,7 @@ import { mountAdminApi } from '../src/commands/serve-http-admin-api.ts';
import type { ServeHttpContext } from '../src/commands/serve-http.ts';
import { sqlQueryForEngine } from '../src/core/sql-query.ts';
import { MCP_LOG_RETENTION_KEY, runMcpLogRetention } from '../src/core/mcp-request-log-retention.ts';
+import { readFileSync } from 'node:fs';
let engine: PGLiteEngine;
let server: Server;
@@ -87,3 +88,11 @@ describe('admin dashboard across a request-log prune', () => {
expect(Date.parse(log.pruned_before)).toBeLessThan(Date.now() - 30 * 86_400_000);
}, 60_000);
});
+
+describe('admin Request Log page', () => {
+ test('shows the retention window and prune date the endpoint returns', () => {
+ const page = readFileSync('admin/src/pages/RequestLog.tsx', 'utf8');
+ expect(page).toContain('data.retention_days');
+ expect(page).toContain('data.pruned_before');
+ });
+});