Nuclear fix: pin input every 100ms via embedded HTML script + crush wrap min-height 100%
Browse files- app.py +50 -0
- static/app.css +13 -0
app.py
CHANGED
|
@@ -417,6 +417,56 @@ def build_app() -> gr.Blocks:
|
|
| 417 |
min_width=88,
|
| 418 |
)
|
| 419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
inputs = [msg, chatbot, temperature, max_tokens, thinking, lang_state]
|
| 421 |
outputs = [chatbot, msg]
|
| 422 |
|
|
|
|
| 417 |
min_width=88,
|
| 418 |
)
|
| 419 |
|
| 420 |
+
# Always-on pin script (Gradio js= is unreliable on Spaces iframe)
|
| 421 |
+
gr.HTML(
|
| 422 |
+
"""
|
| 423 |
+
<script>
|
| 424 |
+
(function(){
|
| 425 |
+
if (window.__nyraPinInstalled) return;
|
| 426 |
+
window.__nyraPinInstalled = true;
|
| 427 |
+
window.iFrameResizer = { autoResize: false, sizeWidth: false };
|
| 428 |
+
function pin(){
|
| 429 |
+
var list = document.querySelectorAll('#nyra-input textarea, textarea[data-testid="textbox"]');
|
| 430 |
+
for (var i=0;i<list.length;i++){
|
| 431 |
+
var el = list[i];
|
| 432 |
+
el.setAttribute('rows','1');
|
| 433 |
+
el.style.setProperty('height','40px','important');
|
| 434 |
+
el.style.setProperty('min-height','40px','important');
|
| 435 |
+
el.style.setProperty('max-height','40px','important');
|
| 436 |
+
el.style.setProperty('resize','none','important');
|
| 437 |
+
el.style.setProperty('overflow','hidden','important');
|
| 438 |
+
el.style.setProperty('line-height','40px','important');
|
| 439 |
+
el.oninput = function(e){
|
| 440 |
+
e.target.style.setProperty('height','40px','important');
|
| 441 |
+
};
|
| 442 |
+
}
|
| 443 |
+
var row = document.getElementById('nyra-input-row');
|
| 444 |
+
if(row){
|
| 445 |
+
row.style.setProperty('height','56px','important');
|
| 446 |
+
row.style.setProperty('max-height','56px','important');
|
| 447 |
+
row.style.setProperty('min-height','56px','important');
|
| 448 |
+
row.style.setProperty('overflow','hidden','important');
|
| 449 |
+
}
|
| 450 |
+
var nodes = document.querySelectorAll('.gradio-container, main, .wrap, .contain, .fillable');
|
| 451 |
+
for (var j=0;j<nodes.length;j++){
|
| 452 |
+
nodes[j].style.setProperty('min-height','0','important');
|
| 453 |
+
nodes[j].style.setProperty('height','auto','important');
|
| 454 |
+
nodes[j].style.setProperty('flex-grow','0','important');
|
| 455 |
+
}
|
| 456 |
+
document.documentElement.style.setProperty('height','auto','important');
|
| 457 |
+
document.body.style.setProperty('height','auto','important');
|
| 458 |
+
document.body.style.setProperty('min-height','0','important');
|
| 459 |
+
}
|
| 460 |
+
setInterval(pin, 100);
|
| 461 |
+
document.addEventListener('DOMContentLoaded', pin);
|
| 462 |
+
window.addEventListener('load', pin);
|
| 463 |
+
pin();
|
| 464 |
+
})();
|
| 465 |
+
</script>
|
| 466 |
+
""",
|
| 467 |
+
visible=True,
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
inputs = [msg, chatbot, temperature, max_tokens, thinking, lang_state]
|
| 471 |
outputs = [chatbot, msg]
|
| 472 |
|
static/app.css
CHANGED
|
@@ -41,20 +41,33 @@ body {
|
|
| 41 |
|
| 42 |
.gradio-container,
|
| 43 |
.gradio-container.gradio-container,
|
|
|
|
| 44 |
main.app,
|
| 45 |
main.fillable,
|
|
|
|
| 46 |
.wrap,
|
|
|
|
| 47 |
.contain,
|
|
|
|
| 48 |
.fillable {
|
| 49 |
height: auto !important;
|
| 50 |
min-height: 0 !important;
|
| 51 |
max-height: none !important;
|
| 52 |
flex-grow: 0 !important;
|
|
|
|
| 53 |
background: var(--nyra-void) !important;
|
| 54 |
color: var(--nyra-starlight) !important;
|
| 55 |
font-family: var(--nyra-font-body) !important;
|
| 56 |
}
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
.gradio-container {
|
| 59 |
max-width: 100% !important;
|
| 60 |
padding: 0 !important;
|
|
|
|
| 41 |
|
| 42 |
.gradio-container,
|
| 43 |
.gradio-container.gradio-container,
|
| 44 |
+
.gradio-container[data-iframe-height],
|
| 45 |
main.app,
|
| 46 |
main.fillable,
|
| 47 |
+
main.svelte-18evea3,
|
| 48 |
.wrap,
|
| 49 |
+
.wrap.svelte-czcr5b,
|
| 50 |
.contain,
|
| 51 |
+
.contain.svelte-czcr5b,
|
| 52 |
.fillable {
|
| 53 |
height: auto !important;
|
| 54 |
min-height: 0 !important;
|
| 55 |
max-height: none !important;
|
| 56 |
flex-grow: 0 !important;
|
| 57 |
+
flex: 0 0 auto !important;
|
| 58 |
background: var(--nyra-void) !important;
|
| 59 |
color: var(--nyra-starlight) !important;
|
| 60 |
font-family: var(--nyra-font-body) !important;
|
| 61 |
}
|
| 62 |
|
| 63 |
+
/* Gradio injects min-height:100% inline on .wrap — crush it */
|
| 64 |
+
div.wrap[style],
|
| 65 |
+
div.contain[style] {
|
| 66 |
+
min-height: 0 !important;
|
| 67 |
+
height: auto !important;
|
| 68 |
+
flex-grow: 0 !important;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
.gradio-container {
|
| 72 |
max-width: 100% !important;
|
| 73 |
padding: 0 !important;
|