mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Fix plugin logos and recent rows for saved OpenClaw/Hermes memories (#1054)
This commit is contained in:
parent
6c6b5297b6
commit
1b1bd4d221
2 changed files with 72 additions and 0 deletions
|
|
@ -40,6 +40,7 @@ import {
|
|||
type Profession,
|
||||
} from "@/hooks/use-personalization"
|
||||
import { normalizePluginClientId } from "@/lib/plugin-catalog"
|
||||
import { detectPluginSpace } from "@/lib/plugin-space"
|
||||
|
||||
type DocumentsResponse = z.infer<typeof DocumentsWithMemoriesResponseSchema>
|
||||
type DocumentWithMemories = DocumentsResponse["documents"][0]
|
||||
|
|
@ -443,6 +444,23 @@ function hasClaudeCodeContainer(document: DocumentWithMemories): boolean {
|
|||
)
|
||||
}
|
||||
|
||||
function getPluginClientFromSpace(
|
||||
document: DocumentWithMemories,
|
||||
): string | null {
|
||||
const containerTags =
|
||||
(document as { containerTags?: string[] }).containerTags ?? []
|
||||
const memorySpaceTags = (document.memoryEntries ?? [])
|
||||
.map((entry) => entry.spaceContainerTag)
|
||||
.filter((tag): tag is string => !!tag)
|
||||
|
||||
for (const tag of [...containerTags, ...memorySpaceTags]) {
|
||||
const plugin = detectPluginSpace(tag)
|
||||
if (plugin) return normalizePluginClientId(plugin.pluginId)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function getPluginClientFromDocument(
|
||||
document: DocumentWithMemories,
|
||||
): string | null {
|
||||
|
|
@ -462,6 +480,9 @@ function getPluginClientFromDocument(
|
|||
|
||||
if (hasClaudeCodeContainer(document)) return "claude_code"
|
||||
|
||||
const pluginClientFromSpace = getPluginClientFromSpace(document)
|
||||
if (pluginClientFromSpace) return pluginClientFromSpace
|
||||
|
||||
const content = getDocumentText(document)
|
||||
const title = document.title ?? ""
|
||||
if (
|
||||
|
|
@ -689,6 +710,26 @@ function parseToolUsage(
|
|||
}
|
||||
|
||||
// Attach latest document info to plugin items where available from MCP documents
|
||||
for (const [pluginId, docInfo] of latestDocPerPlugin) {
|
||||
const itemKey = `plugin_${pluginId}`
|
||||
if (toolMap.has(itemKey)) continue
|
||||
|
||||
const catalog = PLUGIN_DISPLAY_CATALOG[pluginId]
|
||||
toolMap.set(itemKey, {
|
||||
id: itemKey,
|
||||
name: catalog?.name ?? docInfo.title,
|
||||
type: "Plugin",
|
||||
icon: catalog?.icon ?? null,
|
||||
lastUsedAt: docInfo.at,
|
||||
hasBeenUsed: true,
|
||||
connectedAt: null,
|
||||
lastDocumentTitle: null,
|
||||
lastDocumentId: null,
|
||||
lastDocumentPreview: null,
|
||||
lastDocument: null,
|
||||
})
|
||||
}
|
||||
|
||||
for (const [, item] of toolMap) {
|
||||
if (item.type === "Plugin" && !item.lastDocumentTitle) {
|
||||
const pluginId = item.id.replace(/^plugin_/, "")
|
||||
|
|
|
|||
|
|
@ -456,6 +456,34 @@ function parseRoleBlockTranscript(
|
|||
}
|
||||
}
|
||||
|
||||
function parsePluginSpaceNote(
|
||||
document: DocumentWithMemories,
|
||||
content: string,
|
||||
plugin: PluginIdentity | null,
|
||||
): ParsedPluginDocument | null {
|
||||
if (!plugin) return null
|
||||
|
||||
const summary = typeof document.summary === "string" ? document.summary : ""
|
||||
const memoryText = firstMemoryEntryText(document)
|
||||
const preview = takePreview(memoryText || summary || content, 220)
|
||||
|
||||
return {
|
||||
kind: plugin.pluginId === "codex" ? "codex-save" : "plugin-save",
|
||||
pluginLabel: plugin.label,
|
||||
pluginIconSrc: plugin.iconSrc ?? undefined,
|
||||
formatLabel: "Note",
|
||||
title:
|
||||
(typeof document.title === "string" && document.title.trim()) ||
|
||||
`${plugin.label} memory`,
|
||||
preview,
|
||||
summary: takePreview(summary || memoryText || content, 220),
|
||||
artifacts: [],
|
||||
messages: [],
|
||||
sections: [],
|
||||
rawContent: content,
|
||||
}
|
||||
}
|
||||
|
||||
function withIcon(
|
||||
parsed: ParsedPluginDocument | null,
|
||||
): ParsedPluginDocument | null {
|
||||
|
|
@ -694,5 +722,8 @@ export function parsePluginDocument(
|
|||
if (roleBlockSession) return withIcon(roleBlockSession)
|
||||
}
|
||||
|
||||
const pluginSpaceNote = parsePluginSpaceNote(document, content, plugin)
|
||||
if (pluginSpaceNote) return withIcon(pluginSpaceNote)
|
||||
|
||||
return withIcon(parseClaudeCodeByMetadata(document, metadata))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue