Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +147 -16
- witgym/debug_render.py +43 -9
app.py
CHANGED
|
@@ -166,8 +166,9 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 166 |
font-family: 'Bebas Neue', Impact, 'Arial Black', sans-serif;
|
| 167 |
font-size: clamp(4.5rem, 18vw, 9rem); letter-spacing: 0.03em;
|
| 168 |
}
|
| 169 |
-
.wg-wordmark-wit { color: var(--wg-white); }
|
| 170 |
-
|
|
|
|
| 171 |
|
| 172 |
.wg-hero-tagline {
|
| 173 |
font-family: 'EB Garamond', Georgia, serif; font-style: italic;
|
|
@@ -266,11 +267,17 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 266 |
font-size: 0.58rem; color: var(--wg-muted); text-align: center;
|
| 267 |
}
|
| 268 |
|
| 269 |
-
/* ── Practice screen header (compact) ───────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
.wg-practice-bar {
|
| 271 |
-
display: flex; align-items: center; gap: 0.75rem;
|
| 272 |
padding: 0.75rem 1.25rem; border-bottom: 1px solid #d8d0c4;
|
| 273 |
background: #faf9f6;
|
|
|
|
| 274 |
}
|
| 275 |
.wg-practice-logo {
|
| 276 |
font-family: 'Bebas Neue', Impact, sans-serif;
|
|
@@ -459,12 +466,17 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 459 |
/* Debug panels */
|
| 460 |
.wg-panel {
|
| 461 |
border-radius: 7px; padding: 0.6rem 0.8rem;
|
| 462 |
-
margin: 0.35rem 0; border: 1px solid; font-size:
|
| 463 |
}
|
| 464 |
.wg-panel-title {
|
| 465 |
-
font-family: 'Bebas Neue', sans-serif; font-size: 0.
|
| 466 |
-
letter-spacing: 0.08em; margin-bottom: 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
}
|
|
|
|
| 468 |
.wg-panel-yellow { background: #1a1000; border-color: #6b3a0a; color: #fcd34d; }
|
| 469 |
.wg-panel-yellow .wg-panel-title { color: #fbbf24; }
|
| 470 |
.wg-panel-blue { background: #050e1e; border-color: #1e3558; color: #93c5fd; }
|
|
@@ -495,6 +507,22 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 495 |
.wg-meta td { padding: 0.1rem 0.5rem 0.1rem 0; vertical-align: top; }
|
| 496 |
.wg-rule { border-top: 1px solid var(--wg-border); margin: 0.75rem 0; }
|
| 497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
/* ── Metadata chips (dark-mode defaults) ────────────────────────────────── */
|
| 499 |
.wg-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.45rem 0 0.35rem; }
|
| 500 |
.wg-chip {
|
|
@@ -524,7 +552,7 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 524 |
}
|
| 525 |
.wg-capsule-head:hover { color: var(--wg-white); background: rgba(255,255,255,0.04); }
|
| 526 |
.wg-capsule-body {
|
| 527 |
-
padding: 0.5rem 0.65rem; font-size: 0.
|
| 528 |
color: rgba(240,240,240,0.88); line-height: 1.55;
|
| 529 |
border-top: 1px solid var(--wg-border); background: var(--wg-surf2);
|
| 530 |
}
|
|
@@ -532,6 +560,100 @@ body.wg-light-mode footer { background: #fffff8 !important; }
|
|
| 532 |
.wg-cap-chev { font-size: 0.6rem; transition: transform .18s; display: inline-block; }
|
| 533 |
.wg-capsule--open .wg-cap-chev { transform: rotate(90deg); }
|
| 534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
/* ── Light-mode overrides for chips + capsules ──────────────────────────── */
|
| 536 |
#wg-practice .wg-chip-cyan { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
|
| 537 |
#wg-practice .wg-chip-purple { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
|
|
@@ -829,6 +951,14 @@ window.wgClose = function() {
|
|
| 829 |
var o = document.getElementById('wg-modal-overlay');
|
| 830 |
if (o) o.style.display = 'none';
|
| 831 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 832 |
window.wgOpenBio = function(name, title, desc, avatarUrl) {
|
| 833 |
var o = document.getElementById('wg-modal-overlay');
|
| 834 |
var b = document.getElementById('wg-modal-body');
|
|
@@ -1091,8 +1221,6 @@ def _theme():
|
|
| 1091 |
|
| 1092 |
|
| 1093 |
def build_ui():
|
| 1094 |
-
# css=, theme=, head= belong in launch() in Gradio 6.x (SSR-compatible path).
|
| 1095 |
-
# Passing them to gr.Blocks() triggers a deprecation path that breaks SSR hydration on HF Spaces.
|
| 1096 |
with gr.Blocks(title="WitGym") as demo:
|
| 1097 |
# Modal scaffold at top DOM level — position:fixed, never hidden by Column visibility toggling.
|
| 1098 |
# JS is injected via launch(head=...) below, not here, for SSR compatibility.
|
|
@@ -1134,17 +1262,17 @@ def build_ui():
|
|
| 1134 |
)
|
| 1135 |
with gr.Row():
|
| 1136 |
submit_btn = gr.Button(
|
| 1137 |
-
"
|
| 1138 |
elem_id="wg-submit-btn",
|
| 1139 |
)
|
| 1140 |
-
clear_btn = gr.Button("
|
| 1141 |
|
| 1142 |
|
| 1143 |
with gr.Column(scale=1, elem_id="wg-sidebar"):
|
| 1144 |
gr.HTML('<div class="wg-sidebar-label">Try a situation</div>')
|
| 1145 |
for tag, text in STARTERS:
|
| 1146 |
sb = gr.Button(
|
| 1147 |
-
f"
|
| 1148 |
elem_classes=["wg-starter-btn"],
|
| 1149 |
)
|
| 1150 |
sb.click(fn=fill_starter, inputs=[gr.State(text)], outputs=user_input, queue=False)
|
|
@@ -1179,13 +1307,16 @@ def build_ui():
|
|
| 1179 |
|
| 1180 |
|
| 1181 |
demo = build_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1182 |
demo.queue(default_concurrency_limit=1)
|
| 1183 |
demo.favicon_path = _FAVICON
|
| 1184 |
|
| 1185 |
if __name__ == "__main__":
|
| 1186 |
-
# css=, theme=, head= must be in launch() for Gradio 6.x SSR compatibility (HF Spaces).
|
| 1187 |
-
# In SSR mode Node.js renders components server-side; these params are only correctly
|
| 1188 |
-
# threaded through when passed at launch time, not at Blocks() construction time.
|
| 1189 |
kwargs = dict(
|
| 1190 |
favicon_path=_FAVICON,
|
| 1191 |
css=APP_CSS,
|
|
|
|
| 166 |
font-family: 'Bebas Neue', Impact, 'Arial Black', sans-serif;
|
| 167 |
font-size: clamp(4.5rem, 18vw, 9rem); letter-spacing: 0.03em;
|
| 168 |
}
|
| 169 |
+
.wg-wordmark-wit { color: var(--wg-white); text-shadow: 0 0 40px rgba(0,0,0,0.6); }
|
| 170 |
+
/* Stronger shadow separates GYM (yellow) from the yellow dot grid behind it */
|
| 171 |
+
.wg-wordmark-gym { color: var(--wg-yellow); text-shadow: 0 2px 20px rgba(0,0,0,0.8), 0 0 60px rgba(0,0,0,0.5); }
|
| 172 |
|
| 173 |
.wg-hero-tagline {
|
| 174 |
font-family: 'EB Garamond', Georgia, serif; font-style: italic;
|
|
|
|
| 267 |
font-size: 0.58rem; color: var(--wg-muted); text-align: center;
|
| 268 |
}
|
| 269 |
|
| 270 |
+
/* ── Practice screen header (compact, centered) ─────────────────────────── */
|
| 271 |
+
@keyframes wg-header-drop {
|
| 272 |
+
0% { transform: translateY(-10px) scaleY(0.82); opacity: 0; }
|
| 273 |
+
65% { transform: translateY(2px) scaleY(1.04); opacity: 1; }
|
| 274 |
+
100% { transform: translateY(0) scaleY(1); }
|
| 275 |
+
}
|
| 276 |
.wg-practice-bar {
|
| 277 |
+
display: flex; align-items: center; justify-content: center; gap: 0.75rem;
|
| 278 |
padding: 0.75rem 1.25rem; border-bottom: 1px solid #d8d0c4;
|
| 279 |
background: #faf9f6;
|
| 280 |
+
animation: wg-header-drop 0.42s cubic-bezier(.22,.68,0,1.35) both;
|
| 281 |
}
|
| 282 |
.wg-practice-logo {
|
| 283 |
font-family: 'Bebas Neue', Impact, sans-serif;
|
|
|
|
| 466 |
/* Debug panels */
|
| 467 |
.wg-panel {
|
| 468 |
border-radius: 7px; padding: 0.6rem 0.8rem;
|
| 469 |
+
margin: 0.35rem 0; border: 1px solid; font-size: 14px;
|
| 470 |
}
|
| 471 |
.wg-panel-title {
|
| 472 |
+
font-family: 'Bebas Neue', sans-serif; font-size: 0.82rem;
|
| 473 |
+
letter-spacing: 0.08em; margin-bottom: 0.35rem;
|
| 474 |
+
}
|
| 475 |
+
/* Clickable chips */
|
| 476 |
+
.wg-chip-clickable {
|
| 477 |
+
cursor: pointer; transition: filter .15s, transform .1s;
|
| 478 |
}
|
| 479 |
+
.wg-chip-clickable:hover { filter: brightness(1.25); transform: scale(1.06); }
|
| 480 |
.wg-panel-yellow { background: #1a1000; border-color: #6b3a0a; color: #fcd34d; }
|
| 481 |
.wg-panel-yellow .wg-panel-title { color: #fbbf24; }
|
| 482 |
.wg-panel-blue { background: #050e1e; border-color: #1e3558; color: #93c5fd; }
|
|
|
|
| 507 |
.wg-meta td { padding: 0.1rem 0.5rem 0.1rem 0; vertical-align: top; }
|
| 508 |
.wg-rule { border-top: 1px solid var(--wg-border); margin: 0.75rem 0; }
|
| 509 |
|
| 510 |
+
/* ── Coaching notes toggle attention flicker (plays 4× on new turns) ────── */
|
| 511 |
+
@keyframes wg-toggle-beckon {
|
| 512 |
+
0%,100% { color: var(--wg-muted); box-shadow: none; }
|
| 513 |
+
40%,60% { color: var(--wg-yellow); box-shadow: 0 0 10px rgba(245,197,24,0.35); border-color: rgba(245,197,24,0.5); }
|
| 514 |
+
}
|
| 515 |
+
.wg-debug-toggle--new .wg-debug-toggle-label {
|
| 516 |
+
animation: wg-toggle-beckon 1.1s ease-in-out 0.4s 4 forwards;
|
| 517 |
+
}
|
| 518 |
+
#wg-practice .wg-debug-toggle--new .wg-debug-toggle-label {
|
| 519 |
+
animation: wg-toggle-beckon-light 1.1s ease-in-out 0.4s 4 forwards;
|
| 520 |
+
}
|
| 521 |
+
@keyframes wg-toggle-beckon-light {
|
| 522 |
+
0%,100% { color: #9e9288; box-shadow: none; }
|
| 523 |
+
40%,60% { color: #b45309; box-shadow: 0 0 8px rgba(180,83,9,0.25); border-color: rgba(180,83,9,0.4); }
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
/* ── Metadata chips (dark-mode defaults) ────────────────────────────────── */
|
| 527 |
.wg-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.45rem 0 0.35rem; }
|
| 528 |
.wg-chip {
|
|
|
|
| 552 |
}
|
| 553 |
.wg-capsule-head:hover { color: var(--wg-white); background: rgba(255,255,255,0.04); }
|
| 554 |
.wg-capsule-body {
|
| 555 |
+
padding: 0.5rem 0.65rem; font-size: 0.92rem;
|
| 556 |
color: rgba(240,240,240,0.88); line-height: 1.55;
|
| 557 |
border-top: 1px solid var(--wg-border); background: var(--wg-surf2);
|
| 558 |
}
|
|
|
|
| 560 |
.wg-cap-chev { font-size: 0.6rem; transition: transform .18s; display: inline-block; }
|
| 561 |
.wg-capsule--open .wg-cap-chev { transform: rotate(90deg); }
|
| 562 |
|
| 563 |
+
/* ── Shared shimmer + attention keyframes ────────────────────────────────── */
|
| 564 |
+
/* Shimmer: light highlight sweeps L→R — signals "this surface has depth" */
|
| 565 |
+
@keyframes wg-shimmer-slide {
|
| 566 |
+
0% { transform: translateX(-160%); }
|
| 567 |
+
100% { transform: translateX(160%); }
|
| 568 |
+
}
|
| 569 |
+
/* Chevron bobs toward hidden content — pure motion affordance */
|
| 570 |
+
@keyframes wg-chev-beckon {
|
| 571 |
+
0%,100% { transform: translateX(0); }
|
| 572 |
+
40% { transform: translateX(6px); }
|
| 573 |
+
}
|
| 574 |
+
/* Border breathes with a warm glow — signals "this boundary is crossable" */
|
| 575 |
+
@keyframes wg-capsule-glow {
|
| 576 |
+
0%,100% { border-color: var(--wg-border); box-shadow: none; }
|
| 577 |
+
50% { border-color: rgba(245,197,24,0.7); box-shadow: 0 0 0 2.5px rgba(245,197,24,0.18); }
|
| 578 |
+
}
|
| 579 |
+
/* Chip pop-in: slight scale bounce then settles — signals "I'm interactive" */
|
| 580 |
+
@keyframes wg-chip-pop {
|
| 581 |
+
0% { transform: scale(0.88); opacity: 0.6; }
|
| 582 |
+
60% { transform: scale(1.08); opacity: 1; }
|
| 583 |
+
100% { transform: scale(1); opacity: 1; }
|
| 584 |
+
}
|
| 585 |
+
/* Chip shimmer: same sweep but stronger amber */
|
| 586 |
+
@keyframes wg-chip-shimmer {
|
| 587 |
+
0% { transform: translateX(-180%); }
|
| 588 |
+
100% { transform: translateX(180%); }
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
/* ── Capsule attention (border glow + head shimmer + chevron bob) ─────────── */
|
| 592 |
+
.wg-capsule--new {
|
| 593 |
+
animation: wg-capsule-glow 1.2s ease-in-out 0.4s 3 both;
|
| 594 |
+
}
|
| 595 |
+
.wg-capsule--new .wg-capsule-head {
|
| 596 |
+
position: relative; overflow: hidden;
|
| 597 |
+
}
|
| 598 |
+
.wg-capsule--new .wg-capsule-head::after {
|
| 599 |
+
content: ''; position: absolute; inset: 0; pointer-events: none;
|
| 600 |
+
background: linear-gradient(90deg, transparent 15%, rgba(245,197,24,0.55) 50%, transparent 85%);
|
| 601 |
+
transform: translateX(-160%);
|
| 602 |
+
animation: wg-shimmer-slide 1.1s ease-in-out 0.7s 3 both;
|
| 603 |
+
}
|
| 604 |
+
.wg-capsule--new .wg-cap-chev {
|
| 605 |
+
animation: wg-chev-beckon 0.5s ease-in-out 0.3s 6 both;
|
| 606 |
+
}
|
| 607 |
+
/* Kill all animations once the user engages */
|
| 608 |
+
.wg-capsule--new.wg-capsule--open,
|
| 609 |
+
.wg-capsule--new.wg-capsule--open .wg-capsule-head::after,
|
| 610 |
+
.wg-capsule--new.wg-capsule--open .wg-cap-chev { animation: none; }
|
| 611 |
+
|
| 612 |
+
/* Light-mode capsule overrides */
|
| 613 |
+
@keyframes wg-capsule-glow-light {
|
| 614 |
+
0%,100% { border-color: #e0d8cc; box-shadow: none; }
|
| 615 |
+
50% { border-color: rgba(180,83,9,0.6); box-shadow: 0 0 0 2.5px rgba(180,83,9,0.14); }
|
| 616 |
+
}
|
| 617 |
+
#wg-practice .wg-capsule--new {
|
| 618 |
+
animation: wg-capsule-glow-light 1.2s ease-in-out 0.4s 3 both;
|
| 619 |
+
}
|
| 620 |
+
#wg-practice .wg-capsule--new .wg-capsule-head::after {
|
| 621 |
+
background: linear-gradient(90deg, transparent 15%, rgba(180,83,9,0.45) 50%, transparent 85%);
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
/* ── Chip attention: pop-in scale bounce + shimmer sweep ─────────────────── */
|
| 625 |
+
.wg-chip-clickable {
|
| 626 |
+
position: relative; overflow: hidden;
|
| 627 |
+
animation: wg-chip-pop 0.45s cubic-bezier(.22,.68,0,1.4) both;
|
| 628 |
+
}
|
| 629 |
+
/* Stagger the three chips */
|
| 630 |
+
.wg-chip-row .wg-chip-clickable:nth-child(1) { animation-delay: 0.05s; }
|
| 631 |
+
.wg-chip-row .wg-chip-clickable:nth-child(2) { animation-delay: 0.18s; }
|
| 632 |
+
.wg-chip-row .wg-chip-clickable:nth-child(3) { animation-delay: 0.31s; }
|
| 633 |
+
/* Shimmer on each chip after its pop-in */
|
| 634 |
+
.wg-chip-clickable::after {
|
| 635 |
+
content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
|
| 636 |
+
background: linear-gradient(90deg, transparent 10%, rgba(255,255,255,0.55) 50%, transparent 90%);
|
| 637 |
+
transform: translateX(-180%);
|
| 638 |
+
animation: wg-chip-shimmer 0.9s ease-in-out 0.55s 2 both;
|
| 639 |
+
}
|
| 640 |
+
.wg-chip-row .wg-chip-clickable:nth-child(2)::after { animation-delay: 0.68s; }
|
| 641 |
+
.wg-chip-row .wg-chip-clickable:nth-child(3)::after { animation-delay: 0.81s; }
|
| 642 |
+
|
| 643 |
+
/* ── Coaching notes toggle shimmer ──────────────────────────────────────── */
|
| 644 |
+
.wg-debug-toggle--new .wg-debug-toggle-label {
|
| 645 |
+
position: relative; overflow: hidden;
|
| 646 |
+
}
|
| 647 |
+
.wg-debug-toggle--new .wg-debug-toggle-label::after {
|
| 648 |
+
content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
|
| 649 |
+
background: linear-gradient(90deg, transparent 15%, rgba(245,197,24,0.5) 50%, transparent 85%);
|
| 650 |
+
transform: translateX(-160%);
|
| 651 |
+
animation: wg-shimmer-slide 1.3s ease-in-out 0.2s 3 both;
|
| 652 |
+
}
|
| 653 |
+
#wg-practice .wg-debug-toggle--new .wg-debug-toggle-label::after {
|
| 654 |
+
background: linear-gradient(90deg, transparent 15%, rgba(180,83,9,0.38) 50%, transparent 85%);
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
/* ── Light-mode overrides for chips + capsules ──────────────────────────── */
|
| 658 |
#wg-practice .wg-chip-cyan { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
|
| 659 |
#wg-practice .wg-chip-purple { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
|
|
|
|
| 951 |
var o = document.getElementById('wg-modal-overlay');
|
| 952 |
if (o) o.style.display = 'none';
|
| 953 |
};
|
| 954 |
+
window.wgOpenChip = function(title, definition) {
|
| 955 |
+
var o = document.getElementById('wg-modal-overlay');
|
| 956 |
+
var b = document.getElementById('wg-modal-body');
|
| 957 |
+
if (!o || !b) return;
|
| 958 |
+
b.innerHTML = '<div class="wg-pop-show">' + title + '</div>'
|
| 959 |
+
+ '<div class="wg-pop-bio" style="font-style:normal;font-size:1.05rem">' + definition + '</div>';
|
| 960 |
+
o.style.display = 'flex';
|
| 961 |
+
};
|
| 962 |
window.wgOpenBio = function(name, title, desc, avatarUrl) {
|
| 963 |
var o = document.getElementById('wg-modal-overlay');
|
| 964 |
var b = document.getElementById('wg-modal-body');
|
|
|
|
| 1221 |
|
| 1222 |
|
| 1223 |
def build_ui():
|
|
|
|
|
|
|
| 1224 |
with gr.Blocks(title="WitGym") as demo:
|
| 1225 |
# Modal scaffold at top DOM level — position:fixed, never hidden by Column visibility toggling.
|
| 1226 |
# JS is injected via launch(head=...) below, not here, for SSR compatibility.
|
|
|
|
| 1262 |
)
|
| 1263 |
with gr.Row():
|
| 1264 |
submit_btn = gr.Button(
|
| 1265 |
+
"Flex Your Wit →", variant="primary", scale=4,
|
| 1266 |
elem_id="wg-submit-btn",
|
| 1267 |
)
|
| 1268 |
+
clear_btn = gr.Button("Start over →", size="sm", variant="secondary", scale=1)
|
| 1269 |
|
| 1270 |
|
| 1271 |
with gr.Column(scale=1, elem_id="wg-sidebar"):
|
| 1272 |
gr.HTML('<div class="wg-sidebar-label">Try a situation</div>')
|
| 1273 |
for tag, text in STARTERS:
|
| 1274 |
sb = gr.Button(
|
| 1275 |
+
f"{tag.lower()} · {text}", size="sm", variant="secondary",
|
| 1276 |
elem_classes=["wg-starter-btn"],
|
| 1277 |
)
|
| 1278 |
sb.click(fn=fill_starter, inputs=[gr.State(text)], outputs=user_input, queue=False)
|
|
|
|
| 1307 |
|
| 1308 |
|
| 1309 |
demo = build_ui()
|
| 1310 |
+
# Attach css/theme/head to the Blocks object at module level so HF Spaces picks them up
|
| 1311 |
+
# when it imports `demo` and calls its own launch() without these kwargs.
|
| 1312 |
+
# Gradio 6.x reads these from the Blocks object if not explicitly passed to launch().
|
| 1313 |
+
demo.css = APP_CSS
|
| 1314 |
+
demo.theme = _theme()
|
| 1315 |
+
demo.head = _GLOBAL_JS_SCRIPT_TAG
|
| 1316 |
demo.queue(default_concurrency_limit=1)
|
| 1317 |
demo.favicon_path = _FAVICON
|
| 1318 |
|
| 1319 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
| 1320 |
kwargs = dict(
|
| 1321 |
favicon_path=_FAVICON,
|
| 1322 |
css=APP_CSS,
|
witgym/debug_render.py
CHANGED
|
@@ -48,6 +48,28 @@ def _fmt_chip(value: str) -> str:
|
|
| 48 |
return value.replace("_", " ").upper()
|
| 49 |
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def _jstr(text: str) -> str:
|
| 52 |
"""JSON-encode a string for safe embedding in an HTML onclick attribute."""
|
| 53 |
return json.dumps(text)
|
|
@@ -110,29 +132,40 @@ def thinking_turn_html(user_input: str) -> str:
|
|
| 110 |
)
|
| 111 |
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
def _meta_pass1_html(meta) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
connector_chip = (
|
| 115 |
f'<div class="wg-chip-row">'
|
| 116 |
f'<span class="wg-chip-label">connector</span>'
|
| 117 |
-
f'<span class="wg-chip wg-chip-green"
|
|
|
|
|
|
|
| 118 |
f'</div>'
|
| 119 |
) if meta.connector else ""
|
| 120 |
return (
|
| 121 |
'<div class="wg-panel wg-panel-yellow">'
|
| 122 |
-
'<div class="wg-panel-title">
|
| 123 |
'<div class="wg-chip-row">'
|
| 124 |
-
f'<span class="wg-chip wg-chip-cyan">{_esc(_fmt_chip(meta.archetype.value))}</span>'
|
| 125 |
-
f'<span class="wg-chip wg-chip-purple">{_esc(_fmt_chip(meta.tension_type.value))}</span>'
|
| 126 |
-
f'<span class="wg-chip wg-chip-orange">{_esc(_fmt_chip(meta.violation_distance.value))}</span>'
|
| 127 |
'</div>'
|
| 128 |
f'{connector_chip}'
|
| 129 |
f'<div class="wg-avoided"><span class="wg-dim">avoided →</span> '
|
| 130 |
f'<span class="wg-dim-italic">{_esc(meta.obvious_response)}</span></div>'
|
| 131 |
-
'<div class="wg-capsule">'
|
| 132 |
'<div class="wg-capsule-head">SUBTEXT <span class="wg-cap-chev">▶</span></div>'
|
| 133 |
f'<div class="wg-capsule-body wg-collapsed">{_esc(meta.subtext)}</div>'
|
| 134 |
'</div>'
|
| 135 |
-
'<div class="wg-capsule">'
|
| 136 |
'<div class="wg-capsule-head">POWER DYNAMIC <span class="wg-cap-chev">▶</span></div>'
|
| 137 |
f'<div class="wg-capsule-body wg-collapsed">{_esc(meta.power_dynamic)}</div>'
|
| 138 |
'</div>'
|
|
@@ -332,7 +365,7 @@ def format_streaming_turn_html(state: StreamingTurnState, show_debug: bool = Tru
|
|
| 332 |
|
| 333 |
parts += [
|
| 334 |
_twist_meter_html(state.metadata.twist_potential),
|
| 335 |
-
'<div class="wg-debug-toggle">',
|
| 336 |
'<span class="wg-debug-toggle-line"></span>',
|
| 337 |
f'<span class="wg-debug-toggle-label">Coaching notes <span class="wg-debug-chevron">{chevron}</span></span>',
|
| 338 |
'<span class="wg-debug-toggle-line"></span>',
|
|
@@ -439,10 +472,11 @@ def format_trace_html(result: WitGymResponse, user_input: str, show_debug: bool
|
|
| 439 |
# New-turn reveal class for animation
|
| 440 |
new_cls = " wg-coach-reply--new" if is_last else ""
|
| 441 |
|
|
|
|
| 442 |
parts += [
|
| 443 |
_mode_badge_html(result.route),
|
| 444 |
_twist_meter_html(result.metadata.twist_potential),
|
| 445 |
-
'<div class="wg-debug-toggle">',
|
| 446 |
'<span class="wg-debug-toggle-line"></span>',
|
| 447 |
f'<span class="wg-debug-toggle-label">Coaching notes <span class="wg-debug-chevron">{chevron}</span></span>',
|
| 448 |
'<span class="wg-debug-toggle-line"></span>',
|
|
|
|
| 48 |
return value.replace("_", " ").upper()
|
| 49 |
|
| 50 |
|
| 51 |
+
# Succinct definitions for each comedy structural property — shown on chip click
|
| 52 |
+
_CHIP_DEFS: dict[str, tuple[str, str]] = {
|
| 53 |
+
# Archetypes
|
| 54 |
+
"status_assertion": ("STATUS ASSERTION", "Who's in charge here? Comedy exploits the gap between perceived and actual authority."),
|
| 55 |
+
"self_delusion": ("SELF-DELUSION", "The speaker's internal narrative and external reality are on different planets. Exposure is inevitable."),
|
| 56 |
+
"power_inversion": ("POWER INVERSION", "Expected hierarchy flips. The person who should win, loses — and the reversal is the joke."),
|
| 57 |
+
"anxiety_escalation": ("ANXIETY ESCALATION", "A small worry snowballs into catastrophe in real time. Comedy lives in watching the spiral."),
|
| 58 |
+
"social_fail": ("SOCIAL PERFORMANCE FAIL", "The attempt to appear normal backfires. The harder the try, the bigger the collapse."),
|
| 59 |
+
"misplaced_conf": ("MISPLACED CONFIDENCE", "Maximum certainty, zero basis for it. The most dangerous form of comedy."),
|
| 60 |
+
# Tensions
|
| 61 |
+
"social_embarrass": ("SOCIAL EMBARRASSMENT", "The gap between how you want to appear and how you actually appear. Everyone sees it except you."),
|
| 62 |
+
"existential": ("EXISTENTIAL ANXIETY", "The joke touches something deeper — identity, mortality, meaning. The laugh is a release valve."),
|
| 63 |
+
"status_threat": ("STATUS THREAT", "Someone's rank or belonging is under attack. Comedy exploits the gap between deserved and claimed status."),
|
| 64 |
+
"identity_expose": ("IDENTITY EXPOSURE", "A mask slips. What someone really is gets revealed against their will. Truth was always funnier."),
|
| 65 |
+
"logic_collapse": ("LOGIC COLLAPSE", "A belief or argument implodes under its own internal contradictions. Comedy as structural failure."),
|
| 66 |
+
# Distances
|
| 67 |
+
"mild": ("MILD VIOLATION", "Gentle subversion. Safe for a work meeting. The laugh is a small, polite exhale."),
|
| 68 |
+
"moderate": ("MODERATE VIOLATION", "Has an edge. Makes the room slightly uncomfortable in a productive way. The sweet spot."),
|
| 69 |
+
"sharp": ("SHARP VIOLATION", "Cuts deep. The kind of line that makes people go quiet, then laugh harder than expected."),
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
def _jstr(text: str) -> str:
|
| 74 |
"""JSON-encode a string for safe embedding in an HTML onclick attribute."""
|
| 75 |
return json.dumps(text)
|
|
|
|
| 132 |
)
|
| 133 |
|
| 134 |
|
| 135 |
+
def _chip_onclick(value: str) -> str:
|
| 136 |
+
title, defn = _CHIP_DEFS.get(value, (_fmt_chip(value), "A comedy structural property."))
|
| 137 |
+
return f"wgOpenChip({_jstr(title)},{_jstr(defn)})"
|
| 138 |
+
|
| 139 |
+
|
| 140 |
def _meta_pass1_html(meta) -> str:
|
| 141 |
+
arc_click = _chip_onclick(meta.archetype.value)
|
| 142 |
+
ten_click = _chip_onclick(meta.tension_type.value)
|
| 143 |
+
vio_click = _chip_onclick(meta.violation_distance.value)
|
| 144 |
+
_connector_onclick = "wgOpenChip(" + _jstr("CONNECTOR") + "," + _jstr("A word or phrase with two simultaneous readings. When it lands, both meanings hit at once — that’s the mechanism.") + ")"
|
| 145 |
connector_chip = (
|
| 146 |
f'<div class="wg-chip-row">'
|
| 147 |
f'<span class="wg-chip-label">connector</span>'
|
| 148 |
+
f'<span class="wg-chip wg-chip-green wg-chip-clickable"'
|
| 149 |
+
f' onclick="{_esc(_connector_onclick)}"'
|
| 150 |
+
f' title="what is a connector?">{_esc(meta.connector)}</span>'
|
| 151 |
f'</div>'
|
| 152 |
) if meta.connector else ""
|
| 153 |
return (
|
| 154 |
'<div class="wg-panel wg-panel-yellow">'
|
| 155 |
+
'<div class="wg-panel-title">Neurology of Comedy</div>'
|
| 156 |
'<div class="wg-chip-row">'
|
| 157 |
+
f'<span class="wg-chip wg-chip-cyan wg-chip-clickable" onclick="{_esc(arc_click)}" title="what is this archetype?">{_esc(_fmt_chip(meta.archetype.value))}</span>'
|
| 158 |
+
f'<span class="wg-chip wg-chip-purple wg-chip-clickable" onclick="{_esc(ten_click)}" title="what is this tension?">{_esc(_fmt_chip(meta.tension_type.value))}</span>'
|
| 159 |
+
f'<span class="wg-chip wg-chip-orange wg-chip-clickable" onclick="{_esc(vio_click)}" title="what is this distance?">{_esc(_fmt_chip(meta.violation_distance.value))}</span>'
|
| 160 |
'</div>'
|
| 161 |
f'{connector_chip}'
|
| 162 |
f'<div class="wg-avoided"><span class="wg-dim">avoided →</span> '
|
| 163 |
f'<span class="wg-dim-italic">{_esc(meta.obvious_response)}</span></div>'
|
| 164 |
+
'<div class="wg-capsule wg-capsule--new">'
|
| 165 |
'<div class="wg-capsule-head">SUBTEXT <span class="wg-cap-chev">▶</span></div>'
|
| 166 |
f'<div class="wg-capsule-body wg-collapsed">{_esc(meta.subtext)}</div>'
|
| 167 |
'</div>'
|
| 168 |
+
'<div class="wg-capsule wg-capsule--new">'
|
| 169 |
'<div class="wg-capsule-head">POWER DYNAMIC <span class="wg-cap-chev">▶</span></div>'
|
| 170 |
f'<div class="wg-capsule-body wg-collapsed">{_esc(meta.power_dynamic)}</div>'
|
| 171 |
'</div>'
|
|
|
|
| 365 |
|
| 366 |
parts += [
|
| 367 |
_twist_meter_html(state.metadata.twist_potential),
|
| 368 |
+
'<div class="wg-debug-toggle wg-debug-toggle--new">',
|
| 369 |
'<span class="wg-debug-toggle-line"></span>',
|
| 370 |
f'<span class="wg-debug-toggle-label">Coaching notes <span class="wg-debug-chevron">{chevron}</span></span>',
|
| 371 |
'<span class="wg-debug-toggle-line"></span>',
|
|
|
|
| 472 |
# New-turn reveal class for animation
|
| 473 |
new_cls = " wg-coach-reply--new" if is_last else ""
|
| 474 |
|
| 475 |
+
beckon_cls = " wg-debug-toggle--new" if is_last else ""
|
| 476 |
parts += [
|
| 477 |
_mode_badge_html(result.route),
|
| 478 |
_twist_meter_html(result.metadata.twist_potential),
|
| 479 |
+
f'<div class="wg-debug-toggle{beckon_cls}">',
|
| 480 |
'<span class="wg-debug-toggle-line"></span>',
|
| 481 |
f'<span class="wg-debug-toggle-label">Coaching notes <span class="wg-debug-chevron">{chevron}</span></span>',
|
| 482 |
'<span class="wg-debug-toggle-line"></span>',
|