From e4f5c0a1971e07a367e77616df963e481541db05 Mon Sep 17 00:00:00 2001 From: KiriAky 107 Date: Fri, 4 Sep 2026 08:30:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E9=98=BB=E6=AD=A2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8D=B8=E8=BD=BD=E5=90=8E=E7=9A=84=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/features/chat/ChatView.spec.ts | 23 +++++++++++++++++++++ frontend/src/features/chat/ChatView.vue | 9 +++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/frontend/src/features/chat/ChatView.spec.ts b/frontend/src/features/chat/ChatView.spec.ts index 46c73d2..fe1d731 100644 --- a/frontend/src/features/chat/ChatView.spec.ts +++ b/frontend/src/features/chat/ChatView.spec.ts @@ -64,3 +64,26 @@ it('preserves the selection when provider discovery fails', async () => { expect(wrapper.get('.error-banner').text()).toBe('offline') wrapper.unmount() }) + +it.each(['providers', 'skills'])('ignores initialization after unmount while %s are loading', async source => { + const chat = useChatStore() + let finish!: () => void + const pending = new Promise(resolve => { finish = resolve }) + if (source === 'providers') vi.mocked(useProviderStore().loadProviders).mockReturnValueOnce(pending) + else vi.mocked(useSkillStore().loadSkills).mockReturnValueOnce(pending) + const first = mount(ChatView) + first.unmount() + finish() + await flushPromises() + expect(chat.selectedProviderId).toBe('') + expect(chat.selectedModel).toBe('') + expect(useProviderStore().loadModels).not.toHaveBeenCalled() + + const returned = mount(ChatView) + await flushPromises() + expect(chat.selectedProviderId).toBe('a') + expect(chat.selectedModel).toBe('a-default') + await returned.get('textarea').setValue('hello') + expect(returned.get('button.button-primary').attributes('disabled')).toBeUndefined() + returned.unmount() +}) diff --git a/frontend/src/features/chat/ChatView.vue b/frontend/src/features/chat/ChatView.vue index 51ad5d0..7cd0525 100644 --- a/frontend/src/features/chat/ChatView.vue +++ b/frontend/src/features/chat/ChatView.vue @@ -1,5 +1,5 @@