Repository navigation
FE-2039: Let a plugin provide the AI assistant panel's content and title bar - #10103
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A plugin that declares assistant fills the panel below the editor's title bar and fills the title bar with AssistantPanelTitle. The built-in chat stays as it is and shows while no such plugin runs.
Each built-in chat export, the prop and the chat's entry points carry @deprecated with the replacement: a plugin that declares assistant renders its own chat.
43b17e3 to
e930d6c
Compare
The title slot gave pointer events back to every element with a tabindex, so a tab list with tabindex="-1" covered the drag handle. Only buttons, links, form fields and elements that take keyboard focus opt back in.
TypeScript ignores @deprecated on an export-from line, and the declaration bundler drops comments on re-exported names, so imports from @hashintel/petrinaut/ui were never flagged. The barrel now re-exports a tagged alias of the AI SDK class, as a value and a type.
PR SummaryMedium Risk Overview Editor wiring chooses plugin vs built-in through Reviewed by Cursor Bugbot for commit 33b5cc7. Bugbot is set up for automated code reviews on this repo. Configure here. |
The actions container had no box of its own, so a button without position: relative painted under the title bar's drag layer and lost every click. The container is now a positioned row above that layer, hidden while empty so it adds no gap.
…ample The example's Clear button reads useChat's messages and shows only once there are messages: title bar parts render inside content, so they see its state. It uses the one-call form, which the guide's rules give a plugin that keeps no definition.
The content draws Chat and Ledger tabs in the title bar with AssistantPanelTitle and switches its own body, where the built-in chat took an additionalTab.
An assistant's onPrompt receives the message the user sends from the empty-net prompt, after the editor opens the panel, and the prompt shows while it is set. When the panel opens, the content's element marked data-autofocus takes focus, or else the panel. useEditorAssistant also returns the built-in chat, so the view states once which assistant wins.
The main example keeps the chat in the plugin's hook as an AI SDK Chat, so onPrompt can send the empty-net prompt's message to it, and the content reads it with useChat. The tabs example takes the same Chat, the onPrompt paragraph moves above the examples, and the separate onPrompt snippet goes.
Summary
Adds an
assistantcontribution to the plugin API. A plugin renders any React content in the AI assistant panel and fills its title bar, and the editor owns the panel's frame, placement, resizing, dock toggle and Close.Editor shows the first running plugin that provides an assistant, and the
aiAssistantprop's built-in chat while none runs. Built-in chat does not change, and the empty-net prompt also serves a plugin assistant that takes it.aiAssistantprop and the built-in chat's API are marked deprecated. Replaces #9914.Before
With a second tab, the built-in chat drew both tabs:
After
The chat lives in the plugin's hook, so
onPromptcan send the empty-net prompt's message to it:With a second tab, the content draws its own tabs in the title bar:
Links
Changes
Plugin API
assistant: truelets a plugin provide the AI assistantcontentfills the panel below its title barAssistantPanelTitlefills the title bar from insidecontentuseAssistantPanel()reads whether the panel is open and closes itassistant.onPrompt(text)takes the empty-net prompt's messagedata-autofocusmarks the element that takes focus when the panel opensaiAssistantprop and the built-in chat's API are deprecatedEditor
Test coverage
editor-assistant.test.tsx:editor-view.test.tsx:define-petrinaut-plugin.test.ts:@hashintel/petrinautand website unit suites:How to test
Build an SIR modelin prompt