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
@@ -26,6 +26,20 @@ type AgentMessage struct {
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type AuthDeviceSession struct {
ID string `json:"id"`
UserID pgtype.UUID `json:"user_id"`
DeviceType string `json:"device_type"`
System string `json:"system"`
Browser string `json:"browser"`
Client string `json:"client"`
UserAgent string `json:"user_agent"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
LastSeenAt pgtype.Timestamptz `json:"last_seen_at"`
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
RevokedAt pgtype.Timestamptz `json:"revoked_at"`
}
type AuthVerificationCode struct {
ID string `json:"id"`
Region string `json:"region"`
@@ -58,38 +72,39 @@ type CanvasConnection struct {
}
type CanvasNode 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"`
}
type CanvasSnapshot struct {