mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
fix(frontend): localize main chat send and stop button names (#8588)
This commit is contained in:
parent
ee527cd396
commit
5d2f9014c1
@ -30,6 +30,11 @@ Dismissing the drawer returns keyboard focus to the control that opened it.
|
||||
The Agents gallery header wraps to the available width so its import and create
|
||||
actions remain visible beside the compact sidebar on narrow screens.
|
||||
|
||||
Screen readers announce the main chat button as **Send** when composing a
|
||||
message and **Stop current task** while a response is streaming, in the
|
||||
workspace language. Use the separate **Send update** button to queue or steer
|
||||
a running task when those controls are available.
|
||||
|
||||
## Search conversations and messages
|
||||
|
||||
Use **Search** in the sidebar or **⌘K / Ctrl+K** to find conversation titles and
|
||||
|
||||
@ -2161,6 +2161,13 @@ export function InputBox({
|
||||
// the stop affordance (gated above), so the send denial only applies to
|
||||
// the send state.
|
||||
const sendDenied = status !== "streaming" && !canCreateRuns;
|
||||
const submitTitle = stopDenied
|
||||
? t.inputBox.stopStreamingUnavailable
|
||||
: sendDenied
|
||||
? t.inputBox.startTurnUnavailable
|
||||
: status === "streaming"
|
||||
? t.inputBox.stopRun
|
||||
: undefined;
|
||||
const inputPolishUndoAvailable =
|
||||
!polishingInput &&
|
||||
inputPolishUndo !== null &&
|
||||
@ -3579,29 +3586,8 @@ export function InputBox({
|
||||
}
|
||||
variant="outline"
|
||||
status={status}
|
||||
{...(status === "streaming" && canSendBusyInput
|
||||
? {
|
||||
"aria-label": t.inputBox.stopRun,
|
||||
title: t.inputBox.stopRun,
|
||||
}
|
||||
: {})}
|
||||
// A bare disabled square reads as a broken composer; explain
|
||||
// the permission boundary (native title, since a Radix
|
||||
// tooltip won't fire on a disabled button). Spread
|
||||
// conditionally: an explicitly-undefined aria-label would
|
||||
// clobber PromptInputSubmit's default aria-label="Submit"
|
||||
// and strip the submit control's accessible name.
|
||||
{...(stopDenied
|
||||
? {
|
||||
"aria-label": t.inputBox.stopStreamingUnavailable,
|
||||
title: t.inputBox.stopStreamingUnavailable,
|
||||
}
|
||||
: sendDenied
|
||||
? {
|
||||
"aria-label": t.inputBox.startTurnUnavailable,
|
||||
title: t.inputBox.startTurnUnavailable,
|
||||
}
|
||||
: {})}
|
||||
aria-label={submitTitle ?? t.inputBox.send}
|
||||
title={submitTitle}
|
||||
onClick={(e) => {
|
||||
if (status === "streaming") {
|
||||
e.preventDefault();
|
||||
|
||||
@ -804,6 +804,7 @@ export const enUS: Translations = {
|
||||
},
|
||||
],
|
||||
pleaseWaitStreaming: "Please wait for the current response to finish.",
|
||||
send: "Send",
|
||||
runInputMode: "Send while working",
|
||||
queueMode: "Queue",
|
||||
steerMode: "Steer",
|
||||
|
||||
@ -654,6 +654,7 @@ export interface Translations {
|
||||
}
|
||||
)[];
|
||||
pleaseWaitStreaming: string;
|
||||
send: string;
|
||||
runInputMode: string;
|
||||
queueMode: string;
|
||||
steerMode: string;
|
||||
|
||||
@ -755,6 +755,7 @@ export const zhCN: Translations = {
|
||||
},
|
||||
],
|
||||
pleaseWaitStreaming: "请等待当前响应完成。",
|
||||
send: "发送",
|
||||
runInputMode: "运行中发送方式",
|
||||
queueMode: "排队执行",
|
||||
steerMode: "调整当前任务",
|
||||
|
||||
@ -89,7 +89,7 @@ for (const width of [1280, 390]) {
|
||||
await page
|
||||
.getByPlaceholder(/how can i assist you/i)
|
||||
.fill("Find the leave policy");
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => submitted).toBeDefined();
|
||||
expect(submitted).toMatchObject({
|
||||
assistant_id: "researcher",
|
||||
@ -116,7 +116,7 @@ for (const width of [1280, 390]) {
|
||||
await page
|
||||
.getByPlaceholder(/how can i assist you/i)
|
||||
.fill("Do not search knowledge");
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => submitted).toBeDefined();
|
||||
expect(submitted).toMatchObject({
|
||||
input: {
|
||||
|
||||
@ -129,7 +129,7 @@ test("artifact quotes retain the selected source line in the conversation", asyn
|
||||
return handleRunStream(route);
|
||||
});
|
||||
await composer.fill("Explain this figure");
|
||||
await form.getByRole("button", { name: "Submit", exact: true }).click();
|
||||
await form.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect
|
||||
.poll(() => JSON.stringify(submitted))
|
||||
.toContain(`${filepath}:L5-L5`);
|
||||
|
||||
@ -162,7 +162,7 @@ test("uploads retain successful files, cancel one file and retry only the failed
|
||||
await page
|
||||
.locator('textarea[name="message"]')
|
||||
.fill("Review these attachments");
|
||||
await prompt.getByRole("button", { name: "Submit", exact: true }).click();
|
||||
await prompt.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => attempts.length).toBe(3);
|
||||
await expect(prompt.getByRole("status")).toHaveText([
|
||||
"Uploaded",
|
||||
@ -216,7 +216,7 @@ test("uploads retain successful files, cancel one file and retry only the failed
|
||||
path: path.join(qa, "uploads-recovered-light.png"),
|
||||
animations: "disabled",
|
||||
});
|
||||
await prompt.getByRole("button", { name: "Submit", exact: true }).click();
|
||||
await prompt.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => sends).toBe(1);
|
||||
await expect(prompt.getByTitle("success.txt", { exact: true })).toHaveCount(
|
||||
0,
|
||||
|
||||
@ -81,7 +81,7 @@ test.describe("custom-agent knowledge scope", () => {
|
||||
await page
|
||||
.getByPlaceholder(/how can i assist you/i)
|
||||
.fill("Find the policy");
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => streamBody).toBeDefined();
|
||||
|
||||
expect(streamBody).toMatchObject({
|
||||
@ -170,7 +170,7 @@ test.describe("custom-agent knowledge scope", () => {
|
||||
await page
|
||||
.getByPlaceholder(/how can i assist you/i)
|
||||
.fill("Find the policy");
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect.poll(() => streamBody).toBeDefined();
|
||||
|
||||
expect(streamBody).toMatchObject({
|
||||
|
||||
@ -360,7 +360,7 @@ for (const enabledAfterRetry of [true, false]) {
|
||||
await expect(retry).toBeVisible();
|
||||
await expect(page.getByTestId("conversation-reference-chip")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Submit", exact: true }),
|
||||
page.getByRole("button", { name: "Send", exact: true }),
|
||||
).toBeDisabled();
|
||||
await input.press("End");
|
||||
await input.pressSequentially("after retry");
|
||||
@ -382,7 +382,7 @@ for (const enabledAfterRetry of [true, false]) {
|
||||
await retry.click();
|
||||
await expect(retry).toBeHidden();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Submit", exact: true }),
|
||||
page.getByRole("button", { name: "Send", exact: true }),
|
||||
).toBeEnabled();
|
||||
if (enabledAfterRetry)
|
||||
await expect(
|
||||
|
||||
@ -162,10 +162,7 @@ async function expectComposerHeightsEqual(page: Page) {
|
||||
|
||||
async function expectSidecarModelPinnedToSubmit(page: Page) {
|
||||
const metrics = await page.evaluate(() => {
|
||||
const getComposerMetrics = (
|
||||
placeholderPattern: RegExp,
|
||||
submitLabel: string,
|
||||
) => {
|
||||
const getComposerMetrics = (placeholderPattern: RegExp) => {
|
||||
const textarea = Array.from(document.querySelectorAll("textarea")).find(
|
||||
(element) =>
|
||||
placeholderPattern.test(element.getAttribute("placeholder") ?? ""),
|
||||
@ -189,7 +186,7 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
|
||||
const model = buttons.find(
|
||||
(button) => button.label === "DeepSeek V4 Pro",
|
||||
);
|
||||
const submit = buttons.find((button) => button.label === submitLabel);
|
||||
const submit = buttons.find((button) => button.label === "Send");
|
||||
|
||||
return {
|
||||
formLeft: Math.round(formBox.left),
|
||||
@ -207,8 +204,8 @@ async function expectSidecarModelPinnedToSubmit(page: Page) {
|
||||
};
|
||||
|
||||
return {
|
||||
main: getComposerMetrics(/how can i assist you/i, "Submit"),
|
||||
sidecar: getComposerMetrics(/deeper follow-up/i, "Send"),
|
||||
main: getComposerMetrics(/how can i assist you/i),
|
||||
sidecar: getComposerMetrics(/deeper follow-up/i),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ test("approval mode is independent of reasoning and is sent with the run", async
|
||||
await page
|
||||
.getByPlaceholder(/how can i assist you/i)
|
||||
.fill("Inspect the project");
|
||||
await page.getByRole("button", { name: "Submit", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
await expect
|
||||
.poll(() => body)
|
||||
.toMatchObject({ context: { tool_approval_mode: "auto" } });
|
||||
|
||||
@ -127,7 +127,7 @@ test("records beside Send, uploads real audio once, then polishes the transcript
|
||||
await expect(input).toHaveValue("Task:");
|
||||
await expect(page.getByTestId("polish-input-button")).toBeDisabled();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Submit", exact: true }),
|
||||
page.getByRole("button", { name: "Send", exact: true }),
|
||||
).toBeDisabled();
|
||||
await input.press("Enter");
|
||||
await expect(input).toHaveValue("Task: research energy storage");
|
||||
@ -143,7 +143,7 @@ test("records beside Send, uploads real audio once, then polishes the transcript
|
||||
await expect(input).toHaveValue("Task: research energy storage");
|
||||
const micBox = (await page.getByTestId("voice-input-button").boundingBox())!;
|
||||
const sendBox = (await page
|
||||
.getByRole("button", { name: "Submit", exact: true })
|
||||
.getByRole("button", { name: "Send", exact: true })
|
||||
.boundingBox())!;
|
||||
expect(micBox.x + micBox.width).toBeLessThanOrEqual(sendBox.x);
|
||||
expect(sendBox.x - micBox.x).toBeLessThan(65);
|
||||
|
||||
@ -73,7 +73,7 @@ for (const agentName of [undefined, "researcher"]) {
|
||||
await composer.press("Enter");
|
||||
await (await first).finished();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Submit", exact: true }),
|
||||
page.getByRole("button", { name: "Send", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.keyboard.press("ControlOrMeta+k");
|
||||
const dialog = page.getByRole("dialog", { name: "Search conversations" });
|
||||
|
||||
@ -1078,7 +1078,7 @@ it("keeps cancellation available while approvals lock new input", async () => {
|
||||
});
|
||||
expect(screen.getByRole<HTMLTextAreaElement>("textbox").disabled).toBe(true);
|
||||
const submit = screen.getByRole<HTMLButtonElement>("button", {
|
||||
name: "Submit",
|
||||
name: "Stop current task",
|
||||
});
|
||||
expect(submit.disabled).toBe(false);
|
||||
fireEvent.click(submit);
|
||||
|
||||
@ -295,14 +295,19 @@ describe("InputBox send gating (runs:create)", () => {
|
||||
await waitFor(() => expect(onSubmit).toHaveBeenCalledTimes(1));
|
||||
});
|
||||
|
||||
it("keeps the base Submit accessible name when send is not denied", () => {
|
||||
// Mirror of the stop-gating regression: the aria-label must be spread
|
||||
// conditionally, never explicitly-undefined, or it clobbers
|
||||
// PromptInputSubmit's default aria-label="Submit".
|
||||
renderComposer({ onSubmit: rs.fn() });
|
||||
|
||||
const submit = screen.getByRole("button", { name: "Submit" });
|
||||
expect(submit.tagName).toBe("BUTTON");
|
||||
it.each([
|
||||
["en-US", "Send"],
|
||||
["zh-CN", "发送"],
|
||||
] as const)("names the send action in %s", (locale, name) => {
|
||||
document.cookie = `locale=${locale}; path=/`;
|
||||
try {
|
||||
const { container } = renderComposer({ onSubmit: rs.fn(), locale });
|
||||
expect(screen.getByRole("button", { name })).toBe(
|
||||
getSubmitButton(container),
|
||||
);
|
||||
} finally {
|
||||
document.cookie = "locale=; max-age=0; path=/";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -160,27 +160,14 @@ describe("InputBox stop gating (runs:cancel)", () => {
|
||||
|
||||
it("keeps stop enabled for an unresolved permission list (default)", () => {
|
||||
const onStop = rs.fn();
|
||||
const { container } = renderComposer({ onStop });
|
||||
renderComposer({ onStop });
|
||||
|
||||
const submit = getSubmitButton(container);
|
||||
expect(submit.disabled).toBe(false);
|
||||
const stop = screen.getByRole<HTMLButtonElement>("button", {
|
||||
name: "Stop current task",
|
||||
});
|
||||
expect(stop.disabled).toBe(false);
|
||||
|
||||
fireEvent.click(submit);
|
||||
fireEvent.click(stop);
|
||||
expect(onStop).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("keeps the base Submit accessible name when stop is not denied", () => {
|
||||
// Regression: passing an explicitly-undefined aria-label clobbered
|
||||
// PromptInputSubmit's default aria-label="Submit" via JSX spread,
|
||||
// stripping the submit control's accessible name in every
|
||||
// non-denied state (e2e locates the button by that name). Query by
|
||||
// role + name so the assertion resolves the accessible name the
|
||||
// same way e2e and assistive tech do, not via the raw attribute.
|
||||
renderComposer({ onStop: rs.fn() });
|
||||
|
||||
// getByRole throws when no button exposes the "Submit" accessible
|
||||
// name, which is exactly the regression being guarded.
|
||||
const submit = screen.getByRole("button", { name: "Submit" });
|
||||
expect(submit.tagName).toBe("BUTTON");
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user