Docs

Component Interfaces

AI interface contracts for input, message list, message, and file receiver components used by the AiOrchestrator.

The orchestrator’s builder accepts both standard Vaadin components and custom implementations of the AI interfaces. This allows you to swap in custom UI components without changing the orchestrator wiring.

AI Input

AiInput defines the contract for text input components. It has one method to implement:

  • addSubmitListener(SerializableConsumer<String>) — registers a listener that receives the submitted text.

The builder accepts either a MessageInput directly or any AiInput implementation.

Disabling Submit

The orchestrator handles one prompt at a time, so it disables submitting on the input while it processes a prompt. It does the same while a file is uploading to an Upload or UploadManager set as the file receiver. It enables submitting again when the turn has ended and no file is uploading. A MessageInput needs no application code for this. The user can keep typing and the typed text stays in the field — see Disabling Submit.

A custom AiInput gets the same behavior by overriding the following default methods:

  • setSubmitDisabled(boolean) — sets whether submitting is disabled. The default implementation does nothing.

  • isSubmitDisabled() — returns whether submitting is disabled. The default implementation returns false.

An implementation that doesn’t override them keeps working, but submitting isn’t disabled on it. The orchestrator ignores a message submitted in the meantime and logs a warning.

AI Message List

AiMessageList defines the contract for displaying messages. Key methods:

  • addMessage(String text, String userName, List<AiAttachment> attachments) — creates and adds a message, returning an AiMessage handle.

  • addAttachmentClickListener(AttachmentClickCallback) — registers a handler for attachment click events.

  • showTypingIndicator(String userName) / hideTypingIndicator(String userName) — show and hide an indication that the given participant is working on a response. The orchestrator calls the first when a turn starts and adds the assistant message only when the first part of the response arrives, so an implementation that wants to show progress before that overrides it. The second is called before the assistant message is added, and when a turn ends without a response. Both are default no-ops, so a custom implementation that doesn’t override them keeps working.

The builder accepts either a MessageList directly or any AiMessageList implementation. With a MessageList, the orchestrator adds and removes only its own entry among the list’s typing users. When the application has bound the typing users to a signal, they can’t be set, and the orchestrator leaves the indicator to the application.

AI Message

AiMessage represents a single message. It is returned by AiMessageList.addMessage() and supports:

  • getText() / setText(String) — read or replace the message text.

  • appendText(String) — append a token during streaming. The orchestrator calls this as tokens arrive from the LLM.

  • getTime() / setTime(Instant) — message timestamp.

  • getUserName() — the sender display name.

AI File Receiver

AiFileReceiver defines the contract for file upload components. It has one method to implement:

  • takeAttachments() — returns all pending attachments and clears the internal state. The orchestrator calls this when the user submits a message.

A receiver can also override the following default method:

  • isUploading() — returns whether a file is still being uploaded to the receiver. While it returns true, the orchestrator ignores the prompts that would take their attachments from the receiver — see Uploads in Progress. The default implementation returns false.

The builder accepts UploadManager, Upload, or any AiFileReceiver implementation.

The orchestrator installs its own in-memory upload handler on UploadManager or Upload. The component must not have an upload handler already set.

Updated –