From fc6e14efe28e0c40f6453c0e5d9943377ccbfacd Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Mon, 5 May 2025 15:23:38 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Enhance=20form=20submission?= =?UTF-8?q?=20for=20touch=20screens=20(#7198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ feat: Enhance form submission for touch screens * chore: add comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: add comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: linting in AnthropicClient * chore: Add anthropic model outputs for Claude 3.7 * refactor: Simplify touch-screen detection in message submission * fix: Correct button rendering order for chat collapse/expand icons * Revert "refactor: Simplify touch-screen detection in message submission" This reverts commit 8638442a4ce64f4f89e6430e09893cf1736de3d1. * refactor: Improve touchscreen detection for focus handling in ChatForm and useFocusChatEffect * chore: EditMessage linting * refactor: Reorder dropdown items in ExportAndShareMenu --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Danny Avila --- api/app/clients/AnthropicClient.js | 16 +++++++-------- api/utils/tokens.js | 3 +++ .../components/Chat/ExportAndShareMenu.tsx | 20 +++++++++---------- client/src/components/Chat/Input/ChatForm.tsx | 5 +++++ .../components/Chat/Input/CollapseChat.tsx | 4 ++-- .../Chat/Messages/Content/EditMessage.tsx | 6 +++--- client/src/hooks/Chat/useFocusChatEffect.ts | 5 ++++- 7 files changed, 35 insertions(+), 24 deletions(-) diff --git a/api/app/clients/AnthropicClient.js b/api/app/clients/AnthropicClient.js index 60b9c64d1e..91939975c4 100644 --- a/api/app/clients/AnthropicClient.js +++ b/api/app/clients/AnthropicClient.js @@ -396,13 +396,13 @@ class AnthropicClient extends BaseClient { const formattedMessages = orderedMessages.map((message, i) => { const formattedMessage = this.useMessages ? formatMessage({ - message, - endpoint: EModelEndpoint.anthropic, - }) + message, + endpoint: EModelEndpoint.anthropic, + }) : { - author: message.isCreatedByUser ? this.userLabel : this.assistantLabel, - content: message?.content ?? message.text, - }; + author: message.isCreatedByUser ? this.userLabel : this.assistantLabel, + content: message?.content ?? message.text, + }; const needsTokenCount = this.contextStrategy && !orderedMessages[i].tokenCount; /* If tokens were never counted, or, is a Vision request and the message has files, count again */ @@ -680,7 +680,7 @@ class AnthropicClient extends BaseClient { } getCompletion() { - logger.debug('AnthropicClient doesn\'t use getCompletion (all handled in sendCompletion)'); + logger.debug("AnthropicClient doesn't use getCompletion (all handled in sendCompletion)"); } /** @@ -888,7 +888,7 @@ class AnthropicClient extends BaseClient { } getBuildMessagesOptions() { - logger.debug('AnthropicClient doesn\'t use getBuildMessagesOptions'); + logger.debug("AnthropicClient doesn't use getBuildMessagesOptions"); } getEncoding() { diff --git a/api/utils/tokens.js b/api/utils/tokens.js index 8bf134fa4c..e2c311692e 100644 --- a/api/utils/tokens.js +++ b/api/utils/tokens.js @@ -239,12 +239,15 @@ const modelMaxOutputs = { system_default: 1024, }; +/** Outputs from https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-names */ const anthropicMaxOutputs = { 'claude-3-haiku': 4096, 'claude-3-sonnet': 4096, 'claude-3-opus': 4096, 'claude-3.5-sonnet': 8192, 'claude-3-5-sonnet': 8192, + 'claude-3.7-sonnet': 128000, + 'claude-3-7-sonnet': 128000, }; const maxOutputTokensMap = { diff --git a/client/src/components/Chat/ExportAndShareMenu.tsx b/client/src/components/Chat/ExportAndShareMenu.tsx index 7f37ebbc72..4d67967cc1 100644 --- a/client/src/components/Chat/ExportAndShareMenu.tsx +++ b/client/src/components/Chat/ExportAndShareMenu.tsx @@ -44,15 +44,6 @@ export default function ExportAndShareMenu({ }; const dropdownItems: t.MenuItemProps[] = [ - { - label: localize('com_endpoint_export'), - onClick: exportHandler, - icon: , - /** NOTE: THE FOLLOWING PROPS ARE REQUIRED FOR MENU ITEMS THAT OPEN DIALOGS */ - hideOnClick: false, - ref: exportButtonRef, - render: (props) => } diff --git a/client/src/components/Chat/Messages/Content/EditMessage.tsx b/client/src/components/Chat/Messages/Content/EditMessage.tsx index 4abd891360..200cf7d402 100644 --- a/client/src/components/Chat/Messages/Content/EditMessage.tsx +++ b/client/src/components/Chat/Messages/Content/EditMessage.tsx @@ -113,9 +113,9 @@ const EditMessage = ({ messages.map((msg) => msg.messageId === messageId ? { - ...msg, - text: data.text, - } + ...msg, + text: data.text, + } : msg, ), ); diff --git a/client/src/hooks/Chat/useFocusChatEffect.ts b/client/src/hooks/Chat/useFocusChatEffect.ts index 3a22533b75..f3ede51613 100644 --- a/client/src/hooks/Chat/useFocusChatEffect.ts +++ b/client/src/hooks/Chat/useFocusChatEffect.ts @@ -11,7 +11,10 @@ export default function useFocusChatEffect(textAreaRef: React.RefObject