Skip to content

Commit 52da3de

Browse files
committed
feat(chat): add focus functionality to chat input after sending messages
1 parent df0576a commit 52da3de

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

dashboard/src/components/chat/Chat.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ async function startNewChat() {
841841
replyTarget.value = null;
842842
newChat();
843843
closeMobileSidebar();
844+
await focusChatInput();
844845
}
845846
846847
function openCreateProjectDialog() {
@@ -975,6 +976,7 @@ async function selectSession(sessionId: string, pushRoute = true) {
975976
}
976977
scrollToBottom();
977978
closeMobileSidebar();
979+
await focusChatInput();
978980
}
979981
980982
async function sendCurrentMessage() {
@@ -1032,6 +1034,7 @@ async function sendCurrentMessage() {
10321034
console.error("Failed to send message:", error);
10331035
} finally {
10341036
sending.value = false;
1037+
await focusChatInput();
10351038
}
10361039
}
10371040
@@ -1326,6 +1329,13 @@ function scrollToBottom() {
13261329
});
13271330
}
13281331
1332+
async function focusChatInput() {
1333+
await nextTick();
1334+
window.requestAnimationFrame(() => {
1335+
inputRef.value?.focusInput();
1336+
});
1337+
}
1338+
13291339
async function stopCurrentSession() {
13301340
if (!currSessionId.value) return;
13311341
try {

dashboard/src/components/chat/StandaloneChat.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ async function sendCurrentMessage() {
317317
draft.value = "";
318318
clearStaged({ revokeUrls: false });
319319
scrollToBottom();
320+
await focusChatInput();
320321
321322
sendMessageStream({
322323
sessionId,
@@ -393,6 +394,13 @@ function scrollToBottom() {
393394
});
394395
}
395396
397+
async function focusChatInput() {
398+
await nextTick();
399+
window.requestAnimationFrame(() => {
400+
inputRef.value?.focusInput();
401+
});
402+
}
403+
396404
function messageRefs(message: ChatRecord) {
397405
const refs = messageContent(message).refs;
398406
if (refs && typeof refs === "object" && Array.isArray(refs.used)) {

0 commit comments

Comments
 (0)