fix(webui): clarify new chat command text
This commit is contained in:
@@ -58,7 +58,7 @@ BUILTIN_COMMAND_SPECS: tuple[BuiltinCommandSpec, ...] = (
|
||||
BuiltinCommandSpec(
|
||||
"/new",
|
||||
"New chat",
|
||||
"Stop the current task and start a fresh conversation.",
|
||||
"Reset this chat and start a fresh conversation.",
|
||||
"square-pen",
|
||||
lifecycle="finalize_active_turn",
|
||||
),
|
||||
|
||||
@@ -975,12 +975,13 @@ export function ThreadComposer({
|
||||
}, [cursorPosition, disabled, slashMenuDismissed, value]);
|
||||
|
||||
const visibleSlashCommands = useMemo(() => {
|
||||
const baseCommands = slashCommands.filter(
|
||||
(command) => command.command !== "/stop" && command.command !== "/restart",
|
||||
);
|
||||
if (!(isStreaming && onStop)) return baseCommands;
|
||||
if (!(isStreaming && onStop)) return slashCommands;
|
||||
const stopCommand = slashCommands.find((command) => command.command === "/stop");
|
||||
return stopCommand ? [stopCommand, ...baseCommands] : baseCommands;
|
||||
if (!stopCommand) return slashCommands;
|
||||
return [
|
||||
stopCommand,
|
||||
...slashCommands.filter((command) => command.command !== "/stop"),
|
||||
];
|
||||
}, [isStreaming, onStop, slashCommands]);
|
||||
|
||||
const filteredSlashCommands = useMemo<SlashPaletteCommand[]>(() => {
|
||||
@@ -1012,6 +1013,15 @@ export function ThreadComposer({
|
||||
if (slashQuery === null) return [];
|
||||
const withDetails = visibleSlashCommands
|
||||
.filter((command) => {
|
||||
if (
|
||||
slashQuery === ""
|
||||
&& (
|
||||
command.command === "/restart"
|
||||
|| (command.command === "/stop" && !(isStreaming && onStop))
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const commandKey = slashCommandI18nKey(command.command);
|
||||
const title = t(`thread.composer.slash.commands.${commandKey}.title`, {
|
||||
defaultValue: command.title,
|
||||
|
||||
@@ -905,7 +905,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "New chat",
|
||||
"description": "Stop the current task and start a fresh conversation."
|
||||
"description": "Reset this chat and start a fresh conversation."
|
||||
},
|
||||
"stop": {
|
||||
"title": "Stop current task",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "Nuevo chat",
|
||||
"description": "Detiene la tarea actual e inicia una conversación nueva."
|
||||
"description": "Restablece este chat e inicia una conversación nueva."
|
||||
},
|
||||
"stop": {
|
||||
"title": "Detener tarea actual",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "Nouvelle discussion",
|
||||
"description": "Arrêter la tâche en cours et démarrer une nouvelle conversation."
|
||||
"description": "Réinitialiser cette discussion et démarrer une nouvelle conversation."
|
||||
},
|
||||
"stop": {
|
||||
"title": "Arrêter la tâche en cours",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "Obrolan baru",
|
||||
"description": "Hentikan tugas saat ini dan mulai percakapan baru."
|
||||
"description": "Reset chat ini dan mulai percakapan baru."
|
||||
},
|
||||
"stop": {
|
||||
"title": "Hentikan tugas saat ini",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "新しいチャット",
|
||||
"description": "現在のタスクを停止して、新しい会話を開始します。"
|
||||
"description": "このチャットをリセットして、新しい会話を開始します。"
|
||||
},
|
||||
"stop": {
|
||||
"title": "現在のタスクを停止",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "새 채팅",
|
||||
"description": "현재 작업을 중지하고 새 대화를 시작합니다."
|
||||
"description": "이 채팅을 초기화하고 새 대화를 시작합니다."
|
||||
},
|
||||
"stop": {
|
||||
"title": "현재 작업 중지",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "Cuộc trò chuyện mới",
|
||||
"description": "Dừng tác vụ hiện tại và bắt đầu một cuộc trò chuyện mới."
|
||||
"description": "Đặt lại cuộc trò chuyện này và bắt đầu một cuộc trò chuyện mới."
|
||||
},
|
||||
"stop": {
|
||||
"title": "Dừng tác vụ hiện tại",
|
||||
|
||||
@@ -904,7 +904,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "新建对话",
|
||||
"description": "停止当前任务,并开始一个新的对话。"
|
||||
"description": "重置当前对话,并开始一个新的对话。"
|
||||
},
|
||||
"stop": {
|
||||
"title": "停止当前任务",
|
||||
|
||||
@@ -895,7 +895,7 @@
|
||||
"commands": {
|
||||
"new": {
|
||||
"title": "新增對話",
|
||||
"description": "停止目前任務,並開始新的對話。"
|
||||
"description": "重置目前對話,並開始新的對話。"
|
||||
},
|
||||
"stop": {
|
||||
"title": "停止目前任務",
|
||||
|
||||
@@ -854,6 +854,29 @@ describe("ThreadComposer", () => {
|
||||
expect(screen.queryByRole("listbox", { name: "Slash commands" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("offers stop autocomplete once the user starts typing it", () => {
|
||||
const onSend = vi.fn();
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={onSend}
|
||||
placeholder="Type your message..."
|
||||
slashCommands={COMMANDS}
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "/sto" } });
|
||||
|
||||
expect(screen.getByRole("option", { name: /\/stop/i })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
|
||||
expect(input).toHaveValue("/stop");
|
||||
expect(onSend).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("renders slash commands as direct actions with current status", () => {
|
||||
render(
|
||||
<ThreadComposer
|
||||
@@ -1363,7 +1386,7 @@ describe("ThreadComposer", () => {
|
||||
{
|
||||
command: "/new",
|
||||
title: "New chat",
|
||||
description: "Stop the current task and start a fresh conversation.",
|
||||
description: "Reset this chat and start a fresh conversation.",
|
||||
icon: "square-pen",
|
||||
lifecycle: "finalize_active_turn",
|
||||
acceptsArgs: false,
|
||||
@@ -1393,7 +1416,7 @@ describe("ThreadComposer", () => {
|
||||
{
|
||||
command: "/new",
|
||||
title: "New chat",
|
||||
description: "Stop the current task and start a fresh conversation.",
|
||||
description: "Reset this chat and start a fresh conversation.",
|
||||
icon: "square-pen",
|
||||
lifecycle: "finalize_active_turn",
|
||||
acceptsArgs: false,
|
||||
|
||||
Reference in New Issue
Block a user