-
Notifications
You must be signed in to change notification settings - Fork 2k
Agents Manager: open the floating chat on the right at default size on responsive undock #113361
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
Changes from 3 commits
777a2ab
a5204d6
eed0274
249f4d8
d6e16e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,12 @@ import { | |
| type ChatState, | ||
| type UploadedImage, | ||
| } from '@automattic/agenttic-ui'; | ||
| import { useDispatch, useSelect } from '@wordpress/data'; | ||
| import { useCallback, useMemo, useRef } from '@wordpress/element'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import clsx from 'clsx'; | ||
| import { formatWritingSuggestionLabels } from '../../hooks/use-empty-view-suggestions'; | ||
| import useFloatingPanelProps from '../../hooks/use-floating-panel-props'; | ||
| import useHasAiChatEntryButton from '../../hooks/use-has-ai-chat-entry-button'; | ||
| import { AGENTS_MANAGER_STORE } from '../../stores'; | ||
| import { getAgentsManagerInlineData } from '../../utils/get-agents-manager-inline-data'; | ||
| import { isEditorPage } from '../../utils/is-editor-page'; | ||
| import { isReaderChatHost } from '../../utils/is-reader-chat-agent'; | ||
|
|
@@ -32,7 +31,6 @@ import GroupedEmptyView from './grouped-empty-view'; | |
| import type { UseImageUploadResult } from '../../hooks/use-image-upload'; | ||
| import type { ExternalContextCard, ExternalContextCardAction } from '../../utils/external-context'; | ||
| import type { Message, NoticeConfig } from '@automattic/agenttic-ui/dist/types'; | ||
| import type { AgentsManagerSelect } from '@automattic/data-stores'; | ||
| import type { ComponentProps, RefObject } from 'react'; | ||
|
|
||
| interface Props { | ||
|
|
@@ -184,14 +182,9 @@ export default function AgentChat( { | |
| onContextCardAction, | ||
| onContextCardDismiss, | ||
| }: Props ) { | ||
| const { setFloatingPosition, setFreeDragPosition, setFloatingSize } = | ||
| useDispatch( AGENTS_MANAGER_STORE ); | ||
| const conversationViewRef = useRef< HTMLDivElement >( null ); | ||
| const imageUploaderRef = useRef< ImageUploaderHandle >( null ); | ||
| const { floatingPosition, freeDragPosition, floatingSize } = useSelect( ( select ) => { | ||
| const store: AgentsManagerSelect = select( AGENTS_MANAGER_STORE ); | ||
| return store.getAgentsManagerState(); | ||
| }, [] ); | ||
| const floatingPanelProps = useFloatingPanelProps(); | ||
|
|
||
| const mergedComponents = useMemo( | ||
| () => ( { a: CustomALink, ...markdownComponents } ), | ||
|
|
@@ -289,12 +282,9 @@ export default function AgentChat( { | |
|
|
||
| return ( | ||
| <AgentUI.Container | ||
| initialChatPosition={ floatingPosition } | ||
| onChatPositionChange={ ( position ) => setFloatingPosition( position ) } | ||
| initialFreeDragPosition={ freeDragPosition ?? undefined } | ||
| onFreeDragEnd={ setFreeDragPosition } | ||
| defaultSize={ floatingSize ?? undefined } | ||
| onResizeEnd={ setFloatingSize } | ||
| // Remount on dock/undock so the mount-only seed props re-apply. | ||
| key={ isDocked ? 'embedded' : 'floating' } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My agent says there could be a problem with this
|
||
| { ...floatingPanelProps } | ||
| className={ clsx( 'agenttic', { dark: isDocked } ) } | ||
| messages={ messages } | ||
| isProcessing={ isProcessing } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.