Skip to content

Kitto.Web.Handler.Chat

Attribute-routed endpoints for the in-app help chat: the drawer history partial, message send (enqueues the provider call on the chat runner and returns the user bubble plus a pending assistant bubble), the poll endpoint the client uses to fetch the assistant reply once the worker has produced it, and a conversation reset. Requires an authenticated user; all responses are HTML fragments requested by htmx/fetch (with the X-KittoX header), so the navigation guard leaves them alone and no [TKXNavigable] is needed.

TKXChatHandler class

Serves the help-chat drawer history, message send, reply polling and conversation reset.

pascal
procedure HandlePanel;

Returns the HTML of the current user's conversation (all bubbles), or a greeting when empty. Requested when the drawer opens.

pascal
procedure HandleSend;

Accepts a user message (form fields message and optional viewName), appends it plus a pending assistant bubble, submits the provider call to the chat runner, and returns both bubbles for immediate display. The assistant bubble carries its id for polling.

pascal
procedure HandlePoll([TKXPathParam('MsgId')] const AMsgId: string);

Returns the assistant bubble for the given message id. While the worker is still producing the reply the bubble is marked pending (typing indicator); once ready it carries the final text (or the error).

pascal
procedure HandleClear;

Clears the current user's conversation and returns the greeting.

Released under Apache License, Version 2.0.