BoxOfColors Claude Sonnet 5 commited on
Commit
adefefd
Β·
1 Parent(s): 8ed76c6

Fix Generate click never reaching server: watchdog broke the click event

Browse files

Confirmed via server logs (hf spaces logs) that after the previous fix
(8ed76c6), clicking Generate produced zero server-side activity across
all three tabs β€” none of _run_taro/_run_mmaudio/_run_hunyuan's print
statements ever appeared, meaning the click never even reached the
backend. Root cause: combining js= and a real server fn= on the same
.click() event (as 8ed76c6 did) is a combination that breaks the click
from firing at all, contrary to what the docs implied.

Fix: stop using Gradio's js= event-chaining for the watchdog entirely.
Arm it instead via a plain native document click listener (event
delegation, so it works regardless of when Svelte creates the button
DOM). The .click() chains are back to their pre-8ed76c6 form, which
was already confirmed working for triggering generation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -2687,6 +2687,18 @@ _GLOBAL_JS = """
2687
  }, timeoutMs);
2688
  };
2689
 
 
 
 
 
 
 
 
 
 
 
 
 
2690
  // ── ZeroGPU quota attribution ──
2691
  // HF Spaces run inside an iframe on huggingface.co. Gradio's own JS client
2692
  // gets ZeroGPU auth headers (x-zerogpu-token, x-zerogpu-uuid) by sending a
@@ -3161,7 +3173,6 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
3161
  fn=_btn_generating,
3162
  inputs=None,
3163
  outputs=[taro_btn],
3164
- js="() => { window._armGenerateWatchdog('taro_btn', 600000); }",
3165
  ).then(
3166
  fn=_run_taro,
3167
  inputs=[taro_video, taro_seed, taro_cfg, taro_steps, taro_mode,
@@ -3228,7 +3239,6 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
3228
  fn=_btn_generating,
3229
  inputs=None,
3230
  outputs=[mma_btn],
3231
- js="() => { window._armGenerateWatchdog('mma_btn', 600000); }",
3232
  ).then(
3233
  fn=_run_mmaudio,
3234
  inputs=[mma_video, mma_prompt, mma_neg, mma_seed,
@@ -3294,7 +3304,6 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
3294
  fn=_btn_generating,
3295
  inputs=None,
3296
  outputs=[hf_btn],
3297
- js="() => { window._armGenerateWatchdog('hf_btn', 600000); }",
3298
  ).then(
3299
  fn=_run_hunyuan,
3300
  inputs=[hf_video, hf_prompt, hf_neg, hf_seed,
 
2687
  }, timeoutMs);
2688
  };
2689
 
2690
+ // Arm the watchdog via a plain native click listener (event delegation on
2691
+ // document, so it works regardless of when Gradio/Svelte creates the button
2692
+ // elements) rather than Gradio's own js= event-chaining mechanism. Combining
2693
+ // js= with a real server fn= on the SAME .click() event was tried and broke
2694
+ // the click from ever reaching the server at all (confirmed via server logs
2695
+ // showing zero activity after the click) β€” this sidesteps Gradio's event
2696
+ // wiring entirely so it can't interfere with the real click β†’ fn chain.
2697
+ document.addEventListener('click', function(ev) {
2698
+ const hit = ev.target.closest && ev.target.closest('#taro_btn, #mma_btn, #hf_btn');
2699
+ if (hit) window._armGenerateWatchdog(hit.id, 600000);
2700
+ });
2701
+
2702
  // ── ZeroGPU quota attribution ──
2703
  // HF Spaces run inside an iframe on huggingface.co. Gradio's own JS client
2704
  // gets ZeroGPU auth headers (x-zerogpu-token, x-zerogpu-uuid) by sending a
 
3173
  fn=_btn_generating,
3174
  inputs=None,
3175
  outputs=[taro_btn],
 
3176
  ).then(
3177
  fn=_run_taro,
3178
  inputs=[taro_video, taro_seed, taro_cfg, taro_steps, taro_mode,
 
3239
  fn=_btn_generating,
3240
  inputs=None,
3241
  outputs=[mma_btn],
 
3242
  ).then(
3243
  fn=_run_mmaudio,
3244
  inputs=[mma_video, mma_prompt, mma_neg, mma_seed,
 
3304
  fn=_btn_generating,
3305
  inputs=None,
3306
  outputs=[hf_btn],
 
3307
  ).then(
3308
  fn=_run_hunyuan,
3309
  inputs=[hf_video, hf_prompt, hf_neg, hf_seed,