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:
@@ -189,38 +189,39 @@ func (r *ProjectRepository) Save(ctx context.Context, project design.Project) er
|
||||
|
||||
for index, node := range project.Nodes {
|
||||
if err := q.UpsertCanvasNode(ctx, sqlcdb.UpsertCanvasNodeParams{
|
||||
ID: node.ID,
|
||||
ProjectID: project.ID,
|
||||
UserID: toPGUUID(project.UserID),
|
||||
NodeType: string(node.Type),
|
||||
Title: node.Title,
|
||||
X: node.X,
|
||||
Y: node.Y,
|
||||
Width: node.Width,
|
||||
Height: node.Height,
|
||||
Content: node.Content,
|
||||
Tone: node.Tone,
|
||||
Status: node.Status,
|
||||
SortOrder: int32(index),
|
||||
ParentID: node.ParentID,
|
||||
LayerRole: node.LayerRole,
|
||||
FontSize: node.FontSize,
|
||||
FontFamily: node.FontFamily,
|
||||
FontWeight: node.FontWeight,
|
||||
Color: node.Color,
|
||||
TextAlign: node.TextAlign,
|
||||
LineHeight: node.LineHeight,
|
||||
LetterSpacing: node.LetterSpacing,
|
||||
TextDecoration: node.TextDecoration,
|
||||
TextTransform: node.TextTransform,
|
||||
Opacity: node.Opacity,
|
||||
FillColor: node.FillColor,
|
||||
StrokeColor: node.StrokeColor,
|
||||
StrokeWidth: node.StrokeWidth,
|
||||
StrokeStyle: node.StrokeStyle,
|
||||
FlipX: node.FlipX,
|
||||
FlipY: node.FlipY,
|
||||
Rotation: node.Rotation,
|
||||
ID: node.ID,
|
||||
ProjectID: project.ID,
|
||||
UserID: toPGUUID(project.UserID),
|
||||
NodeType: string(node.Type),
|
||||
Title: node.Title,
|
||||
X: node.X,
|
||||
Y: node.Y,
|
||||
Width: node.Width,
|
||||
Height: node.Height,
|
||||
Content: node.Content,
|
||||
Tone: node.Tone,
|
||||
Status: node.Status,
|
||||
SortOrder: int32(index),
|
||||
ParentID: node.ParentID,
|
||||
LayerRole: node.LayerRole,
|
||||
SemanticContext: node.SemanticContext,
|
||||
FontSize: node.FontSize,
|
||||
FontFamily: node.FontFamily,
|
||||
FontWeight: node.FontWeight,
|
||||
Color: node.Color,
|
||||
TextAlign: node.TextAlign,
|
||||
LineHeight: node.LineHeight,
|
||||
LetterSpacing: node.LetterSpacing,
|
||||
TextDecoration: node.TextDecoration,
|
||||
TextTransform: node.TextTransform,
|
||||
Opacity: node.Opacity,
|
||||
FillColor: node.FillColor,
|
||||
StrokeColor: node.StrokeColor,
|
||||
StrokeWidth: node.StrokeWidth,
|
||||
StrokeStyle: node.StrokeStyle,
|
||||
FlipX: node.FlipX,
|
||||
FlipY: node.FlipY,
|
||||
Rotation: node.Rotation,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -509,35 +510,36 @@ func mapNodes(rows []sqlcdb.CanvasNode) []design.Node {
|
||||
nodes := make([]design.Node, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
nodes = append(nodes, design.Node{
|
||||
ID: row.ID,
|
||||
Type: design.NodeType(row.NodeType),
|
||||
Title: row.Title,
|
||||
X: row.X,
|
||||
Y: row.Y,
|
||||
Width: row.Width,
|
||||
Height: row.Height,
|
||||
Content: row.Content,
|
||||
Tone: row.Tone,
|
||||
Status: row.Status,
|
||||
ParentID: row.ParentID,
|
||||
LayerRole: row.LayerRole,
|
||||
FontSize: row.FontSize,
|
||||
FontFamily: row.FontFamily,
|
||||
FontWeight: row.FontWeight,
|
||||
Color: row.Color,
|
||||
TextAlign: row.TextAlign,
|
||||
LineHeight: row.LineHeight,
|
||||
LetterSpacing: row.LetterSpacing,
|
||||
TextDecoration: row.TextDecoration,
|
||||
TextTransform: row.TextTransform,
|
||||
Opacity: row.Opacity,
|
||||
FillColor: row.FillColor,
|
||||
StrokeColor: row.StrokeColor,
|
||||
StrokeWidth: row.StrokeWidth,
|
||||
StrokeStyle: row.StrokeStyle,
|
||||
FlipX: row.FlipX,
|
||||
FlipY: row.FlipY,
|
||||
Rotation: row.Rotation,
|
||||
ID: row.ID,
|
||||
Type: design.NodeType(row.NodeType),
|
||||
Title: row.Title,
|
||||
X: row.X,
|
||||
Y: row.Y,
|
||||
Width: row.Width,
|
||||
Height: row.Height,
|
||||
Content: row.Content,
|
||||
Tone: row.Tone,
|
||||
Status: row.Status,
|
||||
ParentID: row.ParentID,
|
||||
LayerRole: row.LayerRole,
|
||||
SemanticContext: row.SemanticContext,
|
||||
FontSize: row.FontSize,
|
||||
FontFamily: row.FontFamily,
|
||||
FontWeight: row.FontWeight,
|
||||
Color: row.Color,
|
||||
TextAlign: row.TextAlign,
|
||||
LineHeight: row.LineHeight,
|
||||
LetterSpacing: row.LetterSpacing,
|
||||
TextDecoration: row.TextDecoration,
|
||||
TextTransform: row.TextTransform,
|
||||
Opacity: row.Opacity,
|
||||
FillColor: row.FillColor,
|
||||
StrokeColor: row.StrokeColor,
|
||||
StrokeWidth: row.StrokeWidth,
|
||||
StrokeStyle: row.StrokeStyle,
|
||||
FlipX: row.FlipX,
|
||||
FlipY: row.FlipY,
|
||||
Rotation: row.Rotation,
|
||||
})
|
||||
}
|
||||
return nodes
|
||||
|
||||
Reference in New Issue
Block a user