From 4955a5cc1b90fefd293b969f2b5ae8f89be95b73 Mon Sep 17 00:00:00 2001 From: Deenu Bansal Date: Thu, 31 Jul 2025 23:40:09 +0530 Subject: [PATCH 1/2] Add keyboard navigation for mood slider with ARIA attributes --- TalkHeal.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/TalkHeal.py b/TalkHeal.py index ca0d692..234c356 100644 --- a/TalkHeal.py +++ b/TalkHeal.py @@ -75,7 +75,6 @@ def show_signup_ui(): from components.emergency_page import render_emergency_page from components.profile import apply_global_font_size - # --- 1. INITIALIZE SESSION STATE --- if "chat_history" not in st.session_state: st.session_state.chat_history = [] @@ -100,7 +99,6 @@ def show_signup_ui(): # --- 2. SET PAGE CONFIG --- apply_global_font_size() - # --- 3. APPLY STYLES & CONFIGURATIONS --- apply_custom_css() model = configure_gemini() @@ -156,6 +154,76 @@ def get_tone_prompt():

🗣️ Current Chatbot Tone: {st.session_state['selected_tone']}

""", unsafe_allow_html=True) + + # --- Mood Slider with Keyboard Navigation --- + def mood_slider(): + slider_html = """ +
+ + +
Neutral
+ + +
+ """ + mood_value = st.components.v1.html(slider_html, height=100, key="mood_slider") + return mood_value + + st.subheader("😊 Track Your Mood") + mood = mood_slider() + if mood: + st.write(f"Selected mood: {['Very Sad', 'Sad', 'Neutral', 'Happy', 'Very Happy'][mood - 1]}") + # AI-assisted coping tips based on mood + coping_tips = { + 1: "It’s okay to feel this way. Try some deep breathing exercises to find calm.", + 2: "Consider writing down your thoughts in the journal to process your feelings.", + 3: "A short walk or some light stretching might help you feel balanced.", + 4: "Great to hear you’re feeling happy! Share something positive in your journal.", + 5: "You’re shining today! Keep spreading that positivity with a kind act." + } + st.write(f"Coping tip: {coping_tips.get(mood, 'Let’s explore how you’re feeling.')}") + render_chat_interface() handle_chat_input(model, system_prompt=get_tone_prompt()) @@ -170,4 +238,4 @@ def get_tone_prompt(): } setTimeout(scrollToBottom, 100); -""", unsafe_allow_html=True) \ No newline at end of file +""", unsafe_allow_html=True) \ No newline at end of file From 2a4080b59bd9e0e3a8acf7452a083027baf96b0f Mon Sep 17 00:00:00 2001 From: Deenu Bansal Date: Sat, 2 Aug 2025 14:30:45 +0530 Subject: [PATCH 2/2] Resolved merge conflict in TalkHeal.py --- TalkHeal.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/TalkHeal.py b/TalkHeal.py index df278d4..cc28d6e 100644 --- a/TalkHeal.py +++ b/TalkHeal.py @@ -187,22 +187,25 @@ def mood_slider(): """ - mood_value = st.components.v1.html(slider_html, height=100, key="mood_slider") + mood_value = st.components.v1.html(slider_html, height=100) return mood_value + # --- Mood Slider --- st.subheader("😊 Track Your Mood") - mood = mood_slider() - if mood: - st.write(f"Selected mood: {['Very Sad', 'Sad', 'Neutral', 'Happy', 'Very Happy'][mood - 1]}") - # AI-assisted coping tips based on mood - coping_tips = { - 1: "It’s okay to feel this way. Try some deep breathing exercises to find calm.", - 2: "Consider writing down your thoughts in the journal to process your feelings.", - 3: "A short walk or some light stretching might help you feel balanced.", - 4: "Great to hear you’re feeling happy! Share something positive in your journal.", - 5: "You’re shining today! Keep spreading that positivity with a kind act." - } - st.write(f"Coping tip: {coping_tips.get(mood, 'Let’s explore how you’re feeling.')}") + mood_options = ['Very Sad', 'Sad', 'Neutral', 'Happy', 'Very Happy'] + mood = st.slider( + 'Select your mood', + min_value=1, max_value=5, value=3, step=1 +) + coping_tips = { + 1: "It’s okay to feel this way. Try some deep breathing exercises to find calm.", + 2: "Consider writing down your thoughts in the journal to process your feelings.", + 3: "A short walk or some light stretching might help you feel balanced.", + 4: "Great to hear you’re feeling happy! Share something positive in your journal.", + 5: "You’re shining today! Keep spreading that positivity with a kind act." +} + st.write(f"Selected mood: {mood_options[mood-1]}") + st.write(f"Coping tip: {coping_tips.get(mood, 'Let’s explore how you’re feeling.')}") render_chat_interface() handle_chat_input(model, system_prompt=get_tone_prompt())