MCPcopy
hub / github.com/xcanwin/KeepChatGPT / findConversationMessageForPreview

Function findConversationMessageForPreview

KeepChatGPT.user.js:2028–2043  ·  view source on GitHub ↗
(payload)

Source from the content-addressed store, hash-verified

2026 };
2027
2028 const findConversationMessageForPreview = function (payload) {
2029 const currentNodeMessage =
2030 payload?.mapping?.[payload?.current_node]?.message;
2031 if (currentNodeMessage) {
2032 return currentNodeMessage;
2033 }
2034 const mappedMessages = Object.values(payload?.mapping || {})
2035 .map((node) => node?.message)
2036 .filter(Boolean)
2037 .sort((a, b) => {
2038 const aTime = Number(a?.create_time || 0);
2039 const bTime = Number(b?.create_time || 0);
2040 return bTime - aTime;
2041 });
2042 return mappedMessages[0] || null;
2043 };
2044
2045 const buildConversationRecordFromPayload = function (
2046 payload,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected