faerazo commited on
Commit
aae4f3d
·
verified ·
1 Parent(s): a94d31a

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +61 -5
ui.py CHANGED
@@ -41,6 +41,8 @@ def create_interface(agent):
41
  with gr.Blocks(
42
  title=APP_TITLE,
43
  theme=gr.themes.Soft(),
 
 
44
  css="""
45
  /* Theme tokens */
46
  .gradio-container {
@@ -55,6 +57,23 @@ def create_interface(agent):
55
  --bot-accent: #06b6d4;
56
  --bot-accent-2: #3b82f6;
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  /* App background */
60
  .gradio-container {
@@ -76,13 +95,16 @@ def create_interface(agent):
76
  .header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
77
  .header p { margin: .5rem 0 0 0; color: rgba(255,255,255,0.9); font-size: .95rem; }
78
 
79
- /* Chat container */
80
  .chat-container {
81
- height: 500px !important;
 
 
82
  background: var(--panel) !important;
83
  border-radius: 16px !important;
84
  border: 1px solid var(--border) !important;
85
  box-shadow: 0 2px 12px rgba(0,0,0,.35) !important;
 
86
  }
87
 
88
  /* Message row alignment */
@@ -348,10 +370,43 @@ def create_interface(agent):
348
  background: var(--muted);
349
  }
350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  /* Responsive */
352
  @media (max-width: 768px) {
353
  .chat-container {
354
- height: 250px !important;
 
355
  }
356
 
357
  .gradio-container [data-testid="bot"] .message > *,
@@ -388,11 +443,12 @@ def create_interface(agent):
388
  # Main Chat Tab
389
  with gr.Tab("💬 Chat with Agent"):
390
  chatbot = gr.Chatbot(
391
- height=250,
392
  show_label=False,
393
  bubble_full_width=False,
394
  type='messages',
395
- elem_classes=["chat-container"]
 
396
  )
397
 
398
  # Clear chat button
 
41
  with gr.Blocks(
42
  title=APP_TITLE,
43
  theme=gr.themes.Soft(),
44
+ # Add viewport meta tag for better mobile/iframe handling
45
+ head="""<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">""",
46
  css="""
47
  /* Theme tokens */
48
  .gradio-container {
 
57
  --bot-accent: #06b6d4;
58
  --bot-accent-2: #3b82f6;
59
  }
60
+
61
+ /* Critical HF Spaces fixes - Force proper container behavior */
62
+ .gradio-container,
63
+ .gradio-container > *,
64
+ body {
65
+ max-width: 100% !important;
66
+ width: 100% !important;
67
+ overflow-x: hidden !important;
68
+ }
69
+
70
+ /* Force iframe content to be scrollable */
71
+ #root,
72
+ .gradio-container {
73
+ position: relative !important;
74
+ min-height: 100vh !important;
75
+ max-height: none !important;
76
+ }
77
 
78
  /* App background */
79
  .gradio-container {
 
95
  .header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
96
  .header p { margin: .5rem 0 0 0; color: rgba(255,255,255,0.9); font-size: .95rem; }
97
 
98
+ /* Chat container - flexible height for HF Spaces */
99
  .chat-container {
100
+ min-height: 400px !important;
101
+ max-height: 600px !important;
102
+ height: auto !important;
103
  background: var(--panel) !important;
104
  border-radius: 16px !important;
105
  border: 1px solid var(--border) !important;
106
  box-shadow: 0 2px 12px rgba(0,0,0,.35) !important;
107
+ overflow-y: auto !important;
108
  }
109
 
110
  /* Message row alignment */
 
370
  background: var(--muted);
371
  }
372
 
373
+ /* Hugging Face Spaces specific fixes */
374
+ .gradio-container {
375
+ min-height: 100vh !important;
376
+ overflow-y: auto !important;
377
+ }
378
+
379
+ /* Fix for HF iframe container */
380
+ body, html {
381
+ height: auto !important;
382
+ min-height: 100% !important;
383
+ overflow-x: hidden !important;
384
+ overflow-y: auto !important;
385
+ }
386
+
387
+ /* Ensure proper scrolling in tabs - Critical for HF Spaces */
388
+ .gradio-container .tabitem,
389
+ .gradio-container [role="tabpanel"] {
390
+ min-height: calc(100vh - 150px) !important;
391
+ max-height: none !important;
392
+ height: auto !important;
393
+ overflow-y: visible !important;
394
+ overflow-x: hidden !important;
395
+ position: relative !important;
396
+ }
397
+
398
+ /* Make sure tab content can expand */
399
+ .gradio-container .tabs,
400
+ .gradio-container [role="tablist"] + div {
401
+ height: auto !important;
402
+ min-height: 100% !important;
403
+ }
404
+
405
  /* Responsive */
406
  @media (max-width: 768px) {
407
  .chat-container {
408
+ min-height: 300px !important;
409
+ max-height: 400px !important;
410
  }
411
 
412
  .gradio-container [data-testid="bot"] .message > *,
 
443
  # Main Chat Tab
444
  with gr.Tab("💬 Chat with Agent"):
445
  chatbot = gr.Chatbot(
446
+ height=None,
447
  show_label=False,
448
  bubble_full_width=False,
449
  type='messages',
450
+ elem_classes=["chat-container"],
451
+ container=True
452
  )
453
 
454
  # Clear chat button