MCPcopy Create free account
hub / github.com/experdot/pointer / copyMessageMapWithIdMap

Function copyMessageMapWithIdMap

src/renderer/src/stores/helpers/storeHelpers.ts:81–101  ·  view source on GitHub ↗
(
  messageMap: { [messageId: string]: any },
  idMap: Map<string, string>
)

Source from the content-addressed store, hash-verified

79 * 使用ID映射复制消息映射对象
80 */
81export const copyMessageMapWithIdMap = (
82 messageMap: { [messageId: string]: any },
83 idMap: Map<string, string>
84): { [messageId: string]: any } => {
85 const newMessageMap: { [messageId: string]: any } = {}
86
87 Object.entries(messageMap).forEach(([oldId, msg]) => {
88 const newId = idMap.get(oldId)!
89 newMessageMap[newId] = {
90 ...msg,
91 id: newId,
92 parentId: msg.parentId ? idMap.get(msg.parentId) : undefined,
93 replies: msg.replies?.map((replyId: string) => idMap.get(replyId)).filter(Boolean) || [],
94 children: msg.children?.map((childId: string) => idMap.get(childId)).filter(Boolean) || [],
95 branchIndex: msg.branchIndex,
96 isStreaming: false
97 }
98 })
99
100 return newMessageMap
101}
102
103/**
104 * 使用ID映射更新路径数组

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected