Skip to content

feat(frontend): add UDF parameters from the panel - #7551

Merged
aicam merged 11 commits into
apache:mainfrom
carloea2:feat/frontend-udf-param-insert
Aug 13, 2026
Merged

aicam merged 11 commits into
apache:mainfrom
carloea2:feat/frontend-udf-param-insert

Conversation

@carloea2

@carloea2 carloea2 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor
image image

What changes were proposed in this PR?

This PR lets users add Python UDF parameters directly from the properties panel.

The parameter list now includes a dashed Add parameter button. Clicking it opens an inline draft row where the user can enter a name, select a supported type, and confirm with the check button or Enter, or cancel with the close button or Escape.

Confirming the draft inserts a self.UiParameter(...) declaration into the operator's shared Python code. The code remains the single source of truth: the parameter row appears through the existing parse-and-sync flow instead of being written directly into the form model.

The insertion logic:

  • groups new declarations with existing UiParameter declarations;
  • inserts into an existing open() method when available;
  • creates open() when it is absent;
  • handles docstrings, decorators, pass, comments, and empty class bodies;
  • converts display names into safe Python assignment targets while preserving the exact parameter name;
  • rejects missing names, duplicate declarations, unsupported types, and unsupported UDF code shapes.

Any related issues, documentation, discussions?

Closes #7552

How was this PR tested?

Manual verification by the author covered the add, confirm/cancel, declaration insertion, and properties-panel synchronization flows.

Frontend CI formatting and lint:

cd frontend
yarn format:ci

The command passes.

The updated specifications cover component actions and error states, shared-code insertion and synchronization, declaration placement, identifier sanitization, duplicate names, unsupported types, unsupported classes, and malformed class bodies.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code Fable 5 Ultra, OpenAI Codex 5.6 Ultra, and Me

…anel

Adding a parameter in the Python UDF properties panel now writes the
self.UiParameter(...) declaration into the code, creating open() when
the UDF class does not define one. The code stays the single source of
truth: the add action only edits the shared Y.Text code buffer and the
row appears through the existing parse/merge sync loop.
…r declarations

A template whose statements are still commented out parses as a class
body holding only comments and a lezer error node. The error node was
treated as an anchor statement, so the synthesized open() landed at
module level at the end of the file. Filter error nodes out and, when a
class or open() body has no real statements yet, insert right after the
header line with one extra indent level.
…t rule

All placement cases (docstrings, decorators, pass-only, commented-out,
and empty bodies) collapse into a single rule shared by class and
open(): insert before the first real statement, or right after the
header line when the body has none yet. parse() and the insertion share
the class discovery and call traversal, and the add form becomes a
single always-visible row with the name validation living only in the
parser.
…d tables

Each placement case is now a single annotated file where '>' marks the
inserted lines, so input and expected output are derived from one copy;
every case re-parses its result, absorbing the separate round-trip
tests. The redundant undecorated-open case and duplicated fixtures are
gone.
The standalone name/type/Add strip read as another parameter row. It is
now a dashed 'Add parameter' button under the list that opens a draft
row in the same three-column grid, confirmed with a check button or
Enter and dismissed with close or Escape.
@carloea2
carloea2 marked this pull request as ready for review August 11, 2026 08:12
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@github-actions github-actions Bot added feature frontend Changes related to the frontend GUI labels Aug 11, 2026
@codecov-commenter

codecov-commenter commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.06%. Comparing base (7daf8d7) to head (650ef75).

Files with missing lines Patch % Lines
...ce/code-editor/ui-udf-parameters-parser.service.ts 91.04% 0 Missing and 6 partials ⚠️
...ui-udf-parameters/ui-udf-parameters.component.html 89.28% 3 Missing ⚠️
...t/ui-udf-parameters/ui-udf-parameters.component.ts 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7551      +/-   ##
============================================
- Coverage     88.63%   87.06%   -1.58%     
+ Complexity     4346     4226     -120     
============================================
  Files          1177     1173       -4     
  Lines         46896    46782     -114     
  Branches       5230     5235       +5     
============================================
- Hits          41568    40731     -837     
- Misses         3568     4332     +764     
+ Partials       1760     1719      -41     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 133da7b
agent-service 89.01% <ø> (-9.61%) ⬇️ Carriedforward from 133da7b
amber 82.14% <ø> (-2.58%) ⬇️ Carriedforward from 133da7b
computing-unit-managing-service 60.09% <ø> (-0.29%) ⬇️ Carriedforward from 133da7b
config-service 65.97% <ø> (-11.35%) ⬇️ Carriedforward from 133da7b
file-service 69.05% <ø> (ø) Carriedforward from 133da7b
frontend 90.06% <91.66%> (+0.08%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 133da7b
pyamber 97.51% <ø> (-0.01%) ⬇️ Carriedforward from 133da7b
workflow-compiling-service 26.31% <ø> (-31.58%) ⬇️ Carriedforward from 133da7b

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carloea2

Copy link
Copy Markdown
Contributor Author

@aicam can you review it?

@carloea2

Copy link
Copy Markdown
Contributor Author

/request-review @aicam

@github-actions
github-actions Bot requested a review from aicam August 11, 2026 21:11

@aicam aicam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a parameter can emit Python that doesn't compile. If the UDF already
declares a UiParameter inside a compound statement's header — e.g.
if self.UiParameter(name="debug", type=AttributeType.BOOL).value: — and the
next statement is a for/while/if block, the new declaration is inserted
between that header and its body.

Image

@carloea2

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I changed the insertion logic so new parameters are added at the top of open(), immediately after its docstring when present. This avoids relying on the previous declaration’s syntax boundary, which caused the invalid indentation in your example.

I also added a regression test for the exact if followed by for case shown in your feedback. The focused frontend tests now pass (33/33), along with the frontend formatting and lint checks. Could you please take another look?

@aicam
aicam self-requested a review August 13, 2026 18:16

@aicam aicam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aicam
aicam added this pull request to the merge queue Aug 13, 2026
Merged via the queue into apache:main with commit 4afe8d4 Aug 13, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UDF parameters from the properties panel

3 participants