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:
@@ -467,7 +467,7 @@ func (q *Queries) ListMessagesByProject(ctx context.Context, arg ListMessagesByP
|
||||
}
|
||||
|
||||
const listNodesByProject = `-- name: ListNodesByProject :many
|
||||
SELECT id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation
|
||||
SELECT id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context
|
||||
FROM canvas_nodes
|
||||
WHERE project_id = $1 AND user_id = $2
|
||||
ORDER BY sort_order ASC, id ASC
|
||||
@@ -520,6 +520,7 @@ func (q *Queries) ListNodesByProject(ctx context.Context, arg ListNodesByProject
|
||||
&i.FlipX,
|
||||
&i.FlipY,
|
||||
&i.Rotation,
|
||||
&i.SemanticContext,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -745,8 +746,8 @@ func (q *Queries) UpsertBrandKit(ctx context.Context, arg UpsertBrandKitParams)
|
||||
}
|
||||
|
||||
const upsertCanvasNode = `-- name: UpsertCanvasNode :exec
|
||||
INSERT INTO canvas_nodes (id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32)
|
||||
INSERT INTO canvas_nodes (id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
project_id = EXCLUDED.project_id,
|
||||
user_id = EXCLUDED.user_id,
|
||||
@@ -778,42 +779,44 @@ ON CONFLICT (id) DO UPDATE SET
|
||||
stroke_style = EXCLUDED.stroke_style,
|
||||
flip_x = EXCLUDED.flip_x,
|
||||
flip_y = EXCLUDED.flip_y,
|
||||
rotation = EXCLUDED.rotation
|
||||
rotation = EXCLUDED.rotation,
|
||||
semantic_context = EXCLUDED.semantic_context
|
||||
`
|
||||
|
||||
type UpsertCanvasNodeParams struct {
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
NodeType string `json:"node_type"`
|
||||
Title string `json:"title"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
Content string `json:"content"`
|
||||
Tone string `json:"tone"`
|
||||
Status string `json:"status"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
ParentID string `json:"parent_id"`
|
||||
LayerRole string `json:"layer_role"`
|
||||
FontSize float64 `json:"font_size"`
|
||||
FontFamily string `json:"font_family"`
|
||||
FontWeight string `json:"font_weight"`
|
||||
Color string `json:"color"`
|
||||
TextAlign string `json:"text_align"`
|
||||
LineHeight float64 `json:"line_height"`
|
||||
LetterSpacing float64 `json:"letter_spacing"`
|
||||
TextDecoration string `json:"text_decoration"`
|
||||
TextTransform string `json:"text_transform"`
|
||||
Opacity float64 `json:"opacity"`
|
||||
FillColor string `json:"fill_color"`
|
||||
StrokeColor string `json:"stroke_color"`
|
||||
StrokeWidth float64 `json:"stroke_width"`
|
||||
StrokeStyle string `json:"stroke_style"`
|
||||
FlipX bool `json:"flip_x"`
|
||||
FlipY bool `json:"flip_y"`
|
||||
Rotation float64 `json:"rotation"`
|
||||
ID string `json:"id"`
|
||||
ProjectID string `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
NodeType string `json:"node_type"`
|
||||
Title string `json:"title"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
Content string `json:"content"`
|
||||
Tone string `json:"tone"`
|
||||
Status string `json:"status"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
ParentID string `json:"parent_id"`
|
||||
LayerRole string `json:"layer_role"`
|
||||
FontSize float64 `json:"font_size"`
|
||||
FontFamily string `json:"font_family"`
|
||||
FontWeight string `json:"font_weight"`
|
||||
Color string `json:"color"`
|
||||
TextAlign string `json:"text_align"`
|
||||
LineHeight float64 `json:"line_height"`
|
||||
LetterSpacing float64 `json:"letter_spacing"`
|
||||
TextDecoration string `json:"text_decoration"`
|
||||
TextTransform string `json:"text_transform"`
|
||||
Opacity float64 `json:"opacity"`
|
||||
FillColor string `json:"fill_color"`
|
||||
StrokeColor string `json:"stroke_color"`
|
||||
StrokeWidth float64 `json:"stroke_width"`
|
||||
StrokeStyle string `json:"stroke_style"`
|
||||
FlipX bool `json:"flip_x"`
|
||||
FlipY bool `json:"flip_y"`
|
||||
Rotation float64 `json:"rotation"`
|
||||
SemanticContext string `json:"semantic_context"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertCanvasNode(ctx context.Context, arg UpsertCanvasNodeParams) error {
|
||||
@@ -850,6 +853,7 @@ func (q *Queries) UpsertCanvasNode(ctx context.Context, arg UpsertCanvasNodePara
|
||||
arg.FlipX,
|
||||
arg.FlipY,
|
||||
arg.Rotation,
|
||||
arg.SemanticContext,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user