diff --git a/internal/app/therapy.go b/internal/app/therapy.go index 647209c..3b8f851 100644 --- a/internal/app/therapy.go +++ b/internal/app/therapy.go @@ -63,7 +63,7 @@ func relayTherapyMessage(text string, session *Session) { //coverage:ignore // Send immediate feedback message to let user know we're processing thinkingMessageKey := getRandomThinkingMessage(session) - setOutputText(thinkingMessageKey, session) + sendMessage(thinkingMessageKey, session) // Send the actual request to the therapy endpoint reply := callTherapySessionEndpoint(text, session) diff --git a/internal/app/therapy_test.go b/internal/app/therapy_test.go index ce912d5..68ec41e 100644 --- a/internal/app/therapy_test.go +++ b/internal/app/therapy_test.go @@ -90,35 +90,13 @@ func TestRelayTherapyMessage(t *testing.T) { relayTherapyMessage("hi", session) - if len(session.Job.Output) < 2 { - t.Fatalf("expected at least two outputs (immediate feedback + response)") - } - - // First output should be a thinking message - firstOutput := session.Job.Output[0] - validThinkingKeys := []string{ - "therapy_thinking_1", - "therapy_thinking_2", - "therapy_thinking_3", - "therapy_thinking_4", - "therapy_thinking_5", - } - - found := false - for _, validKey := range validThinkingKeys { - if firstOutput.TextID == validKey { - found = true - break - } + // The thinking message is sent immediately via sendMessage, so it won't be in the output + // Only the actual therapy response should be in the output + if len(session.Job.Output) == 0 { + t.Fatalf("expected at least one output (therapy response)") } - - if !found { - t.Fatalf("expected first output to be a thinking message, got %s", firstOutput.TextID) - } - - // Second output should be the actual therapy response - if session.Job.Output[1].TextID != "Hello, I'm here for you." { - t.Fatalf("unexpected relay text: %s", session.Job.Output[1].TextID) + if session.Job.Output[0].TextID != "Hello, I'm here for you." { + t.Fatalf("unexpected relay text: %s", session.Job.Output[0].TextID) } } @@ -173,35 +151,13 @@ func TestHandleSession_ForwardDuringActive(t *testing.T) { handleSession(session) - if len(session.Job.Output) < 2 { - t.Fatalf("expected at least two outputs (immediate feedback + response), got %v", session.Job.Output) - } - - // First output should be a thinking message - firstOutput := session.Job.Output[0] - validThinkingKeys := []string{ - "therapy_thinking_1", - "therapy_thinking_2", - "therapy_thinking_3", - "therapy_thinking_4", - "therapy_thinking_5", - } - - found := false - for _, validKey := range validThinkingKeys { - if firstOutput.TextID == validKey { - found = true - break - } + // The thinking message is sent immediately via sendMessage, so it won't be in the output + // Only the actual therapy response should be in the output + if len(session.Job.Output) == 0 { + t.Fatalf("expected at least one output (therapy response)") } - - if !found { - t.Fatalf("expected first output to be a thinking message, got %s", firstOutput.TextID) - } - - // Second output should be the actual therapy response - if session.Job.Output[1].TextID != "Therapist reply" { - t.Fatalf("expected Therapist reply in second output, got %v", session.Job.Output) + if session.Job.Output[0].TextID != "Therapist reply" { + t.Fatalf("expected Therapist reply, got %v", session.Job.Output) } } @@ -239,35 +195,13 @@ func TestRelayTherapyMessage_ExistingSessionContinues(t *testing.T) { relayTherapyMessage("hi", session) - if len(session.Job.Output) < 2 { - t.Fatalf("expected at least two outputs (immediate feedback + response)") - } - - // First output should be a thinking message - firstOutput := session.Job.Output[0] - validThinkingKeys := []string{ - "therapy_thinking_1", - "therapy_thinking_2", - "therapy_thinking_3", - "therapy_thinking_4", - "therapy_thinking_5", - } - - found := false - for _, validKey := range validThinkingKeys { - if firstOutput.TextID == validKey { - found = true - break - } + // The thinking message is sent immediately via sendMessage, so it won't be in the output + // Only the actual therapy response should be in the output + if len(session.Job.Output) == 0 { + t.Fatalf("expected at least one output (therapy response)") } - - if !found { - t.Fatalf("expected first output to be a thinking message, got %s", firstOutput.TextID) - } - - // Second output should be the actual therapy response - if session.Job.Output[1].TextID != "Hello again" { - t.Fatalf("unexpected relay text: %s", session.Job.Output[1].TextID) + if session.Job.Output[0].TextID != "Hello again" { + t.Fatalf("unexpected relay text: %s", session.Job.Output[0].TextID) } } @@ -359,37 +293,16 @@ func TestRelayTherapyMessageWithImmediateFeedback(t *testing.T) { // Call relayTherapyMessage relayTherapyMessage("I'm feeling anxious about work", session) - // Check that we got at least 2 outputs: immediate feedback + actual response - if len(session.Job.Output) < 2 { - t.Fatalf("expected at least 2 outputs, got %d", len(session.Job.Output)) - } - - // Check that the first output is a thinking message - firstOutput := session.Job.Output[0] - validThinkingKeys := []string{ - "therapy_thinking_1", - "therapy_thinking_2", - "therapy_thinking_3", - "therapy_thinking_4", - "therapy_thinking_5", - } - - found := false - for _, validKey := range validThinkingKeys { - if firstOutput.TextID == validKey { - found = true - break - } - } - - if !found { - t.Fatalf("expected first output to be a thinking message, got %s", firstOutput.TextID) + // The thinking message is sent immediately via sendMessage, so it won't be in the output + // Only the actual therapy response should be in the output + if len(session.Job.Output) == 0 { + t.Fatalf("expected at least one output (therapy response)") } - // Check that the second output is the actual therapy response - secondOutput := session.Job.Output[1] - if !strings.Contains(secondOutput.TextID, "I understand your concerns") { - t.Fatalf("expected therapy response in second output TextID, got: %s", secondOutput.TextID) + // Check that the output is the actual therapy response + output := session.Job.Output[0] + if !strings.Contains(output.TextID, "I understand your concerns") { + t.Fatalf("expected therapy response in output TextID, got: %s", output.TextID) } } diff --git a/internal/translator/translations.go b/internal/translator/translations.go index e354bfa..621b582 100644 --- a/internal/translator/translations.go +++ b/internal/translator/translations.go @@ -14,7 +14,7 @@ const translationsJSON = `{ "therapy_session_ended": "Your therapy session has ended. You can start a new one anytime with /therapy.", "your_last_note": "Here’s your most recent note 👇\n\n", "no_notes": "You haven’t added any entries yet. Start by sharing your thoughts and feelings with CapyMind.", - "commands_hint": "Here are the commands you can use to interact with CapyMind 👇\n\n/start Begin using the bot\n/note Make a journal entry\n/last View your most recent entry\n/analysis Receive an analysis of your journal\n/settings Settings\n/language Set your language preference\n/timezone Set your time zone\n/feedback Give feedback \n/help Get assistance with using CapyMind\n", + "commands_hint": "Here are the commands you can use to interact with CapyMind 👇\n\n/start Begin using the bot\n/note Make a journal entry\n/last View your most recent entry\n/analysis Receive an analysis of your journal\n/therapy Start therapy session\n/settings Settings\n/language Set your language preference\n/timezone Set your time zone\n/feedback Give feedback \n/help Get assistance with using CapyMind\n", "locale_set": "Your language settings have been successfully updated 🌍", "language_select": "Select your preferred language 👇", "timezone_select": "Select your time zone 👇", @@ -107,7 +107,7 @@ const translationsJSON = `{ "therapy_session_ended": "Сесію терапії завершено. Ви можете розпочати нову командою /therapy.", "your_last_note": "Ось ваш останній запис 👇\n\n", "no_notes": "Ви ще не додали жодних записів. Почніть, поділившись своїми думками та почуттями з CapyMind.", - "commands_hint": "Ось команди, які ви можете використовувати для взаємодії з CapyMind 👇\n\n/start Почати використання бота\n/note Зробити запис у журнал\n/last Переглянути ваш останній запис\n/analysis Отримати аналіз вашого журналу\n/settings Налаштування\n/language Встановити мову\n/timezone Встановити ваш часовий пояс\n/feedback Залишити відгук\n/help Отримати допомогу з використання CapyMind\n", + "commands_hint": "Ось команди, які ви можете використовувати для взаємодії з CapyMind 👇\n\n/start Почати використання бота\n/note Зробити запис у журнал\n/last Переглянути ваш останній запис\n/analysis Отримати аналіз вашого журналу\n/therapy Розпочати сесію терапії\n/settings Налаштування\n/language Встановити мову\n/timezone Встановити ваш часовий пояс\n/feedback Залишити відгук\n/help Отримати допомогу з використання CapyMind\n", "locale_set": "Ваші налаштування мови успішно оновлено 🌍", "language_select": "Виберіть вашу мову 👇", "timezone_select": "Виберіть свій часовий пояс 👇",