MCPcopy Index your code
hub / github.com/simstudioai/sim / dedupeById

Function dedupeById

apps/sim/lib/copilot/chat/messages-store.ts:12–21  ·  view source on GitHub ↗

* Keep the first occurrence of each message id. A single `INSERT ... ON * CONFLICT` cannot touch the same conflict target twice, so a repeated id * would otherwise throw.

(messages: PersistedMessage[])

Source from the content-addressed store, hash-verified

10 * would otherwise throw.
11 */
12function dedupeById(messages: PersistedMessage[]): PersistedMessage[] {
13 const seen = new Set<string>()
14 const out: PersistedMessage[] = []
15 for (const m of messages) {
16 if (seen.has(m.id)) continue
17 seen.add(m.id)
18 out.push(m)
19 }
20 return out
21}
22
23function toRow(
24 chatId: string,

Callers 2

Calls 2

addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected