@@ -564,8 +564,8 @@ def save_new_language(lang_name, system_prompt):
564564 transform: translate(-50%, -50%) !important;
565565 z-index: 9999 !important;
566566 background: white !important;
567- padding: 20px !important;
568- border-radius: 10px !important;
567+ padding: 10px !important;
568+ border-radius: 8px !important;
569569 box-shadow: 0 4px 10px rgba(0,0,0,0.2) !important;
570570 max-width: 90% !important;
571571 width: 600px !important;
@@ -577,33 +577,26 @@ def save_new_language(lang_name, system_prompt):
577577 left: 0 !important;
578578 width: 100% !important;
579579 height: 100% !important;
580- background-color: rgba(0, 0, 0, 0.5 ) !important;
580+ background-color: rgba(0, 0, 0, 0.7 ) !important;
581581 z-index: 9998 !important;
582582}
583583"""
584584
585585def get_config (request : gr .Request ):
586586 """Get configuration from cookies"""
587587 config = {"feel_consent" : False }
588- if request and 'feel_consent' in request .cookies :
589- config ["feel_consent" ] = request .cookies ['feel_consent' ] == 'true'
588+
589+ if request and hasattr (request , 'cookies' ):
590+ for key in config .keys ():
591+ if key in request .cookies :
592+ config [key ] = request .cookies [key ] == 'true'
593+
590594 return config ["feel_consent" ]
591595
592596js = '''function js(){
593597 window.set_cookie = function(key, value){
594- // Use a longer expiry and more complete cookie setting
595- const d = new Date();
596- d.setTime(d.getTime() + (365*24*60*60*1000));
597- document.cookie = key + "=" + value + ";path=/;expires=" + d.toUTCString() + ";SameSite=Lax";
598- return value === 'true'; // Return boolean directly
599- }
600-
601- window.check_cookie = function(key){
602- const value = document.cookie
603- .split('; ')
604- .find(row => row.startsWith(key + '='))
605- ?.split('=')[1];
606- return value === 'true'; // Return boolean directly
598+ document.cookie = key+'='+value+'; Path=/; SameSite=Strict';
599+ return [value];
607600 }
608601}'''
609602
@@ -703,11 +696,11 @@ def get_config(request: gr.Request):
703696 submit_btn = gr .Button (value = "💾 Submit conversation" , visible = False )
704697
705698 # Overlay for the consent modal
706- with gr .Group (elem_classes = ["modal-overlay" ]) as consent_overlay :
699+ with gr .Group (elem_classes = ["modal-overlay" ], visible = False ) as consent_overlay :
707700 pass
708701
709702 # Consent popup
710- with gr .Group (elem_classes = ["consent-modal" ]) as consent_modal :
703+ with gr .Group (elem_classes = ["consent-modal" ], visible = False ) as consent_modal :
711704 gr .Markdown ("# User Agreement" )
712705 with gr .Group (elem_classes = ["user-agreement-container" ]):
713706 gr .Markdown (USER_AGREEMENT )
@@ -721,17 +714,16 @@ def initialize_consent_status():
721714 def update_visibility (has_consent ):
722715 # Show/hide components based on consent status
723716 return (
724- gr .Group (visible = has_consent ), # main_app
717+ gr .Group (visible = True ), # main_app
725718 gr .Group (visible = not has_consent ), # consent_overlay
726719 gr .Group (visible = not has_consent ) # consent_modal
727720 )
728721
729722 # Initialize app with consent checking
730- demo .load (fn = initialize_consent_status , outputs = user_consented ).then (
723+ demo .load (fn = get_config , js = js , outputs = user_consented ).then (
731724 fn = update_visibility ,
732725 inputs = user_consented ,
733- outputs = [main_app , consent_overlay , consent_modal ],
734- js = "async () => { await new Promise(r => setTimeout(r, 100)); const consented = window.check_cookie('feel_consent'); return consented; }"
726+ outputs = [main_app , consent_overlay , consent_modal ]
735727 )
736728
737729 # Function to handle consent button click
@@ -741,7 +733,7 @@ def handle_consent():
741733 consent_btn .click (
742734 fn = handle_consent ,
743735 outputs = user_consented ,
744- js = "() => { window. set_cookie('feel_consent', 'true'); return true; } "
736+ js = "(value ) => set_cookie('feel_consent', 'true')"
745737 ).then (
746738 fn = update_visibility ,
747739 inputs = user_consented ,
0 commit comments