Commit ·
7ab32d4
1
Parent(s): e550e2e
Replace the empty-prompt alert with an inline, context-aware hint
Browse filesClicking Write with AI with an empty scenario box used to throw a
blocking browser alert (especially jarring inside the HF Space iframe).
Now it focuses the prompt field and shows an inline hint — and when an
example script is already loaded, the hint points to Generate Audio
instead of implying something is wrong. Typing clears the hint.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- static/app.js +11 -1
static/app.js
CHANGED
|
@@ -629,10 +629,20 @@ el.loadScriptBtn.addEventListener("click", async () => {
|
|
| 629 |
});
|
| 630 |
|
| 631 |
/* ---------------- AI script generation ---------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
el.generateScriptBtn.addEventListener("click", async () => {
|
| 633 |
const prompt = el.scriptPrompt.value.trim();
|
| 634 |
if (!prompt) {
|
| 635 |
-
|
|
|
|
| 636 |
return;
|
| 637 |
}
|
| 638 |
|
|
|
|
| 629 |
});
|
| 630 |
|
| 631 |
/* ---------------- AI script generation ---------------- */
|
| 632 |
+
const PROMPT_HINTS = [
|
| 633 |
+
"Describe a scenario above first.",
|
| 634 |
+
"Describe a new scenario above — or press Generate Audio to voice the script you already have.",
|
| 635 |
+
];
|
| 636 |
+
|
| 637 |
+
el.scriptPrompt.addEventListener("input", () => {
|
| 638 |
+
if (PROMPT_HINTS.includes(el.scriptGenStatus.textContent)) el.scriptGenStatus.textContent = "";
|
| 639 |
+
});
|
| 640 |
+
|
| 641 |
el.generateScriptBtn.addEventListener("click", async () => {
|
| 642 |
const prompt = el.scriptPrompt.value.trim();
|
| 643 |
if (!prompt) {
|
| 644 |
+
el.scriptPrompt.focus();
|
| 645 |
+
el.scriptGenStatus.textContent = state.turns.length ? PROMPT_HINTS[1] : PROMPT_HINTS[0];
|
| 646 |
return;
|
| 647 |
}
|
| 648 |
|