feat(server): persist renderContent texture and cover it in asset lifecycle

Add an optional renderContent field to canvas nodes across the go-zero API
type, domain node, SQLC models/queries, PostgreSQL schema, and mappers so a
lightweight transparent-WebP display texture persists alongside the original
content. Prefer renderContent for project thumbnails and main-canvas
previews, and treat both content and renderContent as protected/deletable
asset URLs during canvas asset cleanup. Extend round-trip coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 20:45:56 +08:00
parent e7a0cc0b86
commit ee2c52bbc6
17 changed files with 75 additions and 46 deletions
+24 -22
View File
@@ -189,18 +189,16 @@ func deletedCanvasAssetURLs(previous []design.Node, next []design.Node, messages
seen := make(map[string]struct{})
var deleted []string
for _, node := range previous {
url := nodeAssetURL(node)
if url == "" {
continue
for _, url := range nodeAssetURLs(node) {
if assetURLSetContains(protectedURLs, url) {
continue
}
if _, ok := seen[url]; ok {
continue
}
seen[url] = struct{}{}
deleted = append(deleted, url)
}
if assetURLSetContains(protectedURLs, url) {
continue
}
if _, ok := seen[url]; ok {
continue
}
seen[url] = struct{}{}
deleted = append(deleted, url)
}
return deleted
}
@@ -220,7 +218,9 @@ func projectAssetURLs(project design.Project) []string {
urls = append(urls, url)
}
for _, node := range project.Nodes {
add(nodeAssetURL(node))
for _, url := range nodeAssetURLs(node) {
add(url)
}
}
for _, url := range canvasSnapshotAssetURLs(project.Canvas) {
add(url)
@@ -267,9 +267,7 @@ func canvasSnapshotAssetURLs(canvas string) []string {
}
urls := make([]string, 0, len(snapshot.Nodes))
for _, node := range snapshot.Nodes {
if url := nodeAssetURL(node); url != "" {
urls = append(urls, url)
}
urls = append(urls, nodeAssetURLs(node)...)
}
return urls
}
@@ -277,22 +275,26 @@ func canvasSnapshotAssetURLs(canvas string) []string {
func canvasAssetURLSet(nodes []design.Node) map[string]struct{} {
items := make(map[string]struct{})
for _, node := range nodes {
if url := nodeAssetURL(node); url != "" {
for _, url := range nodeAssetURLs(node) {
addAssetURLKeys(items, url)
}
}
return items
}
func nodeAssetURL(node design.Node) string {
func nodeAssetURLs(node design.Node) []string {
if node.Type != design.NodeTypeImage && node.Type != design.NodeTypeFrame {
return ""
return nil
}
content := strings.TrimSpace(node.Content)
if content == "" || strings.HasPrefix(content, "data:image/") || !isGeneratedImageContent(content) {
return ""
urls := make([]string, 0, 2)
for _, content := range []string{node.Content, node.RenderContent} {
content = strings.TrimSpace(content)
if content == "" || strings.HasPrefix(content, "data:image/") || !isGeneratedImageContent(content) {
continue
}
urls = append(urls, content)
}
return content
return normalizeAssetURLs(urls)
}
func promptMessageAssetURLs(content string) []string {