ciaochris commited on
Commit
4f32ec2
·
1 Parent(s): 9b47eb9

Prevent HF iframe resizing from stretching HumanTouch

Browse files

Hugging Face Spaces render the Gradio app inside an auto-resized iframe, so viewport-height CSS can feed back into a very tall page. The editor and canvas now use compact fixed responsive heights, and the Humanizer textboxes use fewer Gradio rows.

Constraint: Hugging Face Spaces render the app inside an auto-resized iframe
Rejected: Only shorten the compose input | did not address vh-driven editor and canvas height
Confidence: high
Scope-risk: narrow
Directive: Do not reintroduce vh units into app CSS without verifying inside the live Space iframe
Tested: py -m unittest discover -s tests -v; py -m py_compile app.py tests\test_humantouch.py; local browser measurements at 1280x900 and 375x812
Not-tested: Groq generation behavior, unchanged

Files changed (2) hide show
  1. app.py +35 -29
  2. tests/test_humantouch.py +12 -0
app.py CHANGED
@@ -179,10 +179,10 @@ def build_custom_css() -> str:
179
  letter-spacing: 0;
180
  }
181
 
182
- #main_container {
183
- min-height: 100vh;
184
- padding: 30px 32px 22px;
185
- }
186
 
187
  #header {
188
  max-width: 1180px;
@@ -380,10 +380,12 @@ def build_custom_css() -> str:
380
  color: var(--ht-text) !important;
381
  }
382
 
383
- #humanizer_input textarea,
384
- #humanizer_output textarea {
385
- min-height: 42vh !important;
386
- }
 
 
387
 
388
  #humanize_btn,
389
  #compose_btn {
@@ -425,10 +427,11 @@ def build_custom_css() -> str:
425
  box-shadow: 0 8px 20px rgba(34, 48, 71, 0.10);
426
  }
427
 
428
- #symbiotic_canvas {
429
- height: 58vh !important;
430
- overflow: hidden;
431
- }
 
432
 
433
  #symbiotic_canvas .message,
434
  #symbiotic_canvas .user,
@@ -521,14 +524,17 @@ def build_custom_css() -> str:
521
  gap: 12px;
522
  }
523
 
524
- #humanizer_input textarea,
525
- #humanizer_output textarea {
526
- min-height: 30vh !important;
527
- }
528
-
529
- #symbiotic_canvas {
530
- height: 52vh !important;
531
- }
 
 
 
532
 
533
  #compose_btn {
534
  width: 100%;
@@ -590,15 +596,15 @@ def create_interface():
590
  with gr.Column(variant="panel", elem_classes=["workspace-panel"]):
591
  gr.Markdown("### Rewrite pasted text")
592
  with gr.Row(elem_classes=["humanizer-grid"]):
593
- input_text_humanizer = gr.Textbox(
594
- label="Source text", lines=15,
595
- placeholder="Paste a draft that sounds too polished, too generic, or too flat.",
596
- elem_id="humanizer_input", scale=1
597
- )
598
- output_text_humanizer = gr.Textbox(
599
- label="Human rewrite", lines=15,
600
- interactive=False, elem_id="humanizer_output", scale=1
601
- )
602
  with gr.Row():
603
  style_slider_h = gr.Slider(0, 100, 50, label="Style: clear to lyrical")
604
  tone_slider_h = gr.Slider(0, 100, 50, label="Tone: reserved to expressive")
 
179
  letter-spacing: 0;
180
  }
181
 
182
+ #main_container {
183
+ min-height: auto;
184
+ padding: 30px 32px 22px;
185
+ }
186
 
187
  #header {
188
  max-width: 1180px;
 
380
  color: var(--ht-text) !important;
381
  }
382
 
383
+ #humanizer_input textarea,
384
+ #humanizer_output textarea {
385
+ height: 260px !important;
386
+ min-height: 180px !important;
387
+ max-height: 320px !important;
388
+ }
389
 
390
  #humanize_btn,
391
  #compose_btn {
 
427
  box-shadow: 0 8px 20px rgba(34, 48, 71, 0.10);
428
  }
429
 
430
+ #symbiotic_canvas {
431
+ height: 280px !important;
432
+ max-height: 320px !important;
433
+ overflow: auto;
434
+ }
435
 
436
  #symbiotic_canvas .message,
437
  #symbiotic_canvas .user,
 
524
  gap: 12px;
525
  }
526
 
527
+ #humanizer_input textarea,
528
+ #humanizer_output textarea {
529
+ height: 140px !important;
530
+ min-height: 120px !important;
531
+ max-height: 180px !important;
532
+ }
533
+
534
+ #symbiotic_canvas {
535
+ height: 200px !important;
536
+ max-height: 220px !important;
537
+ }
538
 
539
  #compose_btn {
540
  width: 100%;
 
596
  with gr.Column(variant="panel", elem_classes=["workspace-panel"]):
597
  gr.Markdown("### Rewrite pasted text")
598
  with gr.Row(elem_classes=["humanizer-grid"]):
599
+ input_text_humanizer = gr.Textbox(
600
+ label="Source text", lines=9,
601
+ placeholder="Paste a draft that sounds too polished, too generic, or too flat.",
602
+ elem_id="humanizer_input", scale=1
603
+ )
604
+ output_text_humanizer = gr.Textbox(
605
+ label="Human rewrite", lines=9,
606
+ interactive=False, elem_id="humanizer_output", scale=1
607
+ )
608
  with gr.Row():
609
  style_slider_h = gr.Slider(0, 100, 50, label="Style: clear to lyrical")
610
  tone_slider_h = gr.Slider(0, 100, 50, label="Tone: reserved to expressive")
tests/test_humantouch.py CHANGED
@@ -104,11 +104,23 @@ class VisualThemeTests(unittest.TestCase):
104
  self.assertIn("@media (max-width: 768px)", css)
105
  self.assertIn("grid-template-columns: 1fr", css)
106
  self.assertIn("#humanizer_input, #humanizer_output", css)
 
107
  self.assertNotIn("clamp(", css)
108
  self.assertIn("width: 100% !important;", css)
109
  self.assertIn(".humanizer-grid > .form", css)
110
  self.assertIn("#chat_input textarea", css)
111
  self.assertIn("min-height: 52px !important;", css)
 
 
 
 
 
 
 
 
 
 
 
112
 
113
  def test_canvas_input_uses_compact_placeholder(self):
114
  source = inspect.getsource(app.create_interface)
 
104
  self.assertIn("@media (max-width: 768px)", css)
105
  self.assertIn("grid-template-columns: 1fr", css)
106
  self.assertIn("#humanizer_input, #humanizer_output", css)
107
+ self.assertNotIn("vh", css)
108
  self.assertNotIn("clamp(", css)
109
  self.assertIn("width: 100% !important;", css)
110
  self.assertIn(".humanizer-grid > .form", css)
111
  self.assertIn("#chat_input textarea", css)
112
  self.assertIn("min-height: 52px !important;", css)
113
+ self.assertIn("height: 260px !important;", css)
114
+ self.assertIn("height: 280px !important;", css)
115
+ self.assertIn("height: 140px !important;", css)
116
+ self.assertIn("height: 200px !important;", css)
117
+
118
+ def test_humanizer_textboxes_use_compact_rows(self):
119
+ source = inspect.getsource(app.create_interface)
120
+
121
+ self.assertIn("label=\"Source text\", lines=9", source)
122
+ self.assertIn("label=\"Human rewrite\", lines=9", source)
123
+ self.assertNotIn("lines=15", source)
124
 
125
  def test_canvas_input_uses_compact_placeholder(self):
126
  source = inspect.getsource(app.create_interface)