Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(forge): ship the prompt coach's first message inline so the composer stops jumping

nirholasa00bc8045a15
diff --git a/pages/forge.html b/pages/forge.html
index e326f2070..4841610cd 100644
--- a/pages/forge.html
+++ b/pages/forge.html
@@ -3473,7 +3473,17 @@
</svg>
Surprise me
</button>
- <span class="prompt-coach" id="prompt-coach" data-grade="tip" aria-live="polite"></span>
+ <!-- Ships the exact message grade('') writes for an empty prompt, so
+ .prompt-tools is its settled height in the first frame. It used
+ to ship empty at min-height:1.2em and grow when updateCoach()
+ ran, wrapping the coach onto its own line in this flex-wrap row
+ and pushing the quality tiles, the composer and the example
+ chips down with it: 38px at desktop widths, measured against
+ production. tests/forge-prompt-coach.test.js reads this file and
+ src/forge-prompt-studio.js so the two copies cannot drift.
+ data-no-i18n because the text becomes dynamic the moment anyone
+ types (docs/site-performance.md rule 6). -->
+ <span class="prompt-coach" id="prompt-coach" data-grade="tip" aria-live="polite" data-no-i18n>Name one object and a material, e.g. “a brass compass, weathered”.</span>
<span class="prompt-count" id="prompt-count">0 / 1000</span>
</div>
</div>
diff --git a/src/forge-prompt-studio.js b/src/forge-prompt-studio.js
index d375d7bff..f07fdd3fe 100644
--- a/src/forge-prompt-studio.js
+++ b/src/forge-prompt-studio.js
@@ -131,7 +131,7 @@ function grade(raw) {
if (!text) {
return {
grade: 'tip',
- msg: 'Name one object and a material — e.g. “a brass compass, weathered”.',
+ msg: 'Name one object and a material, e.g. “a brass compass, weathered”.',
};
}
if (words < 2) {
diff --git a/tests/forge-prompt-coach.test.js b/tests/forge-prompt-coach.test.js
new file mode 100644
index 000000000..471292371
--- /dev/null
+++ b/tests/forge-prompt-coach.test.js
@@ -0,0 +1,65 @@
+/**
+ * The forge composer's prompt coach ships its settled message in the HTML.
+ *
+ * `.prompt-tools` is a flex-wrap row holding the Surprise button, the coach and
+ * the character counter. The coach used to ship EMPTY, and `updateCoach()` wrote
+ * grade('')'s message into it once the module ran. At desktop widths that text
+ * does not fit beside its neighbours, so the row wrapped onto a second line and
+ * grew 38px, pushing the quality tiles, the composer and the example-prompt row
+ * down with it. Measured against production on 2026-09-08, /forge's CLS was
+ * 0.2523 on a Pixel 5, and the growth of the containers above `#examples` is
+ * what moves it (see docs/site-performance.md).
+ *
+ * Shipping the settled text is only a fix while the two copies agree. This test
+ * reads them both out of their own files rather than restating either, so
+ * editing one without the other fails here instead of silently restoring the
+ * shift.
+ */
+
+import { describe, it, expect } from 'vitest';
+import { readFileSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
+const HTML = readFileSync(join(ROOT, 'pages/forge.html'), 'utf8');
+const STUDIO = readFileSync(join(ROOT, 'src/forge-prompt-studio.js'), 'utf8');
+
+// The message grade() returns for an empty prompt: the first `msg:` after the
+// `if (!text)` branch.
+function emptyPromptMessage() {
+ const branch = STUDIO.indexOf('if (!text) {');
+ expect(branch).toBeGreaterThan(-1);
+ const msg = /msg:\s*'((?:[^'\\]|\\.)*)'/.exec(STUDIO.slice(branch));
+ expect(msg).not.toBeNull();
+ return msg[1];
+}
+
+function shippedCoachText() {
+ const el = /<span class="prompt-coach"[^>]*>([\s\S]*?)<\/span>/.exec(HTML);
+ expect(el).not.toBeNull();
+ return el[1].trim();
+}
+
+describe('forge prompt coach reserves its own row', () => {
+ it('ships the message rather than an empty span', () => {
+ expect(shippedCoachText().length).toBeGreaterThan(20);
+ });
+
+ it('ships exactly what grade("") writes, so the swap moves nothing', () => {
+ expect(shippedCoachText()).toBe(emptyPromptMessage());
+ });
+
+ it('carries the grade the empty state renders with', () => {
+ const tag = /<span class="prompt-coach"[^>]*>/.exec(HTML)[0];
+ expect(tag).toContain(`data-grade="tip"`);
+ });
+
+ it('opts out of i18n, because the text becomes dynamic on the first keystroke', () => {
+ // docs/site-performance.md rule 6: a node whose text a script owns cannot
+ // also carry a catalog key, or the catalog pass reverts it.
+ const tag = /<span class="prompt-coach"[^>]*>/.exec(HTML)[0];
+ expect(tag).toContain('data-no-i18n');
+ expect(tag).not.toContain('data-i18n=');
+ });
+});