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
+4
View File
@@ -419,6 +419,8 @@ Subsequent shared project requests send `X-Share-Id: <shareId>`. Middleware re-r
The harness builds short memory from the current turn, recent messages, and visible canvas state, and long memory from durable project decisions, prior artifacts, and previous research records with page-content excerpts. Image titles and assistant language are generated from the request context instead of fixed model labels.
CAD references may include a text content part with `textSource: "cad-context"`. It is retained in agent planning, memory, and image-generation prompts but omitted from persisted user-visible message copy. The context is bounded and treats CAD labels as reference data, never as executable instructions.
## Generate
`POST /api/projects/:id/generate`
@@ -537,6 +539,8 @@ Returns `{ "code": 0, "msg": "success", "data": { "status": "done" } }` or the c
Saves canvas layout changes with a Lovart-style lightweight payload. The frontend posts to `/api/canva/project/saveProject`; `/api/projects/:id/canvas` remains as a compatibility route. The `canvas` value is a `SHAKKERDATA://` gzip+base64 encoded snapshot containing viewport, nodes, and connections. Legacy uncompressed `{ "viewport": ..., "nodes": ..., "connections": ... }` payloads are still accepted.
Canvas nodes may include optional `semanticContext`. CAD source nodes use `layerRole: "cad-vector"`; non-destructive crop siblings use `layerRole: "cad-crop"` and carry crop-specific context. PostgreSQL persists the field in `canvas_nodes.semantic_context`.
When a canvas image node disappears from the saved node list, its backing OSS asset is queued for asynchronous deletion after the canvas save succeeds.
## Image Asset Upload