forked from 1b-agent/opencadstudio-upstream
An entity added via a plugin's AddEntity with a common.layer name that no LAYER command ever created kept its layer in-session, but the DWG writer resolves an unknown layer name to a NULL handle, so on reopen the entity collapsed to layer 0. Add a shared Scene::ensure_layer(name) that registers a missing layer with a real handle (allocate_handle, per #67) and call it from add_entity and update_entity. This covers the plugin AddEntity/UpdateEntity IPC and every internal add path without a new IPC request. Existing/empty/"0" layers are no-ops, so normal draw commands are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>