BoxOfColors Claude Sonnet 4.6 commited on
Commit
305c050
·
1 Parent(s): 86e179e

fix: restore waveform HTML before writing error to statusbar

Browse files

The pending spinner (first yield) replaces the whole wf_container HTML
including the statusbar span. On quota error, we were trying to write
to wf_statusbar_* after it had been wiped. Fix: restore preRegenWaveHtml
first, then getElementById finds the span and error message shows correctly.

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

Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -2210,19 +2210,9 @@ _GLOBAL_JS = """
2210
  if (hadError) {
2211
  var toastMsg = typeof errMsg === 'string' ? errMsg : JSON.stringify(errMsg);
2212
 
2213
- // Show error in the status bar (always in our DOM, no cross-origin issues)
2214
- var statusBar = document.getElementById('wf_statusbar_' + slot_id);
2215
- if (statusBar) {
2216
- statusBar.style.color = '#e05252';
2217
- statusBar.textContent = '⚠ ' + toastMsg;
2218
- // Reset after 15s so user can try again
2219
- setTimeout(function() {
2220
- statusBar.style.color = '#888';
2221
- statusBar.textContent = 'Click a segment to regenerate \u00a0|\u00a0 Playhead syncs to video';
2222
- }, 15000);
2223
- }
2224
-
2225
- // Restore waveform HTML to pre-regen snapshot
2226
  if (preRegenWaveHtml !== null) {
2227
  var waveEl = document.getElementById('slot_wave_' + slot_id);
2228
  if (waveEl) waveEl.innerHTML = preRegenWaveHtml;
@@ -2237,7 +2227,20 @@ _GLOBAL_JS = """
2237
  }
2238
  }
2239
 
2240
- if (lbl) lbl.textContent = 'Regen failed';
 
 
 
 
 
 
 
 
 
 
 
 
 
2241
  } else {
2242
  if (lbl) lbl.textContent = 'Done';
2243
 
 
2210
  if (hadError) {
2211
  var toastMsg = typeof errMsg === 'string' ? errMsg : JSON.stringify(errMsg);
2212
 
2213
+ // Restore waveform HTML FIRST the pending spinner may have replaced
2214
+ // the container (including the statusbar span), so we need the original
2215
+ // HTML back before we can write the error message into it.
 
 
 
 
 
 
 
 
 
 
2216
  if (preRegenWaveHtml !== null) {
2217
  var waveEl = document.getElementById('slot_wave_' + slot_id);
2218
  if (waveEl) waveEl.innerHTML = preRegenWaveHtml;
 
2227
  }
2228
  }
2229
 
2230
+ // Now write error into status bar (container is restored so element exists)
2231
+ var statusBar = document.getElementById('wf_statusbar_' + slot_id);
2232
+ if (statusBar) {
2233
+ statusBar.style.color = '#e05252';
2234
+ statusBar.textContent = '\u26a0 ' + toastMsg;
2235
+ setTimeout(function() {
2236
+ statusBar.style.color = '#888';
2237
+ statusBar.textContent = 'Click a segment to regenerate \u00a0|\u00a0 Playhead syncs to video';
2238
+ }, 15000);
2239
+ }
2240
+
2241
+ // Also update the segment label below the waveform
2242
+ var lbl2 = document.getElementById('wf_seglabel_' + slot_id);
2243
+ if (lbl2) lbl2.textContent = 'Quota exceeded — try again later';
2244
  } else {
2245
  if (lbl) lbl.textContent = 'Done';
2246