Skip to content

Inline variable declaration in expression fields#11

Merged
creativeskyai merged 1 commit into
mainfrom
ux/variable-assist-expression-fields
Jul 16, 2026
Merged

Inline variable declaration in expression fields#11
creativeskyai merged 1 commit into
mainfrom
ux/variable-assist-expression-fields

Conversation

@creativeskyai

@creativeskyai creativeskyai commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Inline variable declaration in expression fields

Free-SAIL expression slots (Condition, True/False values, local-variable
values, loop bodies) were bare text inputs with no variable assistance, so
referencing or declaring a variable meant a trip to the Variables tab. They now
get an insert-at-caret variable picker:

  • Type a domain-qualified token (ri!, local!tot) and a dropdown offers
    matching declared variables plus one-click "Create ri!/local!" rows. A bare
    identifier does not auto-open (it is as likely a function name); the ! is the
    unambiguous "writing a reference" signal. A braces button opens the menu on
    demand to browse/insert any declared variable.
  • The choice replaces exactly the analyzed token, not the whole field, because
    an expression is a full formula. The replaced span is fixed to the token
    [start, start+len) rather than the live caret, so a caret that drifts (arrow
    keys / a reposition click) while the menu is open never duplicates the token.

The dropdown machinery (option ranking, portaled-panel anchoring, list
rendering) is factored into a shared variableMenu module so ExpressionInput
and the existing VariableCombobox stay behaviour- and pixel-identical from one
source of truth. Text and record-reference fields are deliberately excluded:
text serializes to a quoted literal and record refs are not variables.

Adds 5 UI acceptance tests (incl. a caret-drift regression); 179 passing. Docs
updated.

Free-SAIL `expression` slots (Condition, True/False values, local-variable
values, loop bodies) were bare text inputs with no variable assistance, so
referencing or declaring a variable meant a trip to the Variables tab. They now
get an insert-at-caret variable picker:

- Type a domain-qualified token (`ri!`, `local!tot`) and a dropdown offers
  matching declared variables plus one-click "Create ri!/local!" rows. A bare
  identifier does not auto-open (it is as likely a function name); the `!` is the
  unambiguous "writing a reference" signal. A braces button opens the menu on
  demand to browse/insert any declared variable.
- The choice replaces exactly the analyzed token, not the whole field, because
  an expression is a full formula. The replaced span is fixed to the token
  `[start, start+len)` rather than the live caret, so a caret that drifts (arrow
  keys / a reposition click) while the menu is open never duplicates the token.

The dropdown machinery (option ranking, portaled-panel anchoring, list
rendering) is factored into a shared `variableMenu` module so ExpressionInput
and the existing VariableCombobox stay behaviour- and pixel-identical from one
source of truth. Text and record-reference fields are deliberately excluded:
text serializes to a quoted literal and record refs are not variables.

Adds 5 UI acceptance tests (incl. a caret-drift regression); 179 passing. Docs
updated.
@creativeskyai
creativeskyai force-pushed the ux/variable-assist-expression-fields branch from f594403 to f5552d0 Compare July 16, 2026 00:24
@creativeskyai
creativeskyai merged commit 85fcf7b into main Jul 16, 2026
1 check passed
@creativeskyai
creativeskyai deleted the ux/variable-assist-expression-fields branch July 16, 2026 00:26
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