fix(data): observeSelectDeep dropped entity id when include carried the id column - #174
Merged
Merged
Conversation
…he id column pickComponents seeded `data.id = entity`, then copied every include key from the read values. An archetype's runtime `components` set still contains the "id" column (id is a live column, only typed-out), so passing it as `include` — as real consumers do — put "id" in the copy loop. Since reads now omit id, the loop overwrote `data.id` with `values["id"]` (undefined), handing back id-less rows. Before id-removal this was masked (reads still carried the correct id, so the overwrite was a no-op). After, every deep-select row got `id: undefined`, silently breaking consumers that key off `row.id` (e.g. a layout system that feeds `row.id` back into a per-entity transaction — the transaction no-ops on the undefined entity and the layout never converges). Skip "id" in the copy loop and assign `data.id = entity` last. Regression test drives the include set straight off `archetype.components`, which reproduces the clobber. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Version bump for the observeSelectDeep id-clobber fix so it can publish. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
observeSelectDeepreturns rows withid: undefinedwhenever theincludeset carries theidcolumn — which an archetype's runtimecomponentsset does, and which real consumers pass directly (e.g.observeSelectDeep(db, db.archetypes.Foo.components)).pickComponentsseededdata.id = entity, then copied every include key from the read values:Since the id-removal change made reads omit
id,values["id"]isundefined, and the loop overwrites the correct id. Before id-removal this was masked (the read still carried the right id, so the overwrite was a no-op).Impact
Any consumer that keys off
row.idfrom a deep select silently getsundefined. This surfaced as a studio layout regression in firefly-platform: the layout system feedsrow.idinto a per-entitysetLayoutIntrinsictransaction; withidundefined the transaction no-ops, so measured element sizes are never recorded, the layout never converges, and top-bar/sidenav controls never settle — breaking three P0 studio E2E tests. Verified end-to-end that this fix resolves them.Fix
Skip
"id"in the copy loop and assigndata.id = entitylast, so the id column present in the include set can't clobber it. Regression test drivesincludestraight offarchetype.components(which carries the id column) — the old tests passed an explicit array withoutid, so they missed it.Full data suite green (3023); typecheck clean.
🤖 Generated with Claude Code