Skip to content

Read an element's label and value without expanding the array - #55

Merged
ww-mw merged 1 commit into
mainfrom
element-display-without-expansion
Oct 2, 2026
Merged

ww-mw merged 1 commit into
mainfrom
element-display-without-expansion

Conversation

@ww-mw

@ww-mw ww-mw commented Oct 2, 2026

Copy link
Copy Markdown
Member

MAX_EXPANDED_ELEMENTS stops a 1000x1000 double from becoming a million table rows. That is right for the table and wrong for everything else: the only channel a consumer had for element-by-element display text was the child nodes, so capping expansion took the Variable Editor grid's data with it.

displayElements() is that channel as an accessor over _elements:

  • Where element children exist, they are the answer — not a second derivation of it — so the two paths cannot drift apart. test/displayElements.test.ts pins the agreement between the paths rather than either one alone.
  • Where they do not, one re-seeded scratch node formats each element through the same getter a child would have used, so the numeric precision, the char/string budgets and the <unavailable> sentinel stay single-sourced. Allocates nothing per element beyond the answer.
  • null for a kind with no elements; [] for an array with none.
  • Asking never creates a child, so reading the panel's data cannot undo the cap.

_elementType is now recorded before the cap guard, because a complex array is the one shape whose element class cannot be inferred from the container (_scalarType is double; the elements are complex).

Also closes two holes in the cap itself. The structured _array_type: 'String' parse and the bare JSON list of strings each built their element children with an inline loop instead of calling _buildStringChildren, so a 10,000-element string array expanded in full from those two spellings while the identical array written as an inline literal did not. Both go through the choke point now, and largeArrayNotExpanded.test.ts would notice a fourth spelling arriving with its own loop.

npm run verify green: 5136 tests.

MAX_EXPANDED_ELEMENTS stops a 1000x1000 double from becoming a million
table rows, which is right for the table and wrong for everything else:
the only channel a consumer had for element-by-element display text was
the child nodes, so capping expansion took the Variable Editor grid's
data with it.

displayElements() is that channel as an accessor over `_elements`. Where
the children exist they ARE the answer, so the two paths cannot drift;
where they do not, one re-seeded scratch node formats each element
through the same getter a child would have used, allocating nothing per
element beyond the answer. `_elementType` is now recorded before the cap
guard, because a complex array is the one shape whose element class
cannot be inferred from the container.

Also closes two holes in the cap itself. The structured `_array_type:
'String'` parse and the bare JSON list of strings each built their
element children with an inline loop instead of calling
_buildStringChildren, so a 10,000-element string array expanded in full
from those two spellings while the identical array written as an inline
literal did not. Both go through the choke point now.
@ww-mw
ww-mw merged commit 1df0a13 into main Oct 2, 2026
4 checks passed
@ww-mw
ww-mw deleted the element-display-without-expansion branch October 2, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant