fix(design): preserve existing canvas nodes when compressed snapshot omits them
SaveCanvas treated a nil Nodes/Connections slice from a compressed snapshot as an empty canvas, wiping existing content. Distinguish nil (field omitted, keep the project's current nodes/connections) from an explicit empty slice. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1082,10 +1082,18 @@ func (s *DesignService) SaveCanvas(ctx context.Context, projectID string, viewpo
|
||||
return design.Project{}, fmt.Errorf("%w: invalid canvas snapshot", design.ErrInvalidInput)
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
nodes = snapshot.Nodes
|
||||
if snapshot.Nodes != nil {
|
||||
nodes = snapshot.Nodes
|
||||
} else {
|
||||
nodes = append([]design.Node(nil), project.Nodes...)
|
||||
}
|
||||
}
|
||||
if len(connections) == 0 {
|
||||
connections = snapshot.Connections
|
||||
if snapshot.Connections != nil {
|
||||
connections = snapshot.Connections
|
||||
} else {
|
||||
connections = append([]design.Connection(nil), project.Connections...)
|
||||
}
|
||||
}
|
||||
if viewport.K == 0 {
|
||||
viewport = snapshot.Viewport
|
||||
|
||||
Reference in New Issue
Block a user