Skip to content

Local AI BGM and sound effects for Claude Code and any MCP client. Stable Audio 3 on Apple Silicon (MLX) and Windows NVIDIA GPUs (PyTorch). No cloud, no API key.

Web UI polish from the README screenshots (GAME-243)

Kana95db84e1df10
diff --git a/docs/assets/webui-edit-en-dark.png b/docs/assets/webui-edit-en-dark.png
index e8969fc..33a8fd2 100644
Binary files a/docs/assets/webui-edit-en-dark.png and b/docs/assets/webui-edit-en-dark.png differ
diff --git a/docs/assets/webui-edit-en-light.png b/docs/assets/webui-edit-en-light.png
index 8defd4d..55c4062 100644
Binary files a/docs/assets/webui-edit-en-light.png and b/docs/assets/webui-edit-en-light.png differ
diff --git a/docs/assets/webui-edit-ja-dark.png b/docs/assets/webui-edit-ja-dark.png
index e02f0f5..20cbad4 100644
Binary files a/docs/assets/webui-edit-ja-dark.png and b/docs/assets/webui-edit-ja-dark.png differ
diff --git a/docs/assets/webui-edit-ja-light.png b/docs/assets/webui-edit-ja-light.png
index 7e92cad..2a340f6 100644
Binary files a/docs/assets/webui-edit-ja-light.png and b/docs/assets/webui-edit-ja-light.png differ
diff --git a/docs/assets/webui-edit-zh-dark.png b/docs/assets/webui-edit-zh-dark.png
index 27a82c8..92fb727 100644
Binary files a/docs/assets/webui-edit-zh-dark.png and b/docs/assets/webui-edit-zh-dark.png differ
diff --git a/docs/assets/webui-edit-zh-light.png b/docs/assets/webui-edit-zh-light.png
index 13ba5ea..dd00f89 100644
Binary files a/docs/assets/webui-edit-zh-light.png and b/docs/assets/webui-edit-zh-light.png differ
diff --git a/docs/assets/webui-generate-en-dark.png b/docs/assets/webui-generate-en-dark.png
index 6ca78a9..0e8f909 100644
Binary files a/docs/assets/webui-generate-en-dark.png and b/docs/assets/webui-generate-en-dark.png differ
diff --git a/docs/assets/webui-generate-en-light.png b/docs/assets/webui-generate-en-light.png
index 5d5c2d6..fc7d3f6 100644
Binary files a/docs/assets/webui-generate-en-light.png and b/docs/assets/webui-generate-en-light.png differ
diff --git a/docs/assets/webui-generate-ja-dark.png b/docs/assets/webui-generate-ja-dark.png
index fb3b3e4..9a563a3 100644
Binary files a/docs/assets/webui-generate-ja-dark.png and b/docs/assets/webui-generate-ja-dark.png differ
diff --git a/docs/assets/webui-generate-ja-light.png b/docs/assets/webui-generate-ja-light.png
index ec3a27f..b4790c1 100644
Binary files a/docs/assets/webui-generate-ja-light.png and b/docs/assets/webui-generate-ja-light.png differ
diff --git a/docs/assets/webui-generate-zh-dark.png b/docs/assets/webui-generate-zh-dark.png
index 5b2e28a..7642d52 100644
Binary files a/docs/assets/webui-generate-zh-dark.png and b/docs/assets/webui-generate-zh-dark.png differ
diff --git a/docs/assets/webui-generate-zh-light.png b/docs/assets/webui-generate-zh-light.png
index 08d4eee..ad7bd6e 100644
Binary files a/docs/assets/webui-generate-zh-light.png and b/docs/assets/webui-generate-zh-light.png differ
diff --git a/src/audio_studio_mcp/static/app.css b/src/audio_studio_mcp/static/app.css
index ba193a3..4a419b9 100644
--- a/src/audio_studio_mcp/static/app.css
+++ b/src/audio_studio_mcp/static/app.css
@@ -179,8 +179,8 @@ select {
.link-btn:disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; }
/* layout */
-#page-generate { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 24px; align-items: start; }
-@media (max-width: 900px) { #page-generate { grid-template-columns: 1fr; } }
+#page-generate { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 24px; align-items: start; }
+@media (max-width: 900px) { #page-generate { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.form { padding: 20px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }
.panel-title { font-size: 20px; letter-spacing: -0.01em; }
@@ -194,6 +194,10 @@ select {
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-weight: 600; font-size: 13px; padding: 0; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
+/* No one-character last lines ("す。"): balance short help texts, and break
+ Japanese at phrase boundaries where the browser can. */
+.hint, .note, .mode-desc, .summary, .empty-state p, .tip { text-wrap: pretty; }
+:lang(ja) :is(.hint, .note, .mode-desc, .summary, .empty-state p, .tip) { word-break: auto-phrase; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; align-items: end; }
/* segmented control: a grey track, the chosen option a raised white key */
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--active); }
@@ -257,7 +261,10 @@ input.num { width: 96px; flex: none; font-variant-numeric: tabular-nums; }
.recent-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.job-head { display: flex; gap: 10px; align-items: flex-start; }
-.job-prompt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
+.job-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
+.job-prompt { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
+.job-text:has(.job-sub) .job-prompt { font-weight: 600; } /* the user's title, the prompt under it */
+.job-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-state { font-size: 12px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.job[data-status="error"] .job-state { color: var(--danger); }
.job[data-status="done"] .job-state { color: var(--ok); }
@@ -288,6 +295,20 @@ kbd {
.cand-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.cand-head strong { font-weight: 600; font-size: 13px; }
.cand-actions, .item-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
+/* Edit page results: one row per sound (original, then A, B, …) so any number
+ of versions line up in the narrower column and the original, which has no
+ actions, simply lets its waveform run to the end of the row. */
+#edit-jobs .candidates { grid-template-columns: 1fr; gap: 8px; }
+#edit-jobs .cand, #edit-jobs .orig { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 12px; }
+#edit-jobs .orig .mini-wave { grid-column: 2 / -1; }
+#edit-jobs .cand { border: 1px solid transparent; } /* same inset as the original's dashed edge */
+#edit-jobs .cand-actions { flex-wrap: nowrap; }
+#edit-jobs { container-type: inline-size; }
+@container (max-width: 540px) { /* a narrow results column: label, waveform and actions stack */
+ #edit-jobs .cand, #edit-jobs .orig { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; }
+ #edit-jobs .orig .mini-wave { grid-column: auto; }
+ #edit-jobs .cand-actions { flex-wrap: wrap; }
+}
.job-foot { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.job-steps { margin: 0; }
@@ -423,8 +444,8 @@ mark { background: var(--sel-bg); color: inherit; border-radius: 2px; }
position: absolute; right: 0; top: 100%; z-index: 5; margin: 6px 0 0; max-width: 520px; padding: 10px 12px;
background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); color: var(--text);
}
-.edit-body { display: grid; grid-template-columns: minmax(340px, 480px) 1fr; gap: 24px; align-items: start; margin-top: 24px; }
-@media (max-width: 900px) { .edit-body { grid-template-columns: 1fr; } }
+.edit-body { display: grid; grid-template-columns: minmax(340px, 480px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 24px; }
+@media (max-width: 900px) { .edit-body { grid-template-columns: minmax(0, 1fr); } }
.edit-tools { overflow: visible; }
.subtabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.subtabs button {
diff --git a/src/audio_studio_mcp/static/app.js b/src/audio_studio_mcp/static/app.js
index 41c86f4..7de5119 100644
--- a/src/audio_studio_mcp/static/app.js
+++ b/src/audio_studio_mcp/static/app.js
@@ -490,7 +490,12 @@ function jobTitle(job) {
if (a.mode === "continue") return t("edit.jobContinue", { len: a.duration_seconds ? `${a.duration_seconds} s` : "—" });
return t(`mode.${a.mode}`);
}
- return promptLabel(a) || "—";
+ return (a.title && a.title.trim()) || promptLabel(a) || "—";
+}
+// Under a titled result: the prompt it was made from.
+function jobSubtitle(job) {
+ const a = job.arguments || {};
+ return job.tool === "generate_audio" && a.title && a.title.trim() ? promptLabel(a) : "";
}
// Full detail for the title tooltip: the prompt, the input, the processing steps.
function jobDetail(job) {
@@ -546,7 +551,9 @@ function jobCard(job) {
const active = job.status === "queued" || job.status === "running";
const head = el("div", { class: "job-head" },
el("span", { class: "badge", text: jobBadge(job) }),
- el("span", { class: "job-prompt", title: jobDetail(job), text: jobTitle(job) }),
+ el("div", { class: "job-text", title: jobDetail(job) },
+ el("span", { class: "job-prompt", text: jobTitle(job) }),
+ jobSubtitle(job) ? el("span", { class: "job-sub", text: jobSubtitle(job) }) : null),
el("span", { class: "job-state" }, active ? el("span", { class: "spinner", "aria-hidden": "true" }) : null,
el("span", { class: "job-state-text", text: jobStateText(job) })));
const card = el("article", { class: "panel job", dataset: { status: job.status, id: job.id, tool: job.tool }, onkeydown: (e) => abKeys(e, card) }, head);
@@ -848,7 +855,41 @@ function initLibrary() {
});
}
+// Description boxes grow with their text (up to 40% of the window) so a long
+// prompt is never cut off. Values are also set from code (examples, reuse,
+// opening a sound), so the value setter refits too; a width change (window,
+// a page becoming visible) refits through the ResizeObserver.
+function fitTextarea(ta) {
+ if (!ta.offsetWidth) return; // hidden: refit when it gets a width
+ const cs = getComputedStyle(ta);
+ ta.style.height = "auto";
+ const h = ta.scrollHeight + parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth);
+ ta.style.height = `${Math.ceil(Math.min(h, window.innerHeight * 0.4))}px`;
+}
+function initAutoGrow() {
+ const value = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value");
+ const widths = new WeakMap();
+ const ro = new ResizeObserver((entries) => {
+ for (const { target } of entries) {
+ if (widths.get(target) === target.offsetWidth) continue; // our own height change
+ widths.set(target, target.offsetWidth);
+ fitTextarea(target);
+ }
+ });
+ for (const ta of document.querySelectorAll("textarea")) {
+ Object.defineProperty(ta, "value", {
+ configurable: true, get() { return value.get.call(this); },
+ set(v) { value.set.call(this, v); fitTextarea(this); },
+ });
+ ta.addEventListener("input", () => fitTextarea(ta));
+ ta.form && ta.form.addEventListener("reset", () => setTimeout(() => fitTextarea(ta)));
+ ro.observe(ta);
+ }
+ document.fonts.ready.then(() => document.querySelectorAll("textarea").forEach(fitTextarea));
+}
+
// ── boot ─────────────────────────────────────────────────────────────────────
+initAutoGrow();
Player.init();
initSettings();
initForm();
diff --git a/src/audio_studio_mcp/static/editor.js b/src/audio_studio_mcp/static/editor.js
index 4eaf768..224af2c 100644
--- a/src/audio_studio_mcp/static/editor.js
+++ b/src/audio_studio_mcp/static/editor.js
@@ -350,6 +350,7 @@ const Editor = {
this.audio.loop = $("#w-loop").checked && !sel;
if (!!sel !== had) $("#x-trim-sel").checked = !!sel; // a new selection is usually what to export
this.renderSelection(quiet);
+ this.renderTransport(); // "Play" ↔ "Play selection"
this.draw();
this.updateAiForm();
this.updateExportForm();
diff --git a/src/audio_studio_mcp/static/i18n.js b/src/audio_studio_mcp/static/i18n.js
index 762d913..4ae80c8 100644
--- a/src/audio_studio_mcp/static/i18n.js
+++ b/src/audio_studio_mcp/static/i18n.js
@@ -3,7 +3,7 @@ window.I18N = {
en: {
"settings.theme": "Theme", "settings.light": "Light", "settings.system": "Follow the system", "settings.dark": "Dark",
"nav.generate": "Generate", "nav.edit": "Edit & export", "nav.library": "Library",
- "task.title": "What do you want to do with this sound?", "task.export": "Export", "task.exportDesc": "For a game or video: format, volume, loop", "task.scope.whole": "Whole sound", "task.scope.sel": "Uses your selection", "task.scope.end": "Adds to the end", "task.scope.either": "Whole sound or selection", "wave.dragHint": "Drag across the waveform to choose the part to replace", "wave.region.inpaint": "Will be replaced", "wave.region.export": "Will be exported", "wave.wholeNote": "The whole sound is used", "wave.ghost": "+{len} new", "wave.shortcuts": "Keyboard shortcuts", "act.export": "Export", "act.downloadWav": "Download original WAV", "act.reuse": "Reuse settings", "cand.original": "Original", "cand.abHintOrig": "Compare: press 1–4 for the new versions, 0 for the original, at the same moment", "jobs.nextHint": "Pick the version you like, then Edit it or Export it for your game or video.", "jobs.gotIt": "Got it", "exp.submitLen": "Export {len} as {fmt}", "edit.jobInpaint": "Replace {range}", "edit.jobContinue": "Extend to {len}", "gen.durationAuto": "Auto ({def} s)", "gen.durationOther": "Other",
+ "task.title": "What do you want to do with this sound?", "task.export": "Export", "task.exportDesc": "Format and volume for game or video", "task.scope.whole": "Whole sound", "task.scope.sel": "Uses your selection", "task.scope.end": "Adds to the end", "task.scope.either": "Whole sound or selection", "wave.dragHint": "Drag across the waveform to choose the part to replace", "wave.region.inpaint": "Will be replaced", "wave.region.export": "Will be exported", "wave.wholeNote": "The whole sound is used", "wave.ghost": "+{len} new", "wave.shortcuts": "Keyboard shortcuts", "act.export": "Export", "act.downloadWav": "Download original WAV", "act.reuse": "Reuse settings", "cand.original": "Original", "cand.abHintOrig": "Compare: press 1–4 for the new versions, 0 for the original, at the same moment", "jobs.nextHint": "Pick the version you like, then Edit it or Export it for your game or video.", "jobs.gotIt": "Got it", "exp.submitLen": "Export {len} as {fmt}", "edit.jobInpaint": "Replace {range}", "edit.jobContinue": "Extend to {len}", "gen.durationAuto": "Auto ({def} s)", "gen.durationOther": "Other",
"status.unload": "Unload model", "status.unloadHint": "Frees the 5–7 GB the model uses. It loads again on the next generation.",
"status.loaded": "Model ready", "status.notLoaded": "Model loads on first use", "status.working": "Working",
"status.offline": "Server unreachable", "status.unloaded": "Model unloaded, memory freed",
@@ -82,7 +82,7 @@ window.I18N = {
"edit.unreadable": "{file} can't be read as audio (damaged or unsupported).",
"edit.mono": "mono", "edit.stereo": "stereo", "edit.madeFrom": "Made from",
"edit.aiTab": "Change with AI", "edit.exportTab": "Export", "edit.mode": "What to do",
- "mode.variation": "Make a variation", "mode.variationDesc": "Same idea, new take on the whole sound",
+ "mode.variation": "Make a variation", "mode.variationDesc": "A new take on the whole sound",
"mode.inpaint": "Replace a section", "mode.inpaintDesc": "Regenerate only the selected part",
"mode.continue": "Extend", "mode.continueDesc": "Make it longer, in the same style",
"edit.strength": "How different?", "edit.subtle": "Close to the original", "edit.loose": "Very different",
@@ -151,7 +151,7 @@ window.I18N = {
ja: {
"settings.theme": "テーマ", "settings.light": "ライト", "settings.system": "システムに合わせる", "settings.dark": "ダーク",
"nav.generate": "生成", "nav.edit": "編集・書き出し", "nav.library": "ライブラリ",
- "task.title": "この音をどうしますか?", "task.export": "書き出し", "task.exportDesc": "ゲーム・動画向けに形式・音量・ループを整える", "task.scope.whole": "音全体", "task.scope.sel": "選択範囲を使う", "task.scope.end": "末尾に追加", "task.scope.either": "全体または選択範囲", "wave.dragHint": "差し替える部分を波形の上でドラッグして選んでください", "wave.region.inpaint": "ここを差し替え", "wave.region.export": "書き出す範囲", "wave.wholeNote": "音全体が対象です", "wave.ghost": "+{len} 追加", "wave.shortcuts": "キーボード操作", "act.export": "書き出し", "act.downloadWav": "元の WAV をダウンロード", "act.reuse": "この設定を使う", "cand.original": "元の音", "cand.abHintOrig": "聴き比べ:1〜4 キーで新しいバージョン、0 で元の音(同じ位置のまま)", "jobs.nextHint": "気に入ったバージョンを選んで「編集」か「書き出し」へ。", "jobs.gotIt": "OK", "exp.submitLen": "{len} を {fmt} で書き出し", "edit.jobInpaint": "{range} を差し替え", "edit.jobContinue": "{len} に延長", "gen.durationAuto": "おまかせ({def} 秒)", "gen.durationOther": "その他",
+ "task.title": "この音をどうしますか?", "task.export": "書き出し", "task.exportDesc": "ゲーム・動画用に形式や音量を整える", "task.scope.whole": "音全体", "task.scope.sel": "選択範囲を使う", "task.scope.end": "末尾に追加", "task.scope.either": "全体または選択範囲", "wave.dragHint": "差し替える部分を波形の上でドラッグして選んでください", "wave.region.inpaint": "ここを差し替え", "wave.region.export": "書き出す範囲", "wave.wholeNote": "音全体が対象です", "wave.ghost": "+{len} 追加", "wave.shortcuts": "キーボード操作", "act.export": "書き出し", "act.downloadWav": "元の WAV をダウンロード", "act.reuse": "この設定を使う", "cand.original": "元の音", "cand.abHintOrig": "聴き比べ:1〜4 キーで新しいバージョン、0 で元の音(同じ位置のまま)", "jobs.nextHint": "気に入ったバージョンを選んで「編集」か「書き出し」へ。", "jobs.gotIt": "OK", "exp.submitLen": "{len} を {fmt} で書き出し", "edit.jobInpaint": "{range} を差し替え", "edit.jobContinue": "{len} に延長", "gen.durationAuto": "おまかせ({def} 秒)", "gen.durationOther": "その他",
"status.unload": "モデルを解放", "status.unloadHint": "モデルが使っている 5〜7 GB のメモリを解放します。次の生成でまた読み込みます。",
"status.loaded": "モデル準備完了", "status.notLoaded": "初回の生成時にモデルを読み込みます", "status.working": "処理中",
"status.offline": "サーバーに接続できません", "status.unloaded": "モデルをアンロードしてメモリを解放しました",
@@ -239,7 +239,7 @@ window.I18N = {
"edit.atMax": "この音はすでに最大の長さ({max} 秒)です。",
"edit.prompt": "説明(英語)",
"edit.promptHint.variation": "結果を説明します。同じ雰囲気ならそのまま、変えたいなら書き換えます(例:別の楽器)。",
- "edit.promptHint.inpaint": "選択部分をどんな音にするか。説明文より前後の音の影響が大きくなります。",
+ "edit.promptHint.inpaint": "選択部分の音を説明します。前後の音の影響を強く受けます。",
"edit.promptHint.continue": "任意。そのままなら同じ雰囲気で続けます。",
"edit.inpaintSel": "{range} を作り直し、それ以外はそのまま残します。コツ:少し広めに選ぶと自然につながります。",
"edit.inpaintNoSel": "波形をドラッグして、差し替える部分を選択してください。",
@@ -386,7 +386,7 @@ window.I18N = {
"edit.extendHint": "当前 {now},最长 {max} 秒。",
"edit.atMax": "这个声音已经是最大时长({max} 秒)。",
"edit.prompt": "描述(英文)",
- "edit.promptHint.variation": "描述想要的结果。保持原文则风格不变,改写则会变化(例如换一种乐器)。",
+ "edit.promptHint.variation": "描述想要的结果。保持原文则风格不变,改写可以换成别的乐器等。",
"edit.promptHint.inpaint": "选中的部分应该是什么声音?前后的音频比文字影响更大。",
"edit.promptHint.continue": "可选。保持不变则按原风格继续。",
"edit.inpaintSel": "重新生成 {range},其余部分保持不变。提示:选得稍宽一些衔接更自然。",
diff --git a/src/audio_studio_mcp/static/index.html b/src/audio_studio_mcp/static/index.html
index 5e4a5fa..8f06ec3 100644
--- a/src/audio_studio_mcp/static/index.html
+++ b/src/audio_studio_mcp/static/index.html
@@ -263,7 +263,7 @@
<div class="field">
<label for="ai-prompt" id="ai-prompt-label" data-i18n="edit.prompt">Description (English)</label>
- <textarea id="ai-prompt" name="prompt" rows="2" spellcheck="false"></textarea>
+ <textarea id="ai-prompt" name="prompt" rows="3" spellcheck="false"></textarea>
<p class="hint" id="ai-prompt-hint"></p>
</div>
diff --git a/tests/test_webui_browser.py b/tests/test_webui_browser.py
index 9e141e6..e653f41 100644
--- a/tests/test_webui_browser.py
+++ b/tests/test_webui_browser.py
@@ -57,6 +57,44 @@ CONTRAST_JS = r"""
KEYS_JS = r"""() => [...document.querySelectorAll("body *")].filter((n) => n.children.length === 0
&& /^[a-z]+\.[a-zA-Z.]+$/.test(n.textContent.trim()) && !n.closest("[hidden]")).map((n) => n.textContent.trim())"""
+# Help texts whose last line is one or two characters ("す。"), and task cards
+# whose description wraps (that makes the whole row of cards taller).
+ORPHANS_JS = r"""
+() => {
+ const lineTexts = (el) => {
+ const chars = [];
+ const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
+ while (walker.nextNode()) {
+ const n = walker.currentNode;
+ for (let i = 0; i < n.length; i++) {
+ if (/\s/.test(n.data[i])) continue;
+ const r = document.createRange(); r.setStart(n, i); r.setEnd(n, i + 1);
+ const b = r.getBoundingClientRect();
+ if (b.width) chars.push([b.top + b.height / 2, n.data[i]]);
+ }
+ }
+ const lines = [];
+ for (const [y, c] of chars) {
+ const last = lines[lines.length - 1];
+ if (last && Math.abs(last.y - y) < 4) last.text += c; else lines.push({ y, text: c });
+ }
+ return lines.map((l) => l.text);
+ };
+ const out = [];
+ const blocks = "p, .hint, .note, .mode-desc, .mode-scope, .summary, .tip > span, .job-foot > span, .range-labels > span, label, legend, h1, h2, .task-title, .empty-title, .steps li span";
+ for (const el of document.querySelectorAll(blocks)) {
+ if (!el.offsetWidth || el.closest("[hidden]") || el.closest(".item, .job") && !el.closest(".job-foot")) continue;
+ if ([...el.querySelectorAll(blocks)].length) continue; // check the innermost block
+ const lines = lineTexts(el);
+ if (lines.length < 2) continue;
+ if (el.matches(".mode-desc")) out.push({ kind: "wrapped-task", text: el.textContent.trim() });
+ const tail = lines[lines.length - 1].replace(/[。、..,!?!?」』))…::]/g, "");
+ if ([...tail].length <= 2) out.push({ kind: "orphan", text: el.textContent.trim() });
+ }
+ return out;
+}
+"""
+
def _free_port() -> int:
with socket.socket() as s:
@@ -278,6 +316,7 @@ def test_editor_flow(web, browser, shots):
page.fill("#w-end", "3")
page.press("#w-end", "Enter")
assert page.evaluate("Editor.sel") == {"a": 1.5, "b": 3}
+ assert page.text_content("#w-play-text") == "Play selection" # without touching the waveform
page.click("#ai-submit")
page.wait_for_selector("#edit-jobs .job[data-status=done]", timeout=15000)
job = page.evaluate("[...state.jobs.values()].find(j => j.tool === 'edit_audio')")
@@ -361,6 +400,7 @@ def test_editor_flow(web, browser, shots):
page.click("#w-wave")
page.keyboard.press("Escape")
assert page.evaluate("Editor.sel") is None
+ assert page.text_content("#w-play-text") == "Play"
_drag(page, "#w-wave", 0.6, 0.6) # a click, not a drag
assert page.evaluate("Editor.playhead") == pytest.approx(2.4, abs=0.05)
page.keyboard.press("Space")
@@ -499,3 +539,83 @@ def test_jobs_queued_while_polling_are_not_lost(web, browser):
statuses = page.evaluate("[...state.jobs.values()].filter((j) => (j.arguments.prompt || '').startsWith('race')).map((j) => j.status)")
assert statuses == ["done"] * 5, statuses
assert not errors, errors
+
+
+def test_layout_polish(web, browser, shots):
+ """Titles on results, prompts never cut off, edit results in rows, no
+ one-character last lines or wrapped task cards in any language."""
+ errors: list[str] = []
+ page = _page(browser, web, "ja", "light", errors)
+ page.wait_for_selector("#examples .chip")
+ page.fill("#prompt", "untitled hum")
+ page.fill("#duration_seconds", "1")
+ page.click("#gen-form label:has(input[name=variations][value='1'])")
+ page.click("#gen-submit")
+ page.locator("#examples .chip").first.click() # the long lo-fi example
+ page.fill("#duration_seconds", "3")
+ page.click("#advanced summary")
+ page.fill("#title", "雨の夜のカフェ")
+ page.click("#gen-submit")
+ card = page.locator("#jobs .job[data-status=done]", has_text="雨の夜のカフェ")
+ card.wait_for(timeout=15000)
+ assert card.locator(".job-prompt").text_content() == "雨の夜のカフェ"
+ assert card.locator(".job-sub").text_content().startswith("Lo-fi hip-hop")
+ # untitled results keep the prompt as their heading, without a subtitle
+ page.wait_for_selector("#jobs .job[data-status=done] >> text=untitled hum")
+ untitled = page.evaluate("""[...document.querySelectorAll('#jobs .job')].filter((n) => !state.jobs.get(n.dataset.id).arguments.title)
+ .map((n) => n.querySelectorAll('.job-sub').length)""")
+ assert untitled and not any(untitled)
+ for width in (1280, 1000, 800): # the one-line prompt under the title never widens the page
+ page.set_viewport_size({"width": width, "height": 900})
+ assert page.evaluate("document.documentElement.scrollWidth <= innerWidth"), width
+ page.set_viewport_size({"width": 1360, "height": 900})
+ fits = "(sel) => { const t = document.querySelector(sel); return t.scrollHeight <= t.clientHeight + 1; }"
+ assert page.evaluate(fits, "#prompt")
+
+ card.locator(".cand-actions button").first.click()
+ page.wait_for_selector("#w-loading", state="hidden")
+ assert page.input_value("#ai-prompt").startswith("Lo-fi hip-hop")
+ assert page.evaluate(fits, "#ai-prompt"), "edit description is cut off"
+ page.fill("#ai-prompt", "x " * 400) # very long text: grows only up to a limit
+ assert page.evaluate("document.querySelector('#ai-prompt').offsetHeight <= innerHeight * 0.4 + 1")
+ page.click("label.mode-card:has(input[value=variation])")
+ page.click("#ai-form label:has(input[name=variations][value='3'])")
+ page.fill("#ai-prompt", "rain")
+ page.click("#ai-submit")
+ page.wait_for_selector("#edit-jobs .job[data-status=done]", timeout=15000)
+ # original + A, B, C: one row each, waveforms starting at the same x
+ rows = page.evaluate("""[...document.querySelectorAll('#edit-jobs .job:first-child :is(.orig, .cand)')].map((n) => {
+ const r = n.getBoundingClientRect(), w = n.querySelector('.mini-wave-track').getBoundingClientRect();
+ return { top: r.top, left: r.left, width: r.width, wave: w.left }; })""")
+ assert len(rows) == 4
+ assert all(b["top"] > a["top"] for a, b in zip(rows, rows[1:]))
+ assert len({round(r["left"]) for r in rows}) == 1 and len({round(r["width"]) for r in rows}) == 1
+ assert len({round(r["wave"]) for r in rows}) == 1
+ page.screenshot(path=str(shots / "layout-edit-ja.png"), full_page=True)
+ # in a narrow results column (two-column page just above 900 px, or a phone) nothing overlaps
+ for width in (920, 1000, 600, 390):
+ page.set_viewport_size({"width": width, "height": 900})
+ assert page.evaluate("document.documentElement.scrollWidth <= innerWidth"), width
+ overlap = page.evaluate("""[...document.querySelectorAll('#edit-jobs .cand')].some((n) => {
+ const w = n.querySelector('.mini-wave-track').getBoundingClientRect(), tm = n.querySelector('.mini-time').getBoundingClientRect();
+ const a = n.querySelector('.cand-actions').getBoundingClientRect();
+ return w.width < 80 || (tm.right > a.left + 1 && tm.bottom > a.top + 1); })""")
+ assert not overlap, width
+ page.set_viewport_size({"width": 1360, "height": 900})
+
+ if sys.platform != "darwin": # line breaks depend on the installed CJK fonts; checked on macOS
+ return
+
+ for lang in LANGS:
+ page.select_option("#lang", lang)
+ for width in (1280, 1440):
+ page.set_viewport_size({"width": width, "height": 900})
+ for mode in ("variation", "inpaint", "continue"):
+ page.click(f"label.mode-card:has(input[value={mode}])")
+ page.evaluate("Editor.setSel({ a: 0.5, b: 1.5 })")
+ bad = page.evaluate(ORPHANS_JS)
+ assert not bad, f"{lang} {width} {mode}: {bad}"
+ page.click("#st-export")
+ assert not page.evaluate(ORPHANS_JS), f"{lang} {width} export"
+ page.select_option("#lang", "auto")
+ assert not errors, errors