chore: Dedupe sent-message cache storage (#22127)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 8401257b271b85cb5ec03574ef861703ba71ea08
Co-authored-by: TaKO8Ki <41065217+TaKO8Ki@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
Takayuki Maeda
2026-02-21 16:04:59 +09:00
committed by GitHub
parent 35fd322114
commit 40f1a6c0d2
2 changed files with 4 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ Docs: https://docs.openclaw.ai
- Dev tooling: add dead-code scans to CI via Knip/ts-prune/ts-unused-exports and report unused dependencies/exports in non-blocking checks. (#22468) Thanks @vincentkoc.
- Dev tooling: move `@larksuiteoapi/node-sdk` out of root `package.json` and keep it scoped to `extensions/feishu` where it is used. (#22471) Thanks @vincentkoc.
- Dev tooling: remove unused root dependency `signal-utils` from core manifest after confirming it was only used by extension-only paths. (#22471) Thanks @vincentkoc.
- Telegram: dedupe sent-message cache storage by removing redundant per-chat Set tracking and using the timestamp map as the single source of truth. (#22127) thanks @TaKO8Ki.
- Agents/Subagents: default subagent spawn depth now uses shared `maxSpawnDepth=2`, enabling depth-1 orchestrator spawning by default while keeping depth policy checks consistent across spawn and prompt paths. (#22223) Thanks @tyler6204.
- Channels/CLI: add per-account/channel `defaultTo` outbound routing fallback so `openclaw agent --deliver` can send without explicit `--reply-to` when a default target is configured. (#16985) Thanks @KirillShchetinin.
- iOS/Chat: clean chat UI noise by stripping inbound untrusted metadata/timestamp prefixes, formatting tool outputs into concise summaries/errors, compacting the composer while typing, and supporting tap-to-dismiss keyboard in chat view. (#22122) thanks @mbelinky.

View File

@@ -6,7 +6,6 @@
const TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
type CacheEntry = {
messageIds: Set<number>;
timestamps: Map<number, number>;
};
@@ -20,7 +19,6 @@ function cleanupExpired(entry: CacheEntry): void {
const now = Date.now();
for (const [msgId, timestamp] of entry.timestamps) {
if (now - timestamp > TTL_MS) {
entry.messageIds.delete(msgId);
entry.timestamps.delete(msgId);
}
}
@@ -33,13 +31,12 @@ export function recordSentMessage(chatId: number | string, messageId: number): v
const key = getChatKey(chatId);
let entry = sentMessages.get(key);
if (!entry) {
entry = { messageIds: new Set(), timestamps: new Map() };
entry = { timestamps: new Map() };
sentMessages.set(key, entry);
}
entry.messageIds.add(messageId);
entry.timestamps.set(messageId, Date.now());
// Periodic cleanup
if (entry.messageIds.size > 100) {
if (entry.timestamps.size > 100) {
cleanupExpired(entry);
}
}
@@ -55,7 +52,7 @@ export function wasSentByBot(chatId: number | string, messageId: number): boolea
}
// Clean up expired entries on read
cleanupExpired(entry);
return entry.messageIds.has(messageId);
return entry.timestamps.has(messageId);
}
/**