From 4461b17f0a2b8a0c42e3ef97f074443aa7c8e13f Mon Sep 17 00:00:00 2001 From: Takuya MATSUNAGA Date: Thu, 19 Dec 2024 20:49:44 +0900 Subject: [PATCH] fix(ChatSessions.vue): improve session initialization logic (#130) - Refactored `currentSessionId` watcher to be asynchronous for better handling of session updates. - Enhanced `mounted` lifecycle hook to check if there are any existing sessions and create a new session if none exist. --- src/components/ChatSessions.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ChatSessions.vue b/src/components/ChatSessions.vue index ddbbe72..7732493 100644 --- a/src/components/ChatSessions.vue +++ b/src/components/ChatSessions.vue @@ -37,12 +37,15 @@ export default defineComponent({ }; }, watch: { - currentSessionId(newVal: SessionId, _: SessionId) { + async currentSessionId(newVal: SessionId, _: SessionId) { this.localCurrentSessionId = newVal; }, }, async mounted() { await this.fetchSessionIdList(); + if (this.localCurrentSessionId == null && this.sessionIdList.length == 0) { + await this.createNewSession(); + } }, methods: { selectSession(sessionId: SessionId) {