diff --git a/src/InterviewAssistant.AppHost/InterviewAssistant.AppHost.csproj b/src/InterviewAssistant.AppHost/InterviewAssistant.AppHost.csproj index af47e8b..fb6d720 100644 --- a/src/InterviewAssistant.AppHost/InterviewAssistant.AppHost.csproj +++ b/src/InterviewAssistant.AppHost/InterviewAssistant.AppHost.csproj @@ -1,6 +1,6 @@ - + Exe diff --git a/src/InterviewAssistant.Web/Components/Pages/Home.razor b/src/InterviewAssistant.Web/Components/Pages/Home.razor index 3f6b540..bc8e139 100644 --- a/src/InterviewAssistant.Web/Components/Pages/Home.razor +++ b/src/InterviewAssistant.Web/Components/Pages/Home.razor @@ -160,7 +160,7 @@ StateHasChanged(); var assistantMessage = new ChatMessage - { + { Role = MessageRoleType.Assistant, Message = string.Empty }; @@ -207,7 +207,8 @@ // 키 입력 처리 (엔터키로 메시지 전송) private async Task HandleKeyDown(KeyboardEventArgs e) { - if (e.Repeat || isSend) return; + var isSendJs = await JSRuntime.InvokeAsync("isMessageSendInProgress"); + if (e.Repeat || isSend || isSendJs) return; isSend = true; @@ -273,7 +274,7 @@ bool first = true; await foreach (var response in responses) - { + { if (first) { isLoading = false; diff --git a/src/InterviewAssistant.Web/wwwroot/js/chatFunctions.js b/src/InterviewAssistant.Web/wwwroot/js/chatFunctions.js index 653c880..c44d6fe 100644 --- a/src/InterviewAssistant.Web/wwwroot/js/chatFunctions.js +++ b/src/InterviewAssistant.Web/wwwroot/js/chatFunctions.js @@ -102,4 +102,8 @@ window.resetTextAreaHeight = function (elementId) { textarea.style.height = ""; textarea.style.overflowY = "hidden"; } +}; + +window.isMessageSendInProgress = function () { + return window.isSend || false; }; \ No newline at end of file diff --git a/test/InterviewAssistant.AppHost.Tests/Components/Pages/HomeTests.cs b/test/InterviewAssistant.AppHost.Tests/Components/Pages/HomeTests.cs index fcc799c..09493de 100644 --- a/test/InterviewAssistant.AppHost.Tests/Components/Pages/HomeTests.cs +++ b/test/InterviewAssistant.AppHost.Tests/Components/Pages/HomeTests.cs @@ -363,6 +363,18 @@ public async Task Home_HandleKeyDown_PreventsDuplicateWithIsSendFlag() Timeout = 5000 }); + // 초기 AI 응답 및 UI 준비 대기 + await Page.WaitForSelectorAsync(".welcome-message", new PageWaitForSelectorOptions + { + State = WaitForSelectorState.Detached, + Timeout = 15000 + }); + await Page.WaitForSelectorAsync(".response-status", new PageWaitForSelectorOptions + { + State = WaitForSelectorState.Detached, + Timeout = 40000 + }); + var textarea = Page.Locator("textarea#messageInput"); // 초기 메시지 개수 확인