feat(server): persist node semantic context and retain CAD agent context

Add a semantic_context column to canvas_nodes (schema, sqlc queries,
generated models, repository upserts) and thread SemanticContext through the
domain node, API type, and mappers so CAD-derived context survives canvas
saves.

Treat agent text parts with textSource "cad-context" like settings: keep
them for planning, memory, and image-generation prompts but exclude them
from the persisted user-visible message copy. Add coverage for the CAD
context visibility and mapper behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 16:40:47 +08:00
parent 57a9aba03e
commit 29b3bd222c
13 changed files with 249 additions and 137 deletions
@@ -0,0 +1,22 @@
package logic
import (
"testing"
"img_infinite_canvas/internal/domain/design"
)
func TestCanvasNodeSemanticContextRoundTrip(t *testing.T) {
nodes := []design.Node{{
ID: "cad-1",
Type: design.NodeTypeImage,
Title: "plan.svg",
LayerRole: "cad-vector",
SemanticContext: "CAD semantic context: layer ROOMS",
}}
roundTrip := toDomainNodes(toAPINodes(nodes))
if len(roundTrip) != 1 || roundTrip[0].SemanticContext != nodes[0].SemanticContext {
t.Fatalf("expected semantic context round trip, got %#v", roundTrip)
}
}
+2
View File
@@ -263,6 +263,7 @@ func toAPINodes(items []design.Node) []types.CanvasNode {
Status: item.Status,
ParentId: item.ParentID,
LayerRole: item.LayerRole,
SemanticContext: item.SemanticContext,
FontSize: item.FontSize,
FontFamily: item.FontFamily,
FontWeight: item.FontWeight,
@@ -305,6 +306,7 @@ func toDomainNodes(items []types.CanvasNode) []design.Node {
Status: item.Status,
ParentID: item.ParentId,
LayerRole: item.LayerRole,
SemanticContext: item.SemanticContext,
FontSize: item.FontSize,
FontFamily: item.FontFamily,
FontWeight: item.FontWeight,