Ryadg commited on
Commit
e8993e4
·
1 Parent(s): 9fbc532

fix: make status/question/feedback textboxes DOM-visible for JS observer

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -118,6 +118,18 @@ body { background: #0A0F1E !important; margin: 0 !important; }
118
  transition: opacity .4s ease, transform .4s ease !important;
119
  pointer-events: none !important;
120
  }
 
 
 
 
 
 
 
 
 
 
 
 
121
  """
122
 
123
  import pathlib
@@ -195,15 +207,19 @@ def update_ui_language(language):
195
 
196
 
197
  def load_pdf(pdf_file, language):
 
198
  s = UI[language]
199
  if pdf_file is None:
200
  return [], s["no_file"], 0, 0
201
  try:
202
  text = extract_text(pdf_file.name)
203
  chunks = chunk_text(text)
 
204
  except ValueError as e:
 
205
  return [], f"Erreur : {e}", 0, 0
206
  except Exception as e:
 
207
  return [], f"Erreur inattendue : {e}", 0, 0
208
  if not chunks:
209
  return [], s["no_chunks"], 0, 0
@@ -344,16 +360,16 @@ document.addEventListener('DOMContentLoaded', function() {
344
  language_selector = gr.Radio(["English", "Français"], value="English", label="🌐 Language", visible=False)
345
 
346
  with gr.Row():
347
- load_status = gr.Textbox(label="Status", interactive=False, scale=4, elem_id="hidden-status-output", visible=False)
348
  score_box = gr.Textbox(label="Score", value="—", interactive=False, scale=1, elem_id="score-box", visible=False)
349
 
350
  with gr.Row():
351
- question_box = gr.Textbox(label="❓ Question", interactive=False, lines=3, scale=3, elem_id="hidden-question-output", visible=False)
352
  new_q_btn = gr.Button("New Question", variant="secondary", scale=1, visible=False, elem_id="hidden-question-btn")
353
 
354
  answer_box = gr.Textbox(label="✏️ Your Answer", lines=4, placeholder="Write your answer here…", visible=False, elem_id="hidden-answer-input")
355
  submit_btn = gr.Button("Submit Answer", variant="primary", visible=False, elem_id="hidden-submit-btn")
356
- feedback_box = gr.Textbox(label="💬 Feedback", interactive=False, lines=7, elem_id="hidden-feedback-output", visible=False)
357
 
358
  # Traduction UI quand on change la langue
359
  language_selector.change(
 
118
  transition: opacity .4s ease, transform .4s ease !important;
119
  pointer-events: none !important;
120
  }
121
+
122
+ /* ── CSS-only invisible textboxes (in DOM for JS, invisible to user) ────────── */
123
+ #hidden-status-output,
124
+ #hidden-question-output,
125
+ #hidden-feedback-output {
126
+ position: absolute !important;
127
+ width: 1px !important;
128
+ height: 1px !important;
129
+ overflow: hidden !important;
130
+ opacity: 0 !important;
131
+ pointer-events: none !important;
132
+ }
133
  """
134
 
135
  import pathlib
 
207
 
208
 
209
  def load_pdf(pdf_file, language):
210
+ print(f"load_pdf called with: {pdf_file}")
211
  s = UI[language]
212
  if pdf_file is None:
213
  return [], s["no_file"], 0, 0
214
  try:
215
  text = extract_text(pdf_file.name)
216
  chunks = chunk_text(text)
217
+ print(f"Extracted chunks: {len(chunks)}")
218
  except ValueError as e:
219
+ print(f"load_pdf ValueError: {e}")
220
  return [], f"Erreur : {e}", 0, 0
221
  except Exception as e:
222
+ print(f"load_pdf Exception: {e}")
223
  return [], f"Erreur inattendue : {e}", 0, 0
224
  if not chunks:
225
  return [], s["no_chunks"], 0, 0
 
360
  language_selector = gr.Radio(["English", "Français"], value="English", label="🌐 Language", visible=False)
361
 
362
  with gr.Row():
363
+ load_status = gr.Textbox(label="Status", interactive=False, scale=4, elem_id="hidden-status-output")
364
  score_box = gr.Textbox(label="Score", value="—", interactive=False, scale=1, elem_id="score-box", visible=False)
365
 
366
  with gr.Row():
367
+ question_box = gr.Textbox(label="❓ Question", interactive=False, lines=3, scale=3, elem_id="hidden-question-output")
368
  new_q_btn = gr.Button("New Question", variant="secondary", scale=1, visible=False, elem_id="hidden-question-btn")
369
 
370
  answer_box = gr.Textbox(label="✏️ Your Answer", lines=4, placeholder="Write your answer here…", visible=False, elem_id="hidden-answer-input")
371
  submit_btn = gr.Button("Submit Answer", variant="primary", visible=False, elem_id="hidden-submit-btn")
372
+ feedback_box = gr.Textbox(label="💬 Feedback", interactive=False, lines=7, elem_id="hidden-feedback-output")
373
 
374
  # Traduction UI quand on change la langue
375
  language_selector.change(