Skip to content

feat: add field highlighting for ai updated fields#9413

Open
ugur-vaadin wants to merge 3 commits into
mainfrom
feat-add-field-highlighting-for-ai-updated-fields
Open

feat: add field highlighting for ai updated fields#9413
ugur-vaadin wants to merge 3 commits into
mainfrom
feat-add-field-highlighting-for-ai-updated-fields

Conversation

@ugur-vaadin
Copy link
Copy Markdown
Contributor

Description

This PR:

  • Adds withFieldValuesChanged(Consumer<Map<HasValue, FieldValueChange>>), which fires once per successful turn. Ignored fields are excluded. Skipped when the turn ended in error or when no field changed.
  • Adds showHighlight(HasValue) and hideHighlight(HasValue) to control the highlighter. Each controller carries a per-instance UUID id (vaadin-ai-<uuid>) and uses addUser / removeUser, so the AI highlight coexists with any other field-highlighter user the application keeps on the same field. The highlight is not retained across detach/re-attach.

Fixes https://github.com/orgs/vaadin/projects/103/views/1?filterQuery=&pane=issue&itemId=193540699

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.
  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

* handler
* @return this controller, for chaining
*/
public FormAIController withFieldValuesChanged(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The method naming doesn't fit into the controller interface. We've typically used the with-prefixed API in builders

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should be changed to addFieldValueChangedListener with field, old value, new value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR:

  • Listener name is now addFieldValueChangedListener
  • FieldValueChange now contains the HasValue field
  • The listener parameter consumer now provides the list of changes rather than a map.

static void show(Element field, String userId) {
field.executeJs(
"customElements.get('vaadin-field-highlighter')"
+ ".addUser(this, {id: $0, name: 'AI', colorIndex: 0})",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The AI-tag looks somewhat unexpected

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The decision after discussion: keep the name as "AI" for now.

* entry — other users on the field stay untouched.
*/
static void show(Element field, String userId) {
field.executeJs(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will probably not survive reattach. Should be wrapped in an attach listener

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants