Focus on send textarea on opening temp chat

2b93fd37e34abcc3955d91890a6c6f2c6663511e

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +10 -3Showing whitespace changes
public/scripts/welcome-screen.js+10 -3
@@ -30,6 +30,9 @@ import { sortMoments, timestampToMoment } from './utils.js';
3030const assistantAvatarKey = 'assistant';
3131const defaultAssistantAvatar = 'default_Assistant.png';
3232
33+const DEFAULT_DISPLAYED = 5;
34+const MAX_DISPLAYED = 20;
35+
3336export function getPermanentAssistantAvatar() {
3437 const assistantAvatar = accountStorage.getItem(assistantAvatarKey);
3538 if (assistantAvatar === null) {
@@ -78,6 +81,7 @@ function sendAssistantMessage() {
7881async function sendWelcomePanel() {
7982 try {
8083 const chatElement = document.getElementById('chat');
84+ const sendTextArea = document.getElementById('send_textarea');
8185 if (!chatElement) {
8286 console.error('Chat element not found');
8387 return;
@@ -134,8 +138,11 @@ async function sendWelcomePanel() {
134138 });
135139 });
136140 fragment.querySelectorAll('button.openTemporaryChat').forEach((button) => {
137141 button.addEventListener('click', async () => {
138142 voidawait newAssistantChat({ temporary: true });
143+ if (sendTextArea instanceof HTMLTextAreaElement) {
144+ sendTextArea.focus();
145+ }
139146 });
140147 });
141148 fragment.querySelectorAll('.recentChat.group').forEach((groupChat) => {
@@ -259,8 +266,8 @@ async function getRecentChats() {
259266 data.sort((a, b) => sortMoments(timestampToMoment(a.last_mes), timestampToMoment(b.last_mes)))
260267 .map(chat => ({ chat, character: characters.find(x => x.avatar === chat.avatar), group: groups.find(x => x.id === chat.group) }))
261268 .filter(t => t.character || t.group)
269+ .slice(0, MAX_DISPLAYED)
262270 .forEach(({ chat, character, group }, index) => {
263- const DEFAULT_DISPLAYED = 5;
264271 const chatTimestamp = timestampToMoment(chat.last_mes);
265272 chat.char_name = character?.name || group?.name || '';
266273 chat.date_short = chatTimestamp.format('l');