Skip to content

Commit 3373d9e

Browse files
wellyshenWelly Shenclaude
authored
Agents Manager: show the chat on the Site Editor navigation view (#112372)
Revert the navigation-view hiding added in #112164. Remove `useHideChatOnSiteEditorNavigation` (and its test), the dock's render gate and layout-manager `isReady` wiring, and the now-unused `isSiteEditorCanvasEditMode` helper; un-export the admin-bar button IDs and sidebar class-name constants the hook imported. The `#wpadminbar` height fix and the `isChatEnabled` rename from that PR are kept. Co-authored-by: Welly Shen <welly.shen@automattic.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent f0d523a commit 3373d9e

6 files changed

Lines changed: 8 additions & 262 deletions

File tree

packages/agents-manager/src/components/agent-dock/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useAgentsManagerContext } from '../../contexts';
1313
import { useSetupCustomActions } from '../../hooks/custom-actions';
1414
import useAdminBarIntegration from '../../hooks/use-admin-bar-integration';
1515
import useAgentLayoutManager from '../../hooks/use-agent-layout-manager';
16-
import useHideChatOnSiteEditorNavigation from '../../hooks/use-hide-chat-on-site-editor-navigation';
1716
import useReaderChatPersistence from '../../hooks/use-reader-chat-persistence';
1817
import { useShouldUseUnifiedAgent } from '../../hooks/use-should-use-unified-agent';
1918
import { AGENTS_MANAGER_STORE } from '../../stores';
@@ -120,14 +119,8 @@ export default function AgentDock( {
120119
[ isReaderChat, setIsOpen ]
121120
);
122121

123-
// The chat can't work on the Site Editor navigation view, so keep the layout
124-
// manager idle there — no docking side effects (portal, body classes, tracking)
125-
// until the editing canvas opens.
126-
const isSiteEditorNavigation = useHideChatOnSiteEditorNavigation();
127-
128122
const { isDocked, canDock, dock, undock, openSidebar, closeSidebar, createAgentPortal } =
129123
useAgentLayoutManager( {
130-
isReady: ! isSiteEditorNavigation,
131124
defaultDocked: isReaderChat ? false : isPersistedDocked,
132125
defaultOpen: isPersistedOpen,
133126
desktopMediaQuery,
@@ -380,9 +373,9 @@ export default function AgentDock( {
380373
/>
381374
);
382375

383-
// Neither case has a chat to open, so render nothing — otherwise the editor
384-
// entry-point buttons below would be dead.
385-
if ( ! isChatEnabled || isSiteEditorNavigation ) {
376+
// When the chat is disabled there's nothing to open, so render nothing — the editor
377+
// entry-point buttons would otherwise be dead.
378+
if ( ! isChatEnabled ) {
386379
return null;
387380
}
388381

packages/agents-manager/src/hooks/__tests__/use-hide-chat-on-site-editor-navigation.test.ts

Lines changed: 0 additions & 127 deletions
This file was deleted.

packages/agents-manager/src/hooks/use-admin-bar-integration/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import type { AgentsManagerSelect } from '@automattic/data-stores';
99
import './style.scss';
1010

1111
// Admin bar element selectors
12-
export const ADMIN_BAR_BUTTON_ID = 'wp-admin-bar-agents-manager';
12+
const ADMIN_BAR_BUTTON_ID = 'wp-admin-bar-agents-manager';
1313
const ADMIN_BAR_CHAT_ITEM_ID = 'wp-admin-bar-agents-manager-chat-support';
1414
const ADMIN_BAR_HISTORY_ITEM_ID = 'wp-admin-bar-agents-manager-chat-history';
1515
const ADMIN_BAR_GUIDES_ITEM_ID = 'wp-admin-bar-agents-manager-support-guides';
1616

1717
// The standalone AI chat button — the chat's entry point, separate from the Help
1818
// menu. The wp-admin bar exposes it by ID; Calypso's masterbar by class.
19-
export const ADMIN_BAR_AI_CHAT_BUTTON_ID = 'wp-admin-bar-agents-manager-ai-chat';
19+
const ADMIN_BAR_AI_CHAT_BUTTON_ID = 'wp-admin-bar-agents-manager-ai-chat';
2020
const MASTERBAR_AI_CHAT_BUTTON_SELECTOR = '.masterbar__item-agents-manager-ai-chat';
2121

2222
/**

packages/agents-manager/src/hooks/use-agent-layout-manager/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ const FULLSCREEN_BODY_CLASS = 'is-fullscreen-mode';
2727
// `jetpack/projects/packages/agents-manager/src/js/sidebar-docking-gate.ts`.
2828
const CHAT_PORTAL_CLASS = 'agents-manager-chat';
2929

30-
// Container classes that reserve layout space for the docked sidebar; the Site
31-
// Editor navigation-view hook imports these to strip and restore them.
32-
export const SIDEBAR_CONTAINER_CLASS = 'agents-manager-sidebar-container';
33-
export const SIDEBAR_OPEN_CLASS = 'agents-manager-sidebar-container--sidebar-open';
30+
// Container classes that reserve layout space for the docked sidebar.
31+
const SIDEBAR_CONTAINER_CLASS = 'agents-manager-sidebar-container';
32+
const SIDEBAR_OPEN_CLASS = 'agents-manager-sidebar-container--sidebar-open';
3433
const SIDEBAR_CLOSING_CLASS = 'agents-manager-sidebar-container--closing';
3534

3635
function getIsFullscreenGateOpen(): boolean {

packages/agents-manager/src/hooks/use-hide-chat-on-site-editor-navigation.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

packages/agents-manager/src/utils/site-editor-context.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ export function isSiteEditorContext( environment?: string, currentRoute?: string
1111
);
1212
}
1313

14-
/**
15-
* True when the Site Editor shows its editing canvas (`?canvas=edit`) rather
16-
* than the navigation view. Scoped to the Site Editor so other admin pages that
17-
* happen to carry `?canvas=edit` aren't treated as canvas edit mode.
18-
*/
19-
export function isSiteEditorCanvasEditMode(): boolean {
20-
return (
21-
isSiteEditorContext() &&
22-
new URLSearchParams( window.location.search ).get( 'canvas' ) === 'edit'
23-
);
24-
}
25-
2614
export function getClientConstructorArguments(
2715
environment?: string,
2816
currentRoute?: string

0 commit comments

Comments
 (0)