Skip to content

docs: add ai controller documentation#5473

Draft
ugur-vaadin wants to merge 1 commit intomainfrom
docs-add-ai-controller-docoumentation
Draft

docs: add ai controller documentation#5473
ugur-vaadin wants to merge 1 commit intomainfrom
docs-add-ai-controller-docoumentation

Conversation

@ugur-vaadin
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-5473.fly.dev

Built from e7d1cb7

@ugur-vaadin ugur-vaadin requested a review from tomivirkki April 13, 2026 16:05
@ugur-vaadin ugur-vaadin changed the title docs: add ai controller docoumentation docs: add ai controller documentation Apr 13, 2026

= [since:com.vaadin:vaadin@V25.2]#AI-Powered Chart#

ifdef::flow[]
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.

I don't see any point with these conditionals.

Suggested change
ifdef::flow[]


[classname]`ChartAIController` manages a single chart. To expose several charts to the same orchestrator -- for example in a dashboard -- implement a custom [classname]`AIController` that builds its tool list from [classname]`ChartAITools.createAll()` with a [classname]`ChartAITools.Callbacks` implementation that returns a stable ID per chart.

endif::flow[]
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.

Suggested change
endif::flow[]


= [since:com.vaadin:vaadin@V25.2]#AI-Powered Grid#

ifdef::flow[]
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.

Suggested change
ifdef::flow[]


[classname]`GridAIController` manages a single grid. To coordinate several grids from the same orchestrator, implement a custom [classname]`AIController` that builds its tool list from [classname]`GridAITools.createAll()` with a custom [classname]`GridAITools.Callbacks` implementation. The callbacks -- [methodname]`getGridIds()`, [methodname]`getState(gridId)`, and [methodname]`updateData(gridId, query)` -- let the LLM address each grid by its ID.

endif::flow[]
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.

Suggested change
endif::flow[]


= [since:com.vaadin:vaadin@V25.2]#Controllers#

ifdef::flow[]
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.

Suggested change
ifdef::flow[]

[TIP]
Return only the tables, columns, and relationships the LLM needs. A smaller, well-described schema produces better queries, uses fewer tokens, and reduces the chance of leaking sensitive columns.

endif::flow[]
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.

Suggested change
endif::flow[]

:feature-flag: com.vaadin.experimental.aiComponents
include::{articles}/_preview-banner.adoc[opts=optional]

ifdef::flow[]
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.

Suggested change

section_outline::[]


endif::flow[]
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.

Suggested change


= Tool Calling & Programmatic Prompts

ifdef::flow[]
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.

Suggested change

[IMPORTANT]
[methodname]`prompt()` requires an active UI context. If called from a background thread or outside a Vaadin request, it throws an [classname]`IllegalStateException`. Always call [methodname]`prompt()` from within a UI event handler or wrap the call in `ui.access()`.

endif::flow[]
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.

Suggested change

Comment on lines +125 to +128
ChartState saved = sessionStore.load(sessionId);
if (saved != null) {
controller.restoreState(saved);
}
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.

I think this step isn't necessary, the chart's own state survives the serialization and doesn't need to be explicitly restored. Same thing with Grid

[source,java]
----
controller.addStateChangeListener(state ->
sessionStore.save(sessionId, state));
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.

Maybe sessionStore isn't ideal here since the primary use-case for state persistence is to restore the state across separate sessions (e.g. when a user logs in later and the original component no longer exists)

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.

3 participants