Keep the context id in Core's entity records instead of on picked objects

registerEntityContext stamped __gevContextId on the entities, primitives and
carriers it registered, and selection and pick resolution read it back. It
is now the contextId field of the entity's Core record.
This commit is contained in:
Sameh Khamis committed 2026-11-03 09:40:15 -08:00
1 parent 07c8d7a17c
commit 42b17ffab6
5 files changed
+18 -16

No files matched your search

+5 -3
View File
@@ -1,3 +1,5 @@
import { entityRecord, readEntityRecord } from './entityRecords.js';
const STORE_KEY = '__gevContextStore';
function createStore() {
@@ -36,14 +38,14 @@ export function registerEntityContext(entity, metadata) {
entity,
updatedAt: Date.now(),
};
entity.__gevContextId = metadata.id;
entityRecord(entity).contextId = metadata.id;
store.entities.set(metadata.id, record);
return record;
}
export function selectEntityContext(entity) {
const store = getContextStore();
const contextId = entity?.__gevContextId;
const contextId = readEntityRecord(entity)?.contextId;
if (!contextId || !store.entities.has(contextId)) return null;
store.selectedEntityId = contextId;
store.selectedAt = Date.now();
@@ -84,7 +86,7 @@ export function selectTrackedSubjectContext(metadata) {
store.entities.delete(key);
}
// Reuse the existing carrier so a per-poll refresh does not churn identity.
const carrier = store.entities.get(id)?.entity || { __gevContextId: id };
const carrier = store.entities.get(id)?.entity || {};
const record = registerEntityContext(carrier, { ...metadata, id });
if (!record) return null;
store.selectedEntityId = id;