mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:14:34 +00:00
chore: Dedupe sent-message cache storage (#22127)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 8401257b27
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:
@@ -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: 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: 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.
|
- 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.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
const TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
const TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
||||||
|
|
||||||
type CacheEntry = {
|
type CacheEntry = {
|
||||||
messageIds: Set<number>;
|
|
||||||
timestamps: Map<number, number>;
|
timestamps: Map<number, number>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,7 +19,6 @@ function cleanupExpired(entry: CacheEntry): void {
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const [msgId, timestamp] of entry.timestamps) {
|
for (const [msgId, timestamp] of entry.timestamps) {
|
||||||
if (now - timestamp > TTL_MS) {
|
if (now - timestamp > TTL_MS) {
|
||||||
entry.messageIds.delete(msgId);
|
|
||||||
entry.timestamps.delete(msgId);
|
entry.timestamps.delete(msgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,13 +31,12 @@ export function recordSentMessage(chatId: number | string, messageId: number): v
|
|||||||
const key = getChatKey(chatId);
|
const key = getChatKey(chatId);
|
||||||
let entry = sentMessages.get(key);
|
let entry = sentMessages.get(key);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
entry = { messageIds: new Set(), timestamps: new Map() };
|
entry = { timestamps: new Map() };
|
||||||
sentMessages.set(key, entry);
|
sentMessages.set(key, entry);
|
||||||
}
|
}
|
||||||
entry.messageIds.add(messageId);
|
|
||||||
entry.timestamps.set(messageId, Date.now());
|
entry.timestamps.set(messageId, Date.now());
|
||||||
// Periodic cleanup
|
// Periodic cleanup
|
||||||
if (entry.messageIds.size > 100) {
|
if (entry.timestamps.size > 100) {
|
||||||
cleanupExpired(entry);
|
cleanupExpired(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +52,7 @@ export function wasSentByBot(chatId: number | string, messageId: number): boolea
|
|||||||
}
|
}
|
||||||
// Clean up expired entries on read
|
// Clean up expired entries on read
|
||||||
cleanupExpired(entry);
|
cleanupExpired(entry);
|
||||||
return entry.messageIds.has(messageId);
|
return entry.timestamps.has(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user