Skip to content

Infer DS labels from code + argument display names (arg-N)#128

Open
mkayander wants to merge 3 commits into
mainfrom
cursor/infer-ds-variable-labels-3270
Open

Infer DS labels from code + argument display names (arg-N)#128
mkayander wants to merge 3 commits into
mainfrom
cursor/infer-ds-variable-labels-3270

Conversation

@mkayander
Copy link
Copy Markdown
Owner

@mkayander mkayander commented Apr 14, 2026

Summary

Runtime structure labels (JS/Python)

  • JavaScript: Array literals under simple bindings use __dstructArrayLiteralWithName; single-string literals stay unnamed to avoid ambiguity.
  • Python: Parent-linked AST infers list literal names from assignments; TrackedList passes displayLabel in addArray options.
  • Viewer: displayLabel on array/map/matrix slices; trees/graphs unchanged.

Test case arguments (this PR)

  • ArgumentObject.label — optional, non-unique display string. name remains the only stable store / structure key (short-uuid for new defaults).
  • Default visible name: arg-${order + 1} via getArgumentDisplayLabel() when label is empty.
  • Rename UI: Suffix icon on argument inputs opens a Popover (tooltip-style) with a text field; changes save with 300ms debounce and flush on close.
  • Input labels: {displayName} ({type}), e.g. arg-1 (Array).
  • Legacy naming: New projects/cases use short-uuid keys instead of head / array; addCase for binary tree creates a uuid argument, not head.

Files of note

  • src/entities/argument/lib/getArgumentDisplayLabel.ts, caseSlice.updateArgumentLabel
  • src/features/argsEditor/ui/ArgumentRenameSuffix.tsx, ArgInput.tsx, ArgsEditor.tsx (delete tooltip uses display name)
  • src/server/api/routers/project.ts (getDefaultArguments, addCase)
  • src/features/treeViewer/hooks/useArgumentsParsing.ts (structure displayLabel from display name)

Testing

  • pnpm test:ci
  • pnpm run tsc

Branch

Rebased onto latest main; includes prior DS label commit + this args commit.

Open in Web Open in Cursor 

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dstruct Ready Ready Preview, Comment Apr 23, 2026 10:05pm

@cursor cursor Bot force-pushed the cursor/infer-ds-variable-labels-3270 branch from 54babea to 7956594 Compare April 23, 2026 19:22
@mkayander mkayander marked this pull request as ready for review April 23, 2026 19:32
@cursor cursor Bot changed the title Infer data structure display labels from variable names (JS/Python) Infer DS labels from code + argument display names (arg-N) Apr 23, 2026
@cursor cursor Bot force-pushed the cursor/infer-ds-variable-labels-3270 branch from 7956594 to 55d0d43 Compare April 23, 2026 19:53
cursoragent and others added 3 commits April 23, 2026 22:01
- JS: extend array literal transform to call __dstructArrayLiteralWithName
  for const/assign/assignment-pattern RHS; keep unnamed helper for
  single-string literals and return-position literals
- Runtime: build labeled literals via ControlledArray with displayLabel in addArray options
- Redux: store displayLabel on ArrayData; show caption in array/map/matrix views
- Python: attach AST parents and infer list names from assign/ann/aug assign;
  pass displayLabel in TrackedList addArray options; seed case arg labels from arg name

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
- Add optional ArgumentObject.label (non-unique); getArgumentDisplayLabel falls back to arg-{order+1}
- caseSlice.updateArgumentLabel + include label in args content signature
- ArgInput: composite field labels; suffix rename opens Popover with debounced 300ms save + flush on close
- JsonInput: suffixSlot + timeout passthrough; string/json inputs use 300ms debounce
- New projects/cases: short-uuid argument ids instead of head/array keys; addCase binary tree uses uuid
- useArgumentsParsing: structure displayLabel uses display name, not store id
- i18n: rename tooltip strings (en + generated types)

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
- Extend array literal transform: append { displayLabel } to new Array/ArrayProxy
  when RHS is inferable; skip ambiguous new Array(singleNumber) length form
- Require array literal parent to be actual RHS (init/right) for named literals
- ArrayProxy constructor accepts optional trailing options object for displayLabel

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
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.

2 participants