hsaest commited on
Commit
ca4acb1
·
1 Parent(s): 3a566dc

fix mobile overflow: min-width, wrap long code, reduce padding/font

Browse files
Files changed (1) hide show
  1. app.py +63 -5
app.py CHANGED
@@ -1430,6 +1430,7 @@ footer { display: none !important; }
1430
  .layout-gap > div {
1431
  width: 100% !important;
1432
  max-width: 100% !important;
 
1433
  flex: 1 1 auto !important;
1434
  }
1435
  /* Action buttons (Run Research / Stop / Clear): three equal flex:1 columns
@@ -1452,16 +1453,47 @@ footer { display: none !important; }
1452
  .resource-grid {
1453
  grid-template-columns: 1fr !important;
1454
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1455
  }
1456
  /* Phone-specific: shrink the two big display headings so they don't dominate
1457
  the small screen. Both get the SAME size + line-height so they stay
1458
  visually consistent with each other. */
1459
  @media (max-width: 600px) {
 
 
1460
  .quest-header-title,
1461
  .hero-heading {
1462
  font-size: 0.9rem !important;
1463
  line-height: 1.2 !important;
1464
  }
 
1465
  }
1466
 
1467
  /* ===================================================================
@@ -2914,17 +2946,43 @@ function() {
2914
  applyDark(mq.matches);
2915
  mq.addEventListener('change', function(e) { applyDark(e.matches); });
2916
 
2917
- // === Auto-scroll to output panel when Run Research is clicked ===
2918
- // Use event delegation on document so it survives Gradio/Svelte re-renders.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2919
  document.addEventListener('click', function (e) {
2920
  var wrapper = document.getElementById('quest-run-btn');
2921
  if (wrapper && wrapper.contains(e.target)) {
 
2922
  setTimeout(function () {
2923
  var out = document.getElementById('quest-output');
2924
  if (out) out.scrollIntoView({ behavior: 'smooth', block: 'start' });
2925
  }, 300);
2926
  }
2927
- }, true); // capture phase so we fire before Gradio's own handler
2928
  }
2929
  """
2930
 
@@ -2949,7 +3007,7 @@ with gr.Blocks(
2949
 
2950
  # --- Main two-column layout ---
2951
  with gr.Row(elem_classes="layout-gap"):
2952
- with gr.Column(scale=6, min_width=420):
2953
  with gr.Group(elem_classes="section-card"):
2954
  gr.HTML(
2955
  '<div class="section-heading">Ask the agent</div>'
@@ -2991,7 +3049,7 @@ with gr.Blocks(
2991
  with gr.TabItem("Record"):
2992
  trace = gr.Code(label="Execution Trace (JSON)", language="json")
2993
 
2994
- with gr.Column(scale=4, min_width=340, elem_classes="right-stack"):
2995
  with gr.Group(elem_classes="section-card"):
2996
  gr.HTML(
2997
  f"""
 
1430
  .layout-gap > div {
1431
  width: 100% !important;
1432
  max-width: 100% !important;
1433
+ min-width: 0 !important; /* override Gradio's inline min-width:420px */
1434
  flex: 1 1 auto !important;
1435
  }
1436
  /* Action buttons (Run Research / Stop / Clear): three equal flex:1 columns
 
1453
  .resource-grid {
1454
  grid-template-columns: 1fr !important;
1455
  }
1456
+ /* Cards: reduce padding and clip overflow so nothing bleeds outside */
1457
+ .section-card {
1458
+ padding: 14px !important;
1459
+ overflow: hidden !important;
1460
+ }
1461
+ /* Force all text (including monospace search queries) to wrap */
1462
+ [class*="gradio-container"] .prose,
1463
+ [class*="gradio-container"] .markdown,
1464
+ [class*="gradio-container"] .gr-markdown,
1465
+ [class*="gradio-container"] [data-testid="markdown"] {
1466
+ overflow-wrap: anywhere !important;
1467
+ word-break: break-word !important;
1468
+ overflow: hidden !important;
1469
+ }
1470
+ /* Inline code (search query highlights) must wrap, not push layout */
1471
+ [class*="gradio-container"] .prose code,
1472
+ [class*="gradio-container"] .markdown code,
1473
+ [class*="gradio-container"] .gr-markdown code {
1474
+ white-space: pre-wrap !important;
1475
+ word-break: break-all !important;
1476
+ overflow-wrap: anywhere !important;
1477
+ }
1478
+ /* Code blocks (Record tab) scroll horizontally rather than overflowing */
1479
+ [class*="gradio-container"] .prose pre,
1480
+ [class*="gradio-container"] .markdown pre {
1481
+ overflow-x: auto !important;
1482
+ white-space: pre !important;
1483
+ }
1484
  }
1485
  /* Phone-specific: shrink the two big display headings so they don't dominate
1486
  the small screen. Both get the SAME size + line-height so they stay
1487
  visually consistent with each other. */
1488
  @media (max-width: 600px) {
1489
+ html, body { font-size: 15px !important; }
1490
+ [class*="gradio-container"] { padding: 12px !important; min-width: 0 !important; }
1491
  .quest-header-title,
1492
  .hero-heading {
1493
  font-size: 0.9rem !important;
1494
  line-height: 1.2 !important;
1495
  }
1496
+ .quest-header { gap: 12px !important; padding: 14px 16px !important; }
1497
  }
1498
 
1499
  /* ===================================================================
 
2946
  applyDark(mq.matches);
2947
  mq.addEventListener('change', function(e) { applyDark(e.matches); });
2948
 
2949
+ // === Streaming auto-scroll ===
2950
+ // When output content changes (new lines stream in), keep the bottom of
2951
+ // the output panel in view — but only if the user has NOT scrolled up
2952
+ // manually (so reading is never interrupted).
2953
+ var userScrolledUp = false;
2954
+
2955
+ window.addEventListener('scroll', function () {
2956
+ var distFromBottom = document.documentElement.scrollHeight
2957
+ - window.scrollY - window.innerHeight;
2958
+ userScrolledUp = distFromBottom > 250;
2959
+ }, { passive: true });
2960
+
2961
+ function scrollToOutputBottom() {
2962
+ if (userScrolledUp) return;
2963
+ var out = document.getElementById('quest-output');
2964
+ if (out) out.scrollIntoView({ behavior: 'smooth', block: 'end' });
2965
+ }
2966
+
2967
+ function watchOutput() {
2968
+ var out = document.getElementById('quest-output');
2969
+ if (!out) { setTimeout(watchOutput, 600); return; }
2970
+ var observer = new MutationObserver(scrollToOutputBottom);
2971
+ observer.observe(out, { childList: true, subtree: true });
2972
+ }
2973
+ watchOutput();
2974
+
2975
+ // === Scroll to top of output & reset scroll-lock when Run is clicked ===
2976
  document.addEventListener('click', function (e) {
2977
  var wrapper = document.getElementById('quest-run-btn');
2978
  if (wrapper && wrapper.contains(e.target)) {
2979
+ userScrolledUp = false; // re-enable auto-scroll for new run
2980
  setTimeout(function () {
2981
  var out = document.getElementById('quest-output');
2982
  if (out) out.scrollIntoView({ behavior: 'smooth', block: 'start' });
2983
  }, 300);
2984
  }
2985
+ }, true);
2986
  }
2987
  """
2988
 
 
3007
 
3008
  # --- Main two-column layout ---
3009
  with gr.Row(elem_classes="layout-gap"):
3010
+ with gr.Column(scale=6, min_width=280):
3011
  with gr.Group(elem_classes="section-card"):
3012
  gr.HTML(
3013
  '<div class="section-heading">Ask the agent</div>'
 
3049
  with gr.TabItem("Record"):
3050
  trace = gr.Code(label="Execution Trace (JSON)", language="json")
3051
 
3052
+ with gr.Column(scale=4, min_width=260, elem_classes="right-stack"):
3053
  with gr.Group(elem_classes="section-card"):
3054
  gr.HTML(
3055
  f"""