-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Agent Builder] Attachment inline rendering and UI actions #253329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
chrisbmar
wants to merge
11
commits into
elastic:main
from
chrisbmar:ab-attachment-inline-rendering-12939
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a21adae
define render attachment xml element server side
chrisbmar 7fc050b
update attachment ui definition interface with new methods
chrisbmar 574285c
markdown plugin initial implementation
chrisbmar 489ef34
wire up markdown plugin with dependencies
chrisbmar 28fa891
implement attachment with actions base logic
chrisbmar e6e9de1
rename file
chrisbmar b042eb5
remove console logs
chrisbmar 319ff23
Merge branch 'main' into ab-attachment-inline-rendering-12939
chrisbmar 92e310c
Merge branch 'main' into ab-attachment-inline-rendering-12939
chrisbmar 06fbbfc
update action button contract to include an icon
chrisbmar 6689c69
Merge branch 'main' into ab-attachment-inline-rendering-12939
chrisbmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...n/components/conversations/conversation_rounds/round_response/attachment_with_actions.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import type { UnknownAttachment } from '@kbn/agent-builder-common/attachments'; | ||
| import { EuiButton } from '@elastic/eui'; | ||
| import { AGENT_BUILDER_EXPERIMENTAL_FEATURES_SETTING_ID } from '@kbn/management-settings-ids'; | ||
| import type { AttachmentsService } from '../../../../../services/attachments/attachements_service'; | ||
| import { useKibana } from '../../../../hooks/use_kibana'; | ||
|
|
||
| interface AttachmentWithActionsProps { | ||
| attachment: UnknownAttachment; | ||
| attachmentsService: AttachmentsService; | ||
| isSidebar: boolean; | ||
| conversationId: string; | ||
| } | ||
|
|
||
| /** | ||
| * Component that renders an attachment with its action buttons. | ||
| */ | ||
| export const AttachmentWithActions: React.FC<AttachmentWithActionsProps> = ({ | ||
| attachment, | ||
| attachmentsService, | ||
| isSidebar, | ||
| conversationId, | ||
| }) => { | ||
| const { | ||
| services: { settings }, | ||
| } = useKibana(); | ||
| const isExperimentalFeaturesEnabled = settings?.client.get<boolean>( | ||
| AGENT_BUILDER_EXPERIMENTAL_FEATURES_SETTING_ID, | ||
| false | ||
| ); | ||
|
|
||
| if (isExperimentalFeaturesEnabled === false) { | ||
| return null; | ||
| } | ||
|
|
||
| const uiDefinition = attachmentsService.getAttachmentUiDefinition(attachment.type); | ||
|
|
||
| if (!uiDefinition) { | ||
| return null; | ||
| } | ||
|
|
||
| const actionButtons = uiDefinition.getActionButtons?.({ | ||
| attachment, | ||
| isSidebar, | ||
| updateOrigin: async (originId: string) => { | ||
| // TODO: Implement updateOrigin | ||
| // attachmentsService.updateOrigin(conversationId, attachment.id, originId); | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <> | ||
| {actionButtons?.map((button) => ( | ||
| <EuiButton key={button.label} onClick={button.handler}> | ||
| {button.label} | ||
| </EuiButton> | ||
| ))} | ||
| {uiDefinition?.renderContent?.({ attachment, isSidebar })} | ||
| </> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc. @joemcelroy whilst I've yet to implement the actual UI (future PR), I'd like to keep this behind the experimental feature flag just to ensure if the agent does include an
<attachment_renderer />XML tag that it doesn't show anything in the UI as we iteratively work towards including the final design - thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this is good