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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(forge): ask what each model is for and record when it finished
qhqf14f008af7b55
diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.jsindex eeca9ff87..19869046c 100644--- a/api/_lib/forge-store.js+++ b/api/_lib/forge-store.js@@ -14,6 +14,7 @@// back to returning the raw provider URL. Persistence is a bonus, never a gate.import { createHash } from 'node:crypto';+import { AsyncLocalStorage } from 'node:async_hooks';import { randomUUID } from 'node:crypto';import { sql, isDbUnavailableError } from './db.js';import { databaseConfigured } from './env.js';@@ -29,6 +30,7 @@ import { fetchUpstream } from './upstream-fetch.js';import { gradeSimReadiness } from './sim-readiness.js';import { putGrade } from './sim-readiness-store.js';import { dispatchWebhooks } from './webhook-dispatch.js';+import { validForgeDestination } from '../../src/shared/forge-destinations.js';// Stable, non-secret salt so a leaked DB row can't be trivially reversed to the// raw browser-local id. The id is anonymous to begin with; this is hygiene, not@@ -123,6 +125,31 @@ export async function attachX402Provenance({ replicateJobId, clientKey, payer, t}}+// Request-scoped facts every row written during one request should carry.+//+// A single /api/forge request can insert a row from any of a dozen branches+// (primary submit, each failover hop, the cache-hit path, the sync lanes), and+// threading a new field through every one of them is how a field ends up set on+// nine branches and silently null on the tenth. The handler states the fact+// once, here, and createCreation reads it, so no branch can forget it.+const creationContext = new AsyncLocalStorage();++/**+ * Run `fn` with request-scoped creation facts. `destination` is validated here,+ * so callers pass the raw request value. `internal` marks platform-generated+ * rows (catalog seeder, quality benchmark) so the funnel report can leave them out.+ * @template T+ * @param {{ destination?: unknown, internal?: boolean }} facts+ * @param {() => T} fn+ * @returns {T}+ */+export function runWithCreationContext({ destination, internal = false } = {}, fn) {+ return creationContext.run(+ { destination: validForgeDestination(destination), internal: internal === true },+ fn,+ );+}+export async function createCreation({clientKey,ipHash,@@ -146,9 +173,18 @@ export async function createCreation({// reference view on every non-multiview lane, so callers that pass nothing// still get their upload tracked.sourceImageUrls = null,+ // What the maker is building for (src/shared/forge-destinations.js). An+ // explicit value wins; otherwise the request-scoped one the handler set.+ destination,+ // Platform-generated row (seeder, benchmark). Only failover successors pass+ // it, to inherit the original's flag; a fresh submit takes it from the context.+ internal,}) {if (!forgeStoreEnabled()) return null;const id = randomUUID();+ const ctx = creationContext.getStore();+ const nextDestination = validForgeDestination(destination) ?? ctx?.destination ?? null;+ const isInternal = typeof internal === 'boolean' ? internal : ctx?.internal === true;// An explicit category (from the studio picker) always wins; otherwise infer// it from the prompt so the model gets a real category at birth instead of// defaulting to 'other' and leaving the category dimension dead.@@ -162,14 +198,14 @@ export async function createCreation({(id, client_key, ip_hash, prompt, aspect, preview_image_url,replicate_job_id, text_to_image_model, views_requested, views_used,multiview, backend, tier, path, status, outcome, model_category, user_id,- source_image_keys)+ source_image_keys, destination, internal)values(${id}, ${clientKey}, ${ipHash ?? null}, ${prompt}, ${aspect ?? null},${previewImageUrl ?? null}, ${replicateJobId ?? null},${textToImageModel ?? null}, ${viewsRequested ?? null}, ${viewsUsed ?? null},${typeof multiview === 'boolean' ? multiview : null}, ${backend ?? null},${tier ?? null}, ${path ?? null}, 'generating', 'generated', ${category}, ${userId ?? null},- ${sourceKeys ? JSON.stringify(sourceKeys) : null})+ ${sourceKeys ? JSON.stringify(sourceKeys) : null}, ${nextDestination}, ${isInternal})`;// Funnel start — counts attempts so the health rollup can show how many// generations began vs. completed. Best-effort; never blocks the insert.@@ -248,7 +284,7 @@ export async function findByJob({ replicateJobId, clientKey }) {const rows = await sql`select id, status, glb_url, glb_key, prompt, preview_image_url,views_requested, views_used, multiview, backend, tier, path, model_category,- user_id, created_at+ user_id, created_at, destination, internalfrom forge_creationswhere replicate_job_id = ${replicateJobId} and client_key = ${clientKey}limit 1@@ -591,6 +627,7 @@ export async function materializeCreation({ replicateJobId, clientKey, glbUrl, qpreview_key = ${preview.key},preview_image_url = ${preview.url},size_bytes = ${glb.bytes},+ completed_at = coalesce(completed_at, now()),updated_at = now()where id = ${existing.id} and client_key = ${clientKey}`;@@ -703,7 +740,8 @@ export async function markFailed({ replicateJobId, clientKey, error }) {try {const rows = await sql`update forge_creations- set status = 'failed', error = ${String(error || 'generation failed').slice(0, 500)}, updated_at = now()+ set status = 'failed', error = ${String(error || 'generation failed').slice(0, 500)},+ completed_at = coalesce(completed_at, now()), updated_at = now()where replicate_job_id = ${replicateJobId} and client_key = ${clientKey} and status != 'done'returning backend, tier, path`;@@ -815,15 +853,18 @@ const VALID_OUTCOMES = new Set(['accepted', 'rejected', 'generated']);// Capture the human verdict on a creation. Scoped to the owning client so a// verdict can't be forged for someone else's row. Returns true on a real write.-export async function recordFeedback({ id, clientKey, outcome, downloaded, rating, note }) {+export async function recordFeedback({ id, clientKey, outcome, downloaded, rating, note, destination }) {if (!forgeStoreEnabled() || !id) return false;+ const nextDestination = validForgeDestination(destination);const nextOutcome = VALID_OUTCOMES.has(outcome) ? outcome : null;const nextRating =Number.isInteger(rating) && rating >= 1 && rating <= 5 ? rating : null;const nextNote = typeof note === 'string' && note.trim() ? note.trim().slice(0, 500) : null;const markDownloaded = downloaded === true;// Nothing meaningful to record → don't touch the row.- if (!nextOutcome && nextRating === null && nextNote === null && !markDownloaded) return false;+ if (!nextOutcome && nextRating === null && nextNote === null && !markDownloaded && !nextDestination) {+ return false;+ }try {const rows = await sql`update forge_creations@@ -831,6 +872,7 @@ export async function recordFeedback({ id, clientKey, outcome, downloaded, ratinrating = coalesce(${nextRating}, rating),note = coalesce(${nextNote}, note),downloaded = (downloaded or ${markDownloaded}),+ destination = coalesce(${nextDestination}, destination),feedback_at = now(),updated_at = now()where id = ${id} and client_key = ${clientKey}diff --git a/api/_lib/migrations/20260921120000_forge_destination.sql b/api/_lib/migrations/20260921120000_forge_destination.sqlnew file mode 100644index 000000000..0e351e1b9--- /dev/null+++ b/api/_lib/migrations/20260921120000_forge_destination.sql@@ -0,0 +1,45 @@+-- Forge funnel instrumentation: what a generation is FOR, and when it finished.+--+-- forge_creations already records the verdict on a model (outcome, rating,+-- downloaded), but not the two facts the funnel report needs to turn that+-- verdict into a product decision:+--+-- destination What the maker is building for: game, web, avatar, simulation,+-- print, ar, or play (just exploring). Asked once in the Forge+-- composer and attached to every generation from that browser,+-- or sent as `destination` by an API caller. Without it the+-- acceptance rate is one number for the whole product, and+-- nobody can say which use case the pipeline actually serves.+-- Null means "never asked or never answered", which is every row+-- before this migration; readers report it as its own bucket+-- and never fold it into a real answer.+--+-- completed_at When the row reached a terminal status (done or failed).+-- updated_at cannot stand in for it: a later feedback write, a+-- vote, or the web-delivery backfill all move updated_at, so+-- updated_at - created_at overstates generation time by days.+-- Generation seconds per accepted asset is the physical quantity+-- cost scales with on the self-hosted GPU lanes. Null on rows+-- that finished before this migration; the report counts only+-- rows that carry it and says how many it judged.+--+-- internal True when the platform generated the row itself: the catalog+-- seeder and the weekly quality benchmark both submit through the+-- real /api/forge path (authenticated by the x-forge-seed header)+-- so they exercise what users exercise. No human ever accepts+-- those rows, so left in the funnel they read as thousands of+-- abandoned generations. Historical seeder rows are still+-- excluded through forge_seed_jobs.creation_id; historical+-- benchmark rows cannot be told apart and stay in the pre-+-- migration numbers, which is one reason the report leads with+-- a window that starts after this migration when one is given.+alter table forge_creations+ add column if not exists destination text,+ add column if not exists completed_at timestamptz,+ add column if not exists internal boolean not null default false;++-- The funnel report groups finished rows by destination over a rolling window.+-- Partial on the answered rows so the index stays small while most history is null.+create index if not exists forge_creations_destination_idx+ on forge_creations (destination, created_at desc)+ where destination is not null;diff --git a/api/cron/forge-finalize.js b/api/cron/forge-finalize.jsindex 3ff60913b..9b958743e 100644--- a/api/cron/forge-finalize.js+++ b/api/cron/forge-finalize.js@@ -206,6 +206,8 @@ async function tryCronRedispatch(row, ageMinutes) {backend: nextLane,tier: row.tier,path: row.path,+ destination: row.destination,+ internal: row.internal === true,});await writeCronHop(submitted.extJobId, { hop: hop + 1, attempted });// A late attended poller still holds the original f1 handle. Job tokens@@ -238,7 +240,7 @@ export default wrapCron(async (req, res) => {const rows = await sql`select id, replicate_job_id, client_key, user_id, prompt, preview_image_url,- backend, tier, path, created_at+ backend, tier, path, created_at, destination, internalfrom forge_creationswhere status = 'generating'and replicate_job_id is not nulldiff --git a/api/forge-feedback.js b/api/forge-feedback.jsindex b54abb454..388c614d4 100644--- a/api/forge-feedback.js+++ b/api/forge-feedback.js@@ -1,13 +1,18 @@/*** Forge feedback — capture the human verdict on a generated 3D model.*- * POST /api/forge-feedback { creation_id, outcome?, downloaded?, rating?, note? }+ * POST /api/forge-feedback { creation_id, outcome?, downloaded?, rating?, note?, destination? }** This is the labeled half of the text→3D data flywheel. /forge stores every* (prompt → reference image → mesh) triple; this endpoint attaches whether a* human kept it, threw it away, downloaded it, or rated it — the signal a future* in-house reconstruction model trains and evaluates against.*+ * `destination` is what the model is for (game, web, avatar, simulation, print,+ * ar, play; see src/shared/forge-destinations.js). It is normally sent with the+ * generation request itself; accepting it here lets a maker answer after the+ * fact, on a model they already have. An unrecognised value is ignored.+ ** Auth-free like the rest of /forge: writes are scoped to the anonymous client* key (x-forge-client header) so a verdict can only be recorded against a row* the same browser created. When the store is unconfigured the endpoint returns@@ -48,6 +53,7 @@ export default wrap(async (req, res) => {downloaded: body?.downloaded === true,rating: Number.isInteger(body?.rating) ? body.rating : undefined,note: typeof body?.note === 'string' ? body.note : undefined,+ destination: body?.destination,});// `stored: false` means no row matched this client+id (or nothing to write) —diff --git a/api/forge.js b/api/forge.jsindex ba5621e60..ee9a6f9ff 100644--- a/api/forge.js+++ b/api/forge.js@@ -91,6 +91,7 @@ import {hashClient,hashIp,createCreation,+ runWithCreationContext,materializeCreation,markFailed,markSupersededBy,@@ -1061,9 +1062,20 @@ async function runHfImageLane({return true;}+// Parse the request once, then run the whole submit inside a creation context so+// every row this request writes (primary submit, each failover hop, the sync and+// cache-hit branches) carries the caller's `destination` without each branch+// having to remember to pass it.async function startJob(req, res) {- const ip = clientIp(req);const body = await readJson(req, 8_000).catch(() => null);+ return runWithCreationContext(+ { destination: body?.destination, internal: isInternalSeedRequest(req) },+ () => startJobWithBody(req, res, body),+ );+}++async function startJobWithBody(req, res, body) {+ const ip = clientIp(req);// Two reconstruction modes share this path:// • image→3D: a caller supplies one or more reference views (image_url or@@ -3125,6 +3137,10 @@ async function pollJob(req, res, jobId) {backend: nextLane,tier: meta.tier,path: meta.path,+ // A poll carries no request body, so the successor inherits what+ // the original submit said it was for.+ destination: meta.destination,+ internal: meta.internal === true,});// Report "running" ONLY once the successor is durably chaseable -// otherwise the client would poll a dead handle forever.diff --git a/pages/forge-studio.html b/pages/forge-studio.htmlindex bbf278772..d97faa736 100644--- a/pages/forge-studio.html+++ b/pages/forge-studio.html@@ -1917,6 +1917,29 @@border-color: var(--stroke-strong);color: var(--ink);}+ /* Destination row: shares the category picker's chip styling. */+ .dest-picker-status {+ font-size: var(--text-xs);+ font-family: var(--font-mono);+ color: var(--ink-dim);+ margin-left: auto;+ opacity: 0;+ transition: opacity var(--duration-fast);+ }+ .dest-picker-status.is-visible {+ opacity: 1;+ }+ .forge-cat-btn:active {+ transform: translateY(1px);+ }+ @media (prefers-reduced-motion: reduce) {+ .forge-cat-btn:active {+ transform: none;+ }+ .dest-picker-status {+ transition: none;+ }+ }/* Two-class grouping inside the picker: "Agents" (can get a brain) vs"Items" (objects). Subtle labels + a divider keep it scannable. */.cat-group-label {@@ -3832,6 +3855,25 @@</div></div>+ <!-- Destination: what the model is for. One tap, remembered in this+ browser and sent with every later generation, so the funnel report+ can say which use case Forge actually serves. The chip ids mirror+ src/shared/forge-destinations.js, the list the server validates+ against (tests/forge-funnel.test.js holds the two in step). Static+ markup so the i18n pass localizes it like every other control here.+ Optional and never blocks anything. -->+ <div class="cat-picker dest-picker" id="forge-destination-picker" role="group" aria-labelledby="forge-destination-label" hidden>+ <span class="cat-picker-label" id="forge-destination-label" data-i18n="forge.making_this_for">Making this for:</span>+ <button class="forge-cat-btn" type="button" data-dest="game" aria-pressed="false" title="Unity, Unreal, Godot, a web game" data-i18n="forge.dest_game" data-i18n-attr="title:forge.dest_game_hint">Game</button>+ <button class="forge-cat-btn" type="button" data-dest="web" aria-pressed="false" title="A site, a product page, a 3D embed" data-i18n="forge.dest_web" data-i18n-attr="title:forge.dest_web_hint">Web</button>+ <button class="forge-cat-btn" type="button" data-dest="avatar" aria-pressed="false" title="A character to rig and animate" data-i18n="forge.dest_avatar" data-i18n-attr="title:forge.dest_avatar_hint">Avatar</button>+ <button class="forge-cat-btn" type="button" data-dest="simulation" aria-pressed="false" title="Robotics, physics, synthetic data" data-i18n="forge.dest_simulation" data-i18n-attr="title:forge.dest_simulation_hint">Simulation</button>+ <button class="forge-cat-btn" type="button" data-dest="print" aria-pressed="false" title="A physical 3D print" data-i18n="forge.dest_print" data-i18n-attr="title:forge.dest_print_hint">Print</button>+ <button class="forge-cat-btn" type="button" data-dest="ar" aria-pressed="false" title="Placing it in a real room" data-i18n="forge.dest_ar" data-i18n-attr="title:forge.dest_ar_hint">AR</button>+ <button class="forge-cat-btn" type="button" data-dest="play" aria-pressed="false" title="Exploring what it can do" data-i18n="forge.dest_play" data-i18n-attr="title:forge.dest_play_hint">Just playing</button>+ <span class="dest-picker-status" id="forge-destination-status" role="status" aria-live="polite" data-saved="Saved. We will remember this for your next models." data-i18n-attr="data-saved:forge.destination_saved"></span>+ </div>+<!-- Category picker — label your model so the gallery and explore feedcan surface it under the right filter. Wired in forge.js via theforge-category-picker id; hidden by default, becomes visible whendiff --git a/pages/forge.html b/pages/forge.htmlindex 44a6f1f74..f7b058f25 100644--- a/pages/forge.html+++ b/pages/forge.html@@ -2216,6 +2216,29 @@border-color: var(--stroke-strong);color: var(--ink);}+ /* Destination row: shares the category picker's chip styling. */+ .dest-picker-status {+ font-size: var(--text-xs);+ font-family: var(--font-mono);+ color: var(--ink-dim);+ margin-left: auto;+ opacity: 0;+ transition: opacity var(--duration-fast);+ }+ .dest-picker-status.is-visible {+ opacity: 1;+ }+ .forge-cat-btn:active {+ transform: translateY(1px);+ }+ @media (prefers-reduced-motion: reduce) {+ .forge-cat-btn:active {+ transform: none;+ }+ .dest-picker-status {+ transition: none;+ }+ }/* Two-class grouping inside the picker: "Agents" (can get a brain) vs"Items" (objects). Subtle labels + a divider keep it scannable. */.cat-group-label {@@ -4089,6 +4112,25 @@</div></details>+ <!-- Destination: what the model is for. One tap, remembered in this+ browser and sent with every later generation, so the funnel report+ can say which use case Forge actually serves. The chip ids mirror+ src/shared/forge-destinations.js, the list the server validates+ against (tests/forge-funnel.test.js holds the two in step). Static+ markup so the i18n pass localizes it like every other control here.+ Optional and never blocks anything. -->+ <div class="cat-picker dest-picker" id="forge-destination-picker" role="group" aria-labelledby="forge-destination-label" hidden>+ <span class="cat-picker-label" id="forge-destination-label" data-i18n="forge.making_this_for">Making this for:</span>+ <button class="forge-cat-btn" type="button" data-dest="game" aria-pressed="false" title="Unity, Unreal, Godot, a web game" data-i18n="forge.dest_game" data-i18n-attr="title:forge.dest_game_hint">Game</button>+ <button class="forge-cat-btn" type="button" data-dest="web" aria-pressed="false" title="A site, a product page, a 3D embed" data-i18n="forge.dest_web" data-i18n-attr="title:forge.dest_web_hint">Web</button>+ <button class="forge-cat-btn" type="button" data-dest="avatar" aria-pressed="false" title="A character to rig and animate" data-i18n="forge.dest_avatar" data-i18n-attr="title:forge.dest_avatar_hint">Avatar</button>+ <button class="forge-cat-btn" type="button" data-dest="simulation" aria-pressed="false" title="Robotics, physics, synthetic data" data-i18n="forge.dest_simulation" data-i18n-attr="title:forge.dest_simulation_hint">Simulation</button>+ <button class="forge-cat-btn" type="button" data-dest="print" aria-pressed="false" title="A physical 3D print" data-i18n="forge.dest_print" data-i18n-attr="title:forge.dest_print_hint">Print</button>+ <button class="forge-cat-btn" type="button" data-dest="ar" aria-pressed="false" title="Placing it in a real room" data-i18n="forge.dest_ar" data-i18n-attr="title:forge.dest_ar_hint">AR</button>+ <button class="forge-cat-btn" type="button" data-dest="play" aria-pressed="false" title="Exploring what it can do" data-i18n="forge.dest_play" data-i18n-attr="title:forge.dest_play_hint">Just playing</button>+ <span class="dest-picker-status" id="forge-destination-status" role="status" aria-live="polite" data-saved="Saved. We will remember this for your next models." data-i18n-attr="data-saved:forge.destination_saved"></span>+ </div>+<!-- Category picker — label your model so the gallery and explore feedcan surface it under the right filter. Wired in forge.js via theforge-category-picker id; hidden by default, becomes visible whendiff --git a/public/locales/en.json b/public/locales/en.jsonindex 4b2cb7816..920275e01 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -7833,6 +7833,21 @@"creature": "Creature","describe_it": "Describe it","describe_the_object_to_generate": "Describe the object to generate",+ "dest_ar": "AR",+ "dest_ar_hint": "Placing it in a real room",+ "dest_avatar": "Avatar",+ "dest_avatar_hint": "A character to rig and animate",+ "dest_game": "Game",+ "dest_game_hint": "Unity, Unreal, Godot, a web game",+ "dest_play": "Just playing",+ "dest_play_hint": "Exploring what it can do",+ "dest_print": "Print",+ "dest_print_hint": "A physical 3D print",+ "dest_simulation": "Simulation",+ "dest_simulation_hint": "Robotics, physics, synthetic data",+ "dest_web": "Web",+ "dest_web_hint": "A site, a product page, a 3D embed",+ "destination_saved": "Saved. We will remember this for your next models.","discard": "👎 Discard","discard_bad_result_title": "Discard — bad result","download_glb": "Download GLB",@@ -7870,6 +7885,7 @@"keep_good_result_title": "Keep — good result","loading_model": "Loading model…","make_another": "Make another",+ "making_this_for": "Making this for:","meta_description": "Type a description, get a textured 3D model. Forge turns a text prompt into an interactive GLB you can orbit, inspect in AR, and download.","meta_og_description": "Describe an object, watch it become an interactive 3D model. Real generation, real GLB, downloadable.","meta_og_title": "Forge — Text & Image to 3D · three.ws",diff --git a/src/forge-studio/forge.js b/src/forge-studio/forge.jsindex c1eef61be..ec4b78841 100644--- a/src/forge-studio/forge.js+++ b/src/forge-studio/forge.js@@ -18,6 +18,7 @@ import { mountPromptDictation } from '../voice/prompt-dictation.js';import { showToast } from '../ui-helpers.js';import { resolveDevR2Url } from '../shared/dev-r2-proxy.js';import { coldStartLabel } from '../shared/forge-frames.js';+import { initForgeDestinationPicker, storedForgeDestination } from '../shared/forge-destination-picker.js';ensureStateKitStyles();//// Drives /api/forge. Three paths share one polling loop:@@ -109,6 +110,8 @@ const els = {segmentBtn: document.getElementById('forge-segment-btn'),openInComposer: document.getElementById('open-in-composer'),categoryPicker: document.getElementById('forge-category-picker'),+ destinationPicker: document.getElementById('forge-destination-picker'),+ destinationStatus: document.getElementById('forge-destination-status'),savedChip: document.getElementById('result-saved'),creations: document.getElementById('creations'),creationsGrid: document.getElementById('creations-grid'),@@ -1347,6 +1350,10 @@ async function startJob({ prompt, imageUrls, skipValidation, payment }) {Array.isArray(imageUrls) && imageUrls.length? { image_urls: imageUrls, prompt: prompt || undefined, ...base }: { prompt, aspect_ratio: aspectRatio, ...base };+ // What this maker said they are building for, remembered from an earlier+ // model. Absent until they answer once; the server ignores an unknown value.+ const destination = storedForgeDestination();+ if (destination) body.destination = destination;// Caller already saw the vision warning and chose to proceed (Consumer 1).if (skipValidation) body.skip_validation = true;// Pay-per-use proof: a non-holder who paid $THREE for this High generation@@ -1554,6 +1561,14 @@ function resetVerdict() {}}+// "Making this for" chips (src/shared/forge-destination-picker.js). The answer is+// written onto the model on screen and remembered for later generations.+const destinationPicker = initForgeDestinationPicker({+ picker: els.destinationPicker,+ status: els.destinationStatus,+ onChoose: (id) => sendFeedback({ destination: id }),+});+function resetCategoryPicker() {if (!els.categoryPicker) return;els.categoryPicker.querySelectorAll('.forge-cat-btn').forEach((b) => b.classList.remove('active'));@@ -1714,6 +1729,7 @@ function showResult(glbUrl, label, meta, { autoSaved = false } = {}) {resetVerdict();resetCategoryPicker();if (els.categoryPicker) els.categoryPicker.hidden = false;+ destinationPicker.show();els.viewerShell?.classList.remove('has-load-error');// Show the load skeleton over the dark viewport until the GLB paints. The// persistent 'load'/'error' listeners below clear it.@@ -2603,12 +2619,14 @@ els.cancel.addEventListener('click', () => {stopElapsed();setBusy(false);if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();showState('empty');});els.again.addEventListener('click', () => {stopRateLimitCountdown();if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();showState('empty');if (mode === 'text') {els.prompt.focus();@@ -2624,6 +2642,7 @@ els.retry.addEventListener('click', () => {if (els.retry.disabled) return; // mid-countdown; Retry re-enables at resetstopRateLimitCountdown();if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();if (lastJob && (lastJob.prompt || (lastJob.imageUrls && lastJob.imageUrls.length))) {run(lastJob);} else {diff --git a/src/forge.js b/src/forge.jsindex 9ddf4876e..9f8469527 100644--- a/src/forge.js+++ b/src/forge.js@@ -25,6 +25,7 @@ import { initWalletButton, getConnectedWalletAddress } from './wallet.js';import { generateForgePrompt } from './forge-prompt-gen.js';import { createForgeTimeline } from './forge-timeline.js';import { createCompare } from './forge-compare.js';+import { initForgeDestinationPicker, storedForgeDestination } from './shared/forge-destination-picker.js';ensureStateKitStyles();//// Drives /api/forge. Three paths share one polling loop:@@ -129,6 +130,8 @@ const els = {openInComposer: document.getElementById('open-in-composer'),irlBtn: document.getElementById('forge-irl-btn'),categoryPicker: document.getElementById('forge-category-picker'),+ destinationPicker: document.getElementById('forge-destination-picker'),+ destinationStatus: document.getElementById('forge-destination-status'),savedChip: document.getElementById('result-saved'),creations: document.getElementById('creations'),creationsGrid: document.getElementById('creations-grid'),@@ -1645,6 +1648,10 @@ async function startJob({ prompt, imageUrls, skipValidation, payment, seed, prog// only — the director rewrites a prompt, and an image submission has// none to rewrite.: { prompt, aspect_ratio: aspectRatio, director: true, ...base };+ // What this maker said they are building for, remembered from an earlier+ // model. Absent until they answer once; the server ignores an unknown value.+ const destination = storedForgeDestination();+ if (destination) body.destination = destination;// Reproducibility: see mintSeed(). Absent on a job replayed from the gallery,// where the original seed was never recorded, so that path stays as it was.if (Number.isInteger(seed)) body.seed = seed;@@ -1953,6 +1960,14 @@ function resetVerdict() {}}+// "Making this for" chips (src/shared/forge-destination-picker.js). The answer is+// written onto the model on screen and remembered for later generations.+const destinationPicker = initForgeDestinationPicker({+ picker: els.destinationPicker,+ status: els.destinationStatus,+ onChoose: (id) => sendFeedback({ destination: id }),+});+function resetCategoryPicker() {if (!els.categoryPicker) return;els.categoryPicker.querySelectorAll('.forge-cat-btn').forEach((b) => b.classList.remove('active'));@@ -2175,6 +2190,7 @@ function showResult(glbUrl, label, meta, { autoSaved = false, downloadUrl = nullresetVerdict();resetCategoryPicker();if (els.categoryPicker) els.categoryPicker.hidden = false;+ destinationPicker.show();els.viewerShell?.classList.remove('has-load-error');// Show the load skeleton over the dark viewport until the GLB paints. The// persistent 'load'/'error' listeners below clear it.@@ -3342,6 +3358,7 @@ els.cancel.addEventListener('click', () => {timeline.fail();setBusy(false);if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();showState('empty');// Return focus to the composer so the keyboard flow continues where it began.if (mode === 'text') els.prompt.focus();@@ -3352,6 +3369,7 @@ els.cancel.addEventListener('click', () => {els.again.addEventListener('click', () => {stopRateLimitCountdown();if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();showState('empty');if (mode === 'text') {els.prompt.focus();@@ -3367,6 +3385,7 @@ els.retry.addEventListener('click', () => {if (els.retry.disabled) return; // mid-countdown; Retry re-enables at resetstopRateLimitCountdown();if (els.categoryPicker) els.categoryPicker.hidden = true;+ destinationPicker.hide();if (lastJob && (lastJob.prompt || (lastJob.imageUrls && lastJob.imageUrls.length))) {run(lastJob);} else {diff --git a/src/shared/forge-destination-picker.js b/src/shared/forge-destination-picker.jsnew file mode 100644index 000000000..c8790da86--- /dev/null+++ b/src/shared/forge-destination-picker.js@@ -0,0 +1,83 @@+// The "Making this for" chip row shared by /forge and /forge-studio.+//+// Asked once, in the result panel, where the maker is already judging the model.+// The answer is remembered per browser and rides along on every later generation+// request, so one tap labels all of a maker's future output. It is also written+// straight onto the model on screen through the page's own feedback sender.+//+// The chips are static markup in each page (so the i18n pass localizes them like+// every other control); this module only owns their behavior. Storage can be+// unavailable (private mode, blocked site data): the chips still work for the+// current model, the answer just is not remembered.++import { validForgeDestination } from './forge-destinations.js';++const STORAGE_KEY = 'forge:destination';+const SAVED_NOTE_MS = 2600;++/** The remembered destination id, or null. Safe to call before any picker exists. */+export function storedForgeDestination() {+ try {+ return validForgeDestination(localStorage.getItem(STORAGE_KEY));+ } catch {+ return null;+ }+}++/**+ * Wire a destination chip row.+ * @param {{+ * picker: HTMLElement|null,+ * status?: HTMLElement|null,+ * onChoose: (id: string) => void,+ * }} opts `onChoose` records the answer on the model currently on screen.+ * @returns {{ show: () => void, hide: () => void }}+ */+export function initForgeDestinationPicker({ picker, status = null, onChoose }) {+ if (!picker) return { show() {}, hide() {} };++ const chips = () => picker.querySelectorAll('.forge-cat-btn[data-dest]');++ function paint(id) {+ for (const b of chips()) {+ const on = b.dataset.dest === id;+ b.classList.toggle('active', on);+ b.setAttribute('aria-pressed', on ? 'true' : 'false');+ }+ }++ let noteTimer = 0;+ function flashSaved() {+ if (!status) return;+ // The localized sentence lives on the element (data-i18n-attr), so a locale+ // switch is honored without this module importing the catalog.+ status.textContent = status.dataset.saved || '';+ status.classList.add('is-visible');+ clearTimeout(noteTimer);+ noteTimer = setTimeout(() => status.classList.remove('is-visible'), SAVED_NOTE_MS);+ }++ picker.addEventListener('click', (e) => {+ const btn = e.target.closest('.forge-cat-btn[data-dest]');+ const id = validForgeDestination(btn?.dataset.dest);+ if (!id) return;+ try {+ localStorage.setItem(STORAGE_KEY, id);+ } catch {+ /* storage unavailable: the answer still lands on this model below */+ }+ paint(id);+ onChoose(id);+ flashSaved();+ });++ return {+ show() {+ paint(storedForgeDestination());+ picker.hidden = false;+ },+ hide() {+ picker.hidden = true;+ },+ };+}diff --git a/src/shared/forge-destinations.js b/src/shared/forge-destinations.jsnew file mode 100644index 000000000..9d3e69711--- /dev/null+++ b/src/shared/forge-destinations.js@@ -0,0 +1,40 @@+// What a Forge generation is FOR. One list, used by the composer chips, the+// request validator, and the funnel report, so the three can never disagree on+// what a valid answer is.+//+// The ids are stored verbatim in forge_creations.destination, so they are a+// wire format: add to this list freely, but never rename or reuse an id.+//+// `play` is a real answer, not a missing one. Someone exploring has a different+// bar for "accepted" than someone shipping a game asset, and folding the two+// together is exactly what made the acceptance rate unreadable before.++export const FORGE_DESTINATIONS = Object.freeze([+ Object.freeze({ id: 'game', label: 'Game', hint: 'Unity, Unreal, Godot, a web game' }),+ Object.freeze({ id: 'web', label: 'Web', hint: 'A site, a product page, a 3D embed' }),+ Object.freeze({ id: 'avatar', label: 'Avatar', hint: 'A character to rig and animate' }),+ Object.freeze({ id: 'simulation', label: 'Simulation', hint: 'Robotics, physics, synthetic data' }),+ Object.freeze({ id: 'print', label: 'Print', hint: 'A physical 3D print' }),+ Object.freeze({ id: 'ar', label: 'AR', hint: 'Placing it in a real room' }),+ Object.freeze({ id: 'play', label: 'Just playing', hint: 'Exploring what it can do' }),+]);++const IDS = new Set(FORGE_DESTINATIONS.map((d) => d.id));++/**+ * Normalize a caller-supplied destination to a stored id, or null when it is+ * absent or not one of ours. Case and surrounding whitespace are forgiven so an+ * API caller sending "Game" is not silently dropped.+ * @param {unknown} value+ * @returns {string|null}+ */+export function validForgeDestination(value) {+ if (typeof value !== 'string') return null;+ const id = value.trim().toLowerCase();+ return IDS.has(id) ? id : null;+}++/** Display label for a stored id; the id itself when it is unknown to this build. */+export function forgeDestinationLabel(id) {+ return FORGE_DESTINATIONS.find((d) => d.id === id)?.label ?? String(id ?? '');+}