From 013414e99cb44f340f9d662a4a9d0e759f1b0c0c Mon Sep 17 00:00:00 2001 From: Ernest Tien Date: Mon, 23 Nov 2026 17:14:49 -0800 Subject: [PATCH] fix(CommentComposer): the agent command menu words its rows through the catalog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `/` menu built each agent's usage line, `/ask `, and its summary, `name · description`, in code, so the placeholder word and the separator stayed English in every locale. Two catalog messages, `@astryx.commentComposer.agentCommandUsage` and `@astryx.commentComposer.agentCommandSummary`, now word them. English output is unchanged. --- .../comment-composer-agent-menu-catalog.md | 7 ++++ packages/core/locales/en.json | 8 ++++ .../lab/src/Comments/CommentComposer.test.tsx | 38 +++++++++++++++++++ packages/lab/src/Comments/CommentComposer.tsx | 21 ++++++++-- 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 .changeset/comment-composer-agent-menu-catalog.md diff --git a/.changeset/comment-composer-agent-menu-catalog.md b/.changeset/comment-composer-agent-menu-catalog.md new file mode 100644 index 0000000000000..e900900ca2600 --- /dev/null +++ b/.changeset/comment-composer-agent-menu-catalog.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/core': patch +--- + +[fix] The catalog words both lines of each agent in the comment composer's `/` menu: `@astryx.commentComposer.agentCommandUsage` ("/{command} ''") and `@astryx.commentComposer.agentCommandSummary` ("{name} · {description}"), so a locale can translate the placeholder word and the separator. English output is unchanged. + +@ernestt diff --git a/packages/core/locales/en.json b/packages/core/locales/en.json index 01caad3d2a41e..db6fe716c8221 100644 --- a/packages/core/locales/en.json +++ b/packages/core/locales/en.json @@ -2371,6 +2371,14 @@ "defaultMessage": "Agents", "description": "Accessible name of a lab CommentComposer's slash-command menu, which lists the AI agents a comment can address." }, + "@astryx.commentComposer.agentCommandUsage": { + "defaultMessage": "/{command} ''", + "description": "First line of an AI agent in a lab CommentComposer's slash-command menu: how to address the agent. {command} is the command after the slash, such as ask. Keep /{command}. Translate only the word prompt, the placeholder for what the viewer asks; the apostrophes keep the angle brackets as text." + }, + "@astryx.commentComposer.agentCommandSummary": { + "defaultMessage": "{name} · {description}", + "description": "Second line of an AI agent in a lab CommentComposer's slash-command menu. {name} is the agent's name and {description} says what asking it does; the app writes both." + }, "@astryx.commentComposer.uploadFailed": { "defaultMessage": "Images couldn't be added", "description": "Error Banner title in a lab CommentComposer when uploading attached images failed; a Retry action follows." diff --git a/packages/lab/src/Comments/CommentComposer.test.tsx b/packages/lab/src/Comments/CommentComposer.test.tsx index 7fbd579faed12..5faeac074ca44 100644 --- a/packages/lab/src/Comments/CommentComposer.test.tsx +++ b/packages/lab/src/Comments/CommentComposer.test.tsx @@ -8,6 +8,7 @@ import { type ComponentProps, } from 'react'; import {act, fireEvent, render, screen, within} from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import { afterAll, afterEach, @@ -36,6 +37,7 @@ vi.mock('../EmojiPicker/emojiData', () => ({ ], })); +import {InternationalizationProvider} from '@astryxdesign/core/i18n'; import {CommentComposer, CommentComposerBase} from './CommentComposer'; const originalMatches = HTMLElement.prototype.matches; @@ -125,6 +127,42 @@ describe('CommentComposer', () => { expect(onAncestorClick).toHaveBeenCalledTimes(1); }); + it('words the agent command menu through the catalog', async () => { + const user = userEvent.setup(); + function Host() { + const [value, setValue] = useState(''); + return ( + '", + '@astryx.commentComposer.agentCommandSummary': + '{name} : {description}', + }, + }}> + + + ); + } + render(); + await user.type(screen.getByRole('combobox'), '/'); + expect(await screen.findByText('/ask ')).toBeTruthy(); + expect(screen.getByText('Assistant : Répond aux questions')).toBeTruthy(); + }); + it('posts the draft from Post, and never an empty one', async () => { const onSubmit = vi.fn(); const {rerender} = render( diff --git a/packages/lab/src/Comments/CommentComposer.tsx b/packages/lab/src/Comments/CommentComposer.tsx index e3eaa432c4e43..d6db89c7c7c49 100644 --- a/packages/lab/src/Comments/CommentComposer.tsx +++ b/packages/lab/src/Comments/CommentComposer.tsx @@ -116,8 +116,8 @@ type AgentCommandItem = ChatComposerTriggerItem & { auxiliaryData: CommentAgentCommand; }; -function renderAgentCommandItem(item: ChatComposerTriggerItem): ReactNode { - const agent = (item as AgentCommandItem).auxiliaryData; +function AgentCommandOption({agent}: {agent: CommentAgentCommand}) { + const t = useTranslator(); return ( - {`/${agent.command} `} + + {t('@astryx.commentComposer.agentCommandUsage', { + command: agent.command, + })} + - {`${agent.name} · ${agent.description}`} + {t('@astryx.commentComposer.agentCommandSummary', { + name: agent.name, + description: agent.description, + })} ); } +function renderAgentCommandItem(item: ChatComposerTriggerItem): ReactNode { + return ( + + ); +} + /** The `/` menu of the agents a comment can address, or null for none. */ function useAgentCommandTrigger( agents: readonly CommentAgentCommand[],