Skip to content

Commit

Permalink
feat: add send message button to thread input
Browse files Browse the repository at this point in the history
Introduce a dedicated ActionIcon for sending messages in the ThreadChatInput component. Remove the redundant right section in the input field and improve code organization.
  • Loading branch information
vaayne committed Sep 11, 2024
1 parent 0910aea commit 7a5380f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
28 changes: 13 additions & 15 deletions web/src/components/thread-input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ export function ThreadChatInput() {
{selectModel()}
{selectSendHotKey()}
</Group>
<ActionIcon
variant="filled"
radius="lg"
aria-label="Settings"
disabled={text === "" || sendThreadMessage.isPending}
onClick={handleSendMessage}
>
{sendThreadMessage.isPending ? (
<Icon icon="svg-spinners:180-ring" />
) : (
<Icon icon="tabler:arrow-up"></Icon>
)}
</ActionIcon>
</Group>
</Flex>
);
Expand Down Expand Up @@ -293,21 +306,6 @@ export function ThreadChatInput() {
border: "none",
},
}}
rightSection={
<ActionIcon
variant="filled"
radius="lg"
aria-label="Settings"
disabled={text === "" || sendThreadMessage.isPending}
onClick={handleSendMessage}
>
{sendThreadMessage.isPending ? (
<Icon icon="svg-spinners:180-ring" />
) : (
<Icon icon="tabler:arrow-up"></Icon>
)}
</ActionIcon>
}
value={text}
onChange={(e) => setText(e.currentTarget.value)}
inputContainer={renderAttachmentTextArea}
Expand Down
5 changes: 3 additions & 2 deletions web/src/libs/query-context.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export function QueryContextProvider({ children }) {
queryClient.invalidateQueries({
queryKey: ["list-threads", assistantId],
});
navigate(`/assistants/${assistantId}/threads/${data.id}`);
},
enabled: isLogin && !!assistantId,
});
Expand Down Expand Up @@ -184,7 +183,9 @@ export function QueryContextProvider({ children }) {
payload,
);
if (isNewThread) {
queryClient.invalidateQueries(["get-thread", newThreadId]);
navigate(`/assistants/${assistantId}/threads/${newThreadId}`, {
replace: true,
});
}
return res.data;
},
Expand Down

0 comments on commit 7a5380f

Please sign in to comment.