Skip to content

Commit e095c87

Browse files
wellyshenWelly Shenclaude
authored
Agents Manager: Restrict zoom action to editor pages (#109908)
* fix: Restrict zoom action to editor pages The zoom action button was appearing on all pages, but it should only be available on editor pages (site editor, post/page editor) where show_component tool messages are meaningful. Also aligns the action id with the convention used by other message action hooks. BSKY-1892 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove unnecessary `as const` assertion in use-sources-action Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Welly Shen <welly.shen@automattic.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 30449a5 commit e095c87

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/agents-manager/src/hooks/use-sources-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function useSourcesAction( registerMessageActions: RegisterMessag
4747

4848
return [
4949
{
50-
type: 'component' as const,
50+
type: 'component',
5151
id: 'sources',
5252
label: 'Sources',
5353
component: SourcesDisplay,

packages/agents-manager/src/hooks/use-zoom-action.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect } from '@wordpress/element';
22
import ZoomActionButton from '../components/zoom-action-button';
3+
import { isEditorPage } from '../utils/is-editor-page';
34
import type { UseAgentChatReturn, UIMessage } from '@automattic/agenttic-client';
45

56
type RegisterMessageActions = UseAgentChatReturn[ 'registerMessageActions' ];
@@ -12,7 +13,7 @@ export default function useZoomAction( registerMessageActions: RegisterMessageAc
1213
registerMessageActions( {
1314
id: 'agents-manager-zoom',
1415
actions: ( message: UIMessage ) => {
15-
if ( message.role !== 'agent' ) {
16+
if ( message.role !== 'agent' || ! isEditorPage() ) {
1617
return [];
1718
}
1819

@@ -30,7 +31,7 @@ export default function useZoomAction( registerMessageActions: RegisterMessageAc
3031
return [
3132
{
3233
type: 'component',
33-
id: 'zoom-toggle',
34+
id: 'zoom',
3435
component: ZoomActionButton,
3536
order: 5,
3637
},

0 commit comments

Comments
 (0)