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): let creators delete their creations, uploaded photos included
nirholas7a9c6d1a6d7b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a98e30cff..95b37e923 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -71,6 +71,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Two docs pages told you to run a command that no longer exists**: The Quick Start page's tip for shrinking a large 3D model named a tool that was pulled from npm back in 2023, so the command it gave you failed instead of compressing anything. It now names the tool that is actually published, and the page also stopped claiming the avatar builder defaults to a local port; it is served from the site itself. On the ERC-8004 page, the snippet that shows you how to independently re-check a validation compared your freshly computed hash against a field the read function never returns, so the check always came back false. It now reads the field that carries the on-chain hash. The "do I need crypto" page also listed an agent's portable address in a form the resolver rejects, and now shows the form that works. (`/docs/quick-start`) `[docs, fix]`- **Walkthroughs actually play now, and the one that would not name itself does**: The Walkthroughs library opened to "Could not load the walkthroughs" and every individual walkthrough opened to the same failure, because the file the player reads had never been published: only 7 of the 20 frames existed and the manifest tying them together was missing entirely. All four walkthroughs were re-captured against the live site, so the 20 frames you step through are the real product as it looks today, and the index, the covers, and the player all load. Two smaller things went with it: the Forge walkthrough was the one page in the set that served a generic "Walkthrough" title and description to search engines and link previews instead of its own, because of a collision between the build-time and serve-time meta systems that is now fixed for every shared page template on the site; and the SDK docs pointed anyone installing the LobeChat plugin at an older descriptor that declares no tools, so the install produced an avatar the model could not talk to. (`/walkthroughs`) `[fix, docs]`- **x402 and Premium docs now match the live endpoints**: Audited the eight paid-endpoint and Premium documentation pages against the running code. Corrected the pump.fun launcher ticker-check example (it used a parameter the endpoint does not accept), refreshed the volume-loop spend cap and price range, repaired the payout source links and a dead datapoint-fabric anchor, dropped a stale archive article count, and made the free sample commands CI-verified so this class of drift fails the build next time. `[docs, fix]`+- **You can now delete your Forge creations, photos included**: Every card in the "Your creations" gallery on /forge and the Forge Studio now carries a delete button (tap once to arm, tap again to confirm). Deleting a creation permanently erases everything the platform stored for it: the 3D model file, the preview image, and, for image-to-3D runs, the reference photos you uploaded. The model also disappears from the community showcase, share links and embeds at the same moment. Before this, a generated model and its source photo stayed on our storage forever with no way to remove them, which is not acceptable for anyone turning personal photos into 3D. Only the browser that forged a model can delete it. (`/forge`) `[feature, security]`- **Your API keys now show whether they still work, and a key can no longer be issued with no permissions at all**: The API keys table in your developer dashboard listed every key you had ever created, but nothing on the row said which ones were still usable. A key you had already revoked looked exactly like a live one, right down to a Revoke button that could only ever fail, and a key that had passed its expiry date looked perfectly healthy until a request mysteriously stopped working. Every key now carries an Active, Expired, or Revoked label, dead keys are dimmed, and the Revoke button is only shown where it can do something. The connection tester also stops picking an expired key to test with. Separately, creating a key through the API with an explicitly empty permission list used to succeed and hand back a credential that could not do anything, with nothing to tell you so; that request is now rejected with a clear message, and a permission listed twice is stored once. (`/dashboard/api`) `[fix, improvement]`- **Your friends list no longer goes blank when the database is mid-upgrade, and search finds unusual names**: Two problems in the friends area. The friends list is built to survive an environment where the social tables have not been created yet: it shows an empty list instead of an error. That safety net was matching on the wording of the database error rather than its type, and the wording it looked for also appears when a single column is missing, which is what a partly-applied upgrade looks like. So during an upgrade the page answered normally and told you that you had no friends, no incoming requests, and no pending invites, with nothing anywhere reporting a fault. The safety net now recognises only a genuinely missing table, and any other database problem is reported as the error it is. Separately, friend search could not find a display name containing a backslash, and a search term ending in one quietly searched for something else, because the search was not escaping the backslash before handing the term to the database. (`/walk`) `[fix]`- **Your Memetic Launcher settings can no longer be dropped behind a success message**: The launcher's settings endpoint answered "saved" to any request whose body it could not actually read, so a badly formed save from a script or an agent looked like it worked while nothing changed. This config decides whether your launcher mints for real and how much SOL it may spend per day, so "I switched it to preview and got an OK" has to mean it is in preview. An unreadable save is now refused outright with a message naming what was wrong, and only a save the server genuinely understood reports success. (`/launcher`) `[fix]`diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.jsindex f3baa9454..80257e96f 100644--- a/api/_lib/forge-store.js+++ b/api/_lib/forge-store.js@@ -17,7 +17,7 @@ import { createHash } from 'node:crypto';import { randomUUID } from 'node:crypto';import { sql, isDbUnavailableError } from './db.js';import { databaseConfigured } from './env.js';-import { putObject, publicUrl } from './r2.js';+import { putObject, publicUrl, deleteObject, keyFromPublicUrl } from './r2.js';import { recordDailyActivity, maybeAwardFirstCreation } from './streaks.js';import { recordGenerationEvent } from './forge-events.js';import { scoreGlbQuality } from './glb-quality.js';@@ -63,6 +63,21 @@ export function hashIp(ip) {return createHash('sha256').update(`${CLIENT_SALT}:ip:${ip}`).digest('hex');}+// Resolve the reference-view URLs a generation consumes down to the bucket keys+// of the user's own uploads (forge/uploads/..., written by api/forge-upload.js).+// Provider-hosted URLs (FLUX previews on a delivery CDN, pasted external links)+// resolve to null and are dropped: they are not ours to delete. Returns a+// deduplicated array, or null when nothing bucket-hosted is present, so the+// column stays null for the text-to-3D majority.+function sourceImageKeysFrom(urls) {+ const keys = new Set();+ for (const url of Array.isArray(urls) ? urls : []) {+ const key = keyFromPublicUrl(url);+ if (key && key.startsWith('forge/')) keys.add(key);+ }+ return keys.size ? [...keys].slice(0, 12) : null;+}+// Record a generation the moment it starts, so the prompt + reference image are// retained even if the mesh step later fails. Returns the new creation id (used// as the durable object key and the client-facing handle) or null when the@@ -127,6 +142,13 @@ export async function createCreation({path,modelCategory,userId,+ // Every reference-view URL the generation consumes (multiview lanes pass the+ // full list). Bucket-hosted ones (the user's own uploaded photos) are+ // resolved to their object keys and remembered on the row so deleteCreation+ // can erase the photos too. Defaults to the preview URL, which is the single+ // reference view on every non-multiview lane, so callers that pass nothing+ // still get their upload tracked.+ sourceImageUrls = null,}) {if (!forgeStoreEnabled()) return null;const id = randomUUID();@@ -134,18 +156,23 @@ export async function createCreation({// it from the prompt so the model gets a real category at birth instead of// defaulting to 'other' and leaving the category dimension dead.const category = validModelCategory(modelCategory) ?? classifyModelCategory(prompt);+ const sourceKeys = sourceImageKeysFrom(+ Array.isArray(sourceImageUrls) && sourceImageUrls.length ? sourceImageUrls : [previewImageUrl],+ );try {await sql`insert into forge_creations(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)+ multiview, backend, tier, path, status, outcome, model_category, user_id,+ source_image_keys)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})+ ${tier ?? null}, ${path ?? null}, 'generating', 'generated', ${category}, ${userId ?? null},+ ${sourceKeys ? JSON.stringify(sourceKeys) : null})`;// Funnel start — counts attempts so the health rollup can show how many// generations began vs. completed. Best-effort; never blocks the insert.@@ -558,6 +585,57 @@ export async function markFailed({ replicateJobId, clientKey, error }) {}}+// Permanently delete a creation: the stored mesh, the stored preview, every+// recorded source upload (the user's reference photos), and the row itself.+// Scoped to the owning client_key so one browser can never erase another's+// work. Bucket objects go first: if storage refuses, the row survives and the+// user can simply retry; deleting the row first would strand unreferenced+// bytes with no handle left to retry from. The row delete then cascades+// forge_votes and forge_comments; lineage children and forge_board_winners+// null their reference (see the migrations that created those FKs).+// Returns 'deleted' | 'not_found' | 'error' | 'unavailable'.+export async function deleteCreation({ id, clientKey }) {+ if (!forgeStoreEnabled() || !id || !clientKey) return 'unavailable';+ try {+ const rows = await sql`+ select id, glb_key, glb_url, preview_key, preview_image_url, source_image_keys+ from forge_creations+ where id = ${id} and client_key = ${clientKey}+ limit 1+ `;+ const row = rows[0];+ if (!row) return 'not_found';++ // Every bucket object the row points at. URL-derived keys cover legacy+ // rows written before the *_key columns existed, and a preview that still+ // points at the raw upload because the durable copy failed. The forge/+ // prefix guard keeps a corrupted row from ever deleting outside the+ // forge namespace.+ const keys = new Set();+ for (const k of [row.glb_key, row.preview_key]) {+ if (typeof k === 'string' && k.startsWith('forge/')) keys.add(k);+ }+ for (const u of [row.glb_url, row.preview_image_url]) {+ const k = keyFromPublicUrl(u);+ if (k && k.startsWith('forge/')) keys.add(k);+ }+ for (const k of Array.isArray(row.source_image_keys) ? row.source_image_keys : []) {+ if (typeof k === 'string' && k.startsWith('forge/')) keys.add(k);+ }+ await Promise.all([...keys].map((key) => deleteObject(key)));++ await sql`delete from forge_creations where id = ${id} and client_key = ${clientKey}`;+ return 'deleted';+ } catch (err) {+ if (isDbUnavailableError(err)) {+ console.warn('[forge-store] deleteCreation skipped (db unavailable):', err?.message);+ return 'unavailable';+ }+ console.error('[forge-store] deleteCreation failed:', err?.message);+ return 'error';+ }+}+const VALID_OUTCOMES = new Set(['accepted', 'rejected', 'generated']);// Capture the human verdict on a creation. Scoped to the owning client so adiff --git a/api/_lib/migrations/20260813160000_forge_source_image_keys.sql b/api/_lib/migrations/20260813160000_forge_source_image_keys.sqlnew file mode 100644index 000000000..65e08f935--- /dev/null+++ b/api/_lib/migrations/20260813160000_forge_source_image_keys.sql@@ -0,0 +1,15 @@+-- Deleting a creation must be able to erase the user's uploaded reference+-- photos, not just the generated mesh. Uploads land in the bucket under+-- forge/uploads/<client12>/<uuid>.<ext> (api/forge-upload.js), but until now no+-- row remembered which upload objects fed a generation: materializeCreation+-- overwrites preview_image_url with the durable copy, so the original photo's+-- key was unrecoverable and the object lived forever even after the creation+-- was discarded. That is unacceptable the moment a paying customer uploads a+-- personal photo for image-to-3D.+--+-- source_image_keys is a jsonb array of bucket keys (all reference views, not+-- just the primary one) recorded at createCreation time. deleteCreation+-- (api/_lib/forge-store.js) removes every listed object along with the stored+-- GLB and preview when the owner deletes the creation from their gallery.+alter table forge_creations+ add column if not exists source_image_keys jsonb;diff --git a/api/_lib/r2.js b/api/_lib/r2.jsindex ba7d24fc2..902ae4210 100644--- a/api/_lib/r2.js+++ b/api/_lib/r2.js@@ -145,6 +145,21 @@ function isAbsoluteUrl(key) {return typeof key === 'string' && /^https?:\/\//i.test(key);}+// Reverse of publicUrl(): resolve a public CDN URL back to the bucket key it+// serves, or null when the URL lives outside our bucket. Lets deletion paths+// find the stored object behind a URL-bearing column (e.g. a forge creation's+// preview_image_url) so the bytes are actually removed, not just unlinked.+export function keyFromPublicUrl(url) {+ if (typeof url !== 'string' || !url.startsWith(`${env.S3_PUBLIC_DOMAIN}/`)) return null;+ const path = url.slice(`${env.S3_PUBLIC_DOMAIN}/`.length).split(/[?#]/)[0];+ if (!path) return null;+ try {+ return path.split('/').map(decodeURIComponent).join('/');+ } catch {+ return null;+ }+}+// A thumbnail_key written by the pre-fix avatar-OG cache (it derived `_og.png`// from an absolute storage_key, so the "key" was a full origin URL that// publicUrl() passes through verbatim — pointing at the site instead of the R2diff --git a/api/forge-creation.js b/api/forge-creation.jsindex 27e83747e..6f706f90d 100644--- a/api/forge-creation.js+++ b/api/forge-creation.js@@ -20,16 +20,25 @@* (same category first, newest, never the model itself)* ?view=1 counts one page impression (fire-and-forget increment* of forge_creations.view_count; never blocks the read)+ *+ * DELETE /api/forge-creation?id=<uuid> → { deleted: true }+ *+ * Deletion is scoped to the owning browser (the x-forge-client header that+ * scopes the gallery): only the client that forged a creation can delete it.+ * It permanently removes the stored GLB, the stored preview, every recorded+ * source upload (the reference photos an image-to-3D run was conditioned on),+ * and the row itself, so a deleted creation is gone from the gallery, the+ * community showcase, and the share/embed pages alike.*/import { cors, json, method, wrap, rateLimited } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';-import { getPublicCreation, listRelated, recordCreationView, hashClient, forgeStoreEnabled } from './_lib/forge-store.js';+import { getPublicCreation, listRelated, recordCreationView, deleteCreation, hashClient, forgeStoreEnabled } from './_lib/forge-store.js';import { isUuid } from './_lib/validate.js';export default wrap(async (req, res) => {- if (cors(req, res, { methods: 'GET,OPTIONS' })) return;- if (!method(req, res, ['GET'])) return;+ if (cors(req, res, { methods: 'GET,DELETE,OPTIONS' })) return;+ if (!method(req, res, ['GET', 'DELETE'])) return;const rl = await limits.mcp3dStatus(clientIp(req));if (!rl.success) {@@ -46,6 +55,26 @@ export default wrap(async (req, res) => {return json(res, 400, { enabled: true, creation: null, error: 'invalid id' });}+ if (req.method === 'DELETE') {+ const rawClient = req.headers['x-forge-client'];+ const clientHeader = Array.isArray(rawClient) ? rawClient[0] : rawClient;+ if (!clientHeader) {+ return json(res, 401, { error: 'missing_client', message: 'x-forge-client header required.' });+ }+ const outcome = await deleteCreation({ id, clientKey: hashClient(clientHeader) });+ if (outcome === 'deleted') return json(res, 200, { deleted: true });+ if (outcome === 'not_found') {+ // Either the id doesn't exist or it belongs to another client; both+ // answer the same so ids can't be probed for existence.+ return json(res, 404, { deleted: false, error: 'not_found' });+ }+ return json(res, 503, {+ deleted: false,+ error: 'delete_failed',+ message: 'Could not delete right now. Nothing was removed; try again shortly.',+ });+ }+// Optional anonymous browser id (same forge:cid the gallery uses) resolves// this browser's own voted-state on the model's like button.const rawClient = req.headers['x-forge-client'];diff --git a/api/forge.js b/api/forge.jsindex 9d69c0f67..abb77ebf1 100644--- a/api/forge.js+++ b/api/forge.js@@ -871,6 +871,7 @@ async function runHfImageLane({viewsRequested: imageUrls.length,viewsUsed: imageUrls.length,multiview: imageUrls.length > 1,+ sourceImageUrls: imageUrls,backend: backendId,tier: tier.id,path,@@ -916,6 +917,7 @@ async function runHfImageLane({viewsRequested: imageUrls.length,viewsUsed: imageUrls.length,multiview: imageUrls.length > 1,+ sourceImageUrls: imageUrls,backend: backendId,tier: tier.id,path,@@ -971,7 +973,7 @@ async function runHfImageLane({previewImageUrl: preview, replicateJobId: rj,textToImageModel: isImageMode ? null : textToImageModel,viewsRequested: imageUrls.length, viewsUsed: imageUrls.length,- multiview: imageUrls.length > 1, backend: backendId, tier: tier.id, path,+ multiview: imageUrls.length > 1, sourceImageUrls: imageUrls, backend: backendId, tier: tier.id, path,});const rd = await materializeCreation({replicateJobId: rj, clientKey, userId: await sessionUserIdFromReq(req),@@ -2023,6 +2025,7 @@ async function startJob(req, res) {viewsRequested: views.length,viewsUsed: job.viewsUsed ?? views.length,multiview: views.length > 1,+ sourceImageUrls: views,backend: backendId,tier: tier.id,path,@@ -2334,6 +2337,7 @@ async function startJob(req, res) {viewsRequested,viewsUsed,multiview,+ sourceImageUrls: views,backend: backendId,tier: tier.id,path,diff --git a/api/gpt-forge.js b/api/gpt-forge.jsindex 914381842..fffe56990 100644--- a/api/gpt-forge.js+++ b/api/gpt-forge.js@@ -875,6 +875,7 @@ async function runHfImageLane({viewsRequested: imageUrls.length,viewsUsed: imageUrls.length,multiview: imageUrls.length > 1,+ sourceImageUrls: imageUrls,backend: backendId,tier: tier.id,path,@@ -920,6 +921,7 @@ async function runHfImageLane({viewsRequested: imageUrls.length,viewsUsed: imageUrls.length,multiview: imageUrls.length > 1,+ sourceImageUrls: imageUrls,backend: backendId,tier: tier.id,path,@@ -975,7 +977,7 @@ async function runHfImageLane({previewImageUrl: preview, replicateJobId: rj,textToImageModel: isImageMode ? null : textToImageModel,viewsRequested: imageUrls.length, viewsUsed: imageUrls.length,- multiview: imageUrls.length > 1, backend: backendId, tier: tier.id, path,+ multiview: imageUrls.length > 1, sourceImageUrls: imageUrls, backend: backendId, tier: tier.id, path,});const rd = await materializeCreation({replicateJobId: rj, clientKey, userId: await sessionUserIdFromReq(req),@@ -2013,6 +2015,7 @@ async function startJob(req, res) {viewsRequested: views.length,viewsUsed: job.viewsUsed ?? views.length,multiview: views.length > 1,+ sourceImageUrls: views,backend: backendId,tier: tier.id,path,@@ -2319,6 +2322,7 @@ async function startJob(req, res) {viewsRequested,viewsUsed,multiview,+ sourceImageUrls: views,backend: backendId,tier: tier.id,path,diff --git a/data/changelog.json b/data/changelog.jsonindex 6476d239c..3f95199a7 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -20759,6 +20759,16 @@"fix","security"]+ },+ {+ "date": "2026-08-13",+ "title": "You can now delete your Forge creations, photos included",+ "summary": "Every card in the \"Your creations\" gallery on /forge and the Forge Studio now carries a delete button (tap once to arm, tap again to confirm). Deleting a creation permanently erases everything the platform stored for it: the 3D model file, the preview image, and, for image-to-3D runs, the reference photos you uploaded. The model also disappears from the community showcase, share links and embeds at the same moment. Before this, a generated model and its source photo stayed on our storage forever with no way to remove them, which is not acceptable for anyone turning personal photos into 3D. Only the browser that forged a model can delete it.",+ "tags": [+ "feature",+ "security"+ ],+ "link": "/forge"}]}diff --git a/docs/api-reference.md b/docs/api-reference.mdindex e3e763afe..d4257cf18 100644--- a/docs/api-reference.md+++ b/docs/api-reference.md@@ -1168,6 +1168,26 @@ creator attribution (`creatorUsername`, `creatorDisplayName`,first, newest, never the model itself. Geometry stats are not stored: the pagereads triangles/vertices live from the free `GET /api/3d/inspect?url=<glb>`.+### Delete a creation: `DELETE /api/forge-creation`++```+DELETE /api/forge-creation?id=<uuid>+x-forge-client: <stable browser id> # required: only the owner can delete+→ { "deleted": true }+```++Permanent deletion for the "Your creations" gallery, scoped to the browser+that forged the model (the same `forge:cid` id that scopes the gallery read).+It erases everything the platform stored for that creation: the durable GLB,+the preview image, any uploaded reference photos the generation was+conditioned on (the image-to-3D source pictures), the row itself, and with it+the model's presence in the community showcase, share links, and embeds.+Votes and comments cascade away with the row. A missing client id is+`401 missing_client`; an id that doesn't exist or belongs to another browser+is `404 not_found` (indistinguishable on purpose, so ids can't be probed).+On a storage fault nothing is removed and the response is `503 delete_failed`;+retry safely.+### Model comments: `GET/POST/DELETE /api/forge-comments````diff --git a/pages/forge-studio.html b/pages/forge-studio.htmlindex cd39104c2..7854e0e34 100644--- a/pages/forge-studio.html+++ b/pages/forge-studio.html@@ -2302,6 +2302,68 @@outline: 2px solid var(--accent);outline-offset: 2px;}+ /* Delete a saved creation. The control is a sibling of the card inside+ .creation-wrap (the card is itself a <button>, so nesting would be+ invalid HTML). Hidden until hover/focus on pointer devices; always+ visible on touch, where hover cannot reveal it. */+ .creation-wrap {+ position: relative;+ display: flex;+ }+ .creation-wrap .creation {+ width: 100%;+ }+ .creation-del {+ position: absolute;+ top: 6px;+ right: 6px;+ z-index: 2;+ min-width: 22px;+ height: 22px;+ padding: 0 6px;+ border: 1px solid var(--stroke-strong);+ border-radius: 999px;+ background: rgba(0, 0, 0, 0.55);+ backdrop-filter: blur(4px);+ color: var(--ink-dim);+ font-size: 13px;+ line-height: 1;+ cursor: pointer;+ opacity: 0;+ transition:+ opacity 0.15s,+ color 0.15s,+ border-color 0.15s,+ background 0.15s;+ }+ .creation-wrap:hover .creation-del,+ .creation-wrap:focus-within .creation-del {+ opacity: 1;+ }+ .creation-del:hover,+ .creation-del.is-armed {+ color: var(--danger);+ border-color: var(--danger);+ background: rgba(0, 0, 0, 0.75);+ }+ .creation-del:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+ }+ .creation-del.is-armed {+ opacity: 1;+ font-family: var(--font-mono);+ font-size: 11px;+ }+ .creation-del:disabled {+ cursor: default;+ color: var(--ink-dim);+ }+ @media (hover: none) {+ .creation-del {+ opacity: 1;+ }+ }.creation .thumb {aspect-ratio: 1 / 1;width: 100%;diff --git a/pages/forge.html b/pages/forge.htmlindex 53668d4c2..a58712d6b 100644--- a/pages/forge.html+++ b/pages/forge.html@@ -2803,6 +2803,68 @@outline: 2px solid var(--accent);outline-offset: 2px;}+ /* Delete a saved creation. The control is a sibling of the card inside+ .creation-wrap (the card is itself a <button>, so nesting would be+ invalid HTML). Hidden until hover/focus on pointer devices; always+ visible on touch, where hover cannot reveal it. */+ .creation-wrap {+ position: relative;+ display: flex;+ }+ .creation-wrap .creation {+ width: 100%;+ }+ .creation-del {+ position: absolute;+ top: 6px;+ right: 6px;+ z-index: 2;+ min-width: 22px;+ height: 22px;+ padding: 0 6px;+ border: 1px solid var(--stroke-strong);+ border-radius: 999px;+ background: rgba(0, 0, 0, 0.55);+ backdrop-filter: blur(4px);+ color: var(--ink-dim);+ font-size: 13px;+ line-height: 1;+ cursor: pointer;+ opacity: 0;+ transition:+ opacity 0.15s,+ color 0.15s,+ border-color 0.15s,+ background 0.15s;+ }+ .creation-wrap:hover .creation-del,+ .creation-wrap:focus-within .creation-del {+ opacity: 1;+ }+ .creation-del:hover,+ .creation-del.is-armed {+ color: var(--danger);+ border-color: var(--danger);+ background: rgba(0, 0, 0, 0.75);+ }+ .creation-del:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+ }+ .creation-del.is-armed {+ opacity: 1;+ font-family: var(--font-mono);+ font-size: 11px;+ }+ .creation-del:disabled {+ cursor: default;+ color: var(--ink-dim);+ }+ @media (hover: none) {+ .creation-del {+ opacity: 1;+ }+ }.creation .thumb {aspect-ratio: 1 / 1;width: 100%;diff --git a/public/changelog.json b/public/changelog.jsonindex cd2e941d0..da6c41e01 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-13T07:51:28.485Z",+ "generated_at": "2026-08-13T08:38:32.663Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -701,6 +701,17 @@"fix"]},+ {+ "date": "2026-08-13",+ "type": "update",+ "title": "You can now delete your Forge creations, photos included",+ "summary": "Every card in the \"Your creations\" gallery on /forge and the Forge Studio now carries a delete button (tap once to arm, tap again to confirm). Deleting a creation permanently erases everything the platform stored for it: the 3D model file, the preview image, and, for image-to-3D runs, the reference photos you uploaded. The model also disappears from the community showcase, share links and embeds at the same moment. Before this, a generated model and its source photo stayed on our storage forever with no way to remove them, which is not acceptable for anyone turning personal photos into 3D. Only the browser that forged a model can delete it.",+ "link": "/forge",+ "tags": [+ "feature",+ "security"+ ]+ },{"date": "2026-08-13","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 5b89235ad..2088587ba 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -526,6 +526,14 @@<category>docs</category><description>Audited the eight paid-endpoint and Premium documentation pages against the running code. Corrected the pump.fun launcher ticker-check example (it used a parameter the endpoint does not accept), refreshed the volume-loop spend cap and price range, repaired the payout source links and a dead datapoint-fabric anchor, dropped a stale archive article count, and made the free sample commands CI-verified so this class of drift fails the build next time.</description></item>+ <item>+ <title>You can now delete your Forge creations, photos included</title>+ <link>https://three.ws/forge</link>+ <guid isPermaLink="false">2026-08-13:You can now delete your Forge creations, photos included</guid>+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>Every card in the "Your creations" gallery on /forge and the Forge Studio now carries a delete button (tap once to arm, tap again to confirm). Deleting a creation permanently erases everything the platform stored for it: the 3D model file, the preview image, and, for image-to-3D runs, the reference photos you uploaded. The model also disappears from the community showcase, share links and embeds at the same moment. Before this, a generated model and its source photo stayed on our storage forever with no way to remove them, which is not acceptable for anyone turning personal photos into 3D. Only the browser that forged a model can delete it.</description>+ </item><item><title>Your API keys now show whether they still work, and a key can no longer be issued with no permissions at all</title><link>https://three.ws/dashboard/api</link>diff --git a/public/features.json b/public/features.jsonindex 0a559a767..c8e9f744f 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-13T07:51:28.469Z",+ "generated_at": "2026-08-13T08:38:32.648Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/forge-studio/forge.js b/src/forge-studio/forge.jsindex b88619b1e..73aee8252 100644--- a/src/forge-studio/forge.js+++ b/src/forge-studio/forge.js@@ -138,6 +138,9 @@ let lastJob = null; // { prompt, imageUrls } — for retry// server's own poll-time failover already walked the async lanes before this.let autoLaneHops = 0;let currentCreationId = null;+// The rows currently rendered in "Your creations", kept so a delete can drop+// one card in place (count, empty state) without a refetch.+let galleryCreations = [];// The quality tier the on-screen result was produced at — drives the "Refine"// affordance, which re-runs the same job exactly one tier higher.let currentResultTier = null;@@ -1749,6 +1752,7 @@ async function loadGallery() {return;}els.creationsGrid.innerHTML = '';+ galleryCreations = creations;for (const c of creations) {const card = document.createElement('button');card.type = 'button';@@ -1814,12 +1818,93 @@ async function loadGallery() {card.addEventListener('click', () => openCreation(c));- els.creationsGrid.appendChild(card);+ // The card is itself a <button>, so the delete control lives beside it in+ // a positioning wrapper rather than nested inside (invalid HTML).+ const cell = document.createElement('div');+ cell.className = 'creation-wrap';+ cell.appendChild(card);+ if (c.id) cell.appendChild(makeDeleteButton(c, cell));+ els.creationsGrid.appendChild(cell);}els.creationsCount.textContent = `${creations.length} saved`;els.creations.classList.remove('is-hidden');}+// Two-tap delete for a gallery card: the first tap arms a visible "Delete?"+// confirm state, the second (within 4s) permanently deletes the creation+// server-side (the stored model, its preview, and any uploaded reference+// photos) and drops the card in place. Blur, Escape, or the timeout disarms.+function makeDeleteButton(c, cell) {+ const del = document.createElement('button');+ del.type = 'button';+ del.className = 'creation-del';+ del.textContent = '×';+ del.title = 'Delete this creation';+ del.setAttribute('aria-label', `Delete: ${c.prompt || 'forged model'}`);+ let armed = false;+ let disarmTimer = 0;+ const disarm = () => {+ armed = false;+ clearTimeout(disarmTimer);+ del.classList.remove('is-armed');+ del.textContent = '×';+ del.title = 'Delete this creation';+ del.setAttribute('aria-label', `Delete: ${c.prompt || 'forged model'}`);+ };+ del.addEventListener('blur', disarm);+ del.addEventListener('keydown', (e) => {+ if (e.key === 'Escape') disarm();+ });+ del.addEventListener('click', async (e) => {+ // Never let a delete tap open the model underneath.+ e.stopPropagation();+ if (!armed) {+ armed = true;+ del.classList.add('is-armed');+ del.textContent = 'Delete?';+ del.title = 'Click again to permanently delete';+ del.setAttribute('aria-label', 'Confirm permanent delete');+ disarmTimer = setTimeout(disarm, 4000);+ return;+ }+ clearTimeout(disarmTimer);+ del.disabled = true;+ del.textContent = '…';+ let ok = false;+ try {+ const res = await fetch(`/api/forge-creation?id=${encodeURIComponent(c.id)}`, {+ method: 'DELETE',+ headers: CLIENT_HEADERS,+ });+ const body = await res.json().catch(() => ({}));+ // A 404 means the row is already gone (deleted from another tab); the+ // card should disappear either way.+ ok = (res.ok && body?.deleted === true) || res.status === 404;+ } catch {+ ok = false;+ }+ if (!ok) {+ del.disabled = false;+ disarm();+ del.title = "Couldn't delete. Check your connection and try again.";+ return;+ }+ removeCreationFromGallery(c.id, cell);+ });+ return del;+}++// Drop a deleted creation's card in place: no refetch, no skeleton flash.+// Keeps the count and empty state truthful, and clears the feedback handle so+// a verdict can't target the deleted row.+function removeCreationFromGallery(id, cell) {+ cell.remove();+ galleryCreations = galleryCreations.filter((x) => String(x.id) !== String(id));+ if (els.creationsCount) els.creationsCount.textContent = `${galleryCreations.length} saved`;+ if (galleryCreations.length === 0) els.creations.classList.add('is-hidden');+ if (String(currentCreationId) === String(id)) currentCreationId = null;+}+// Load a creation into the viewer — shared by gallery card clicks and the// share-link path. `c` is a creation row from /api/forge-gallery or// /api/forge-creation; both return the same shape.diff --git a/src/forge.js b/src/forge.jsindex 7d8f1c17b..b1c25cba2 100644--- a/src/forge.js+++ b/src/forge.js@@ -157,6 +157,9 @@ let lastJob = null; // { prompt, imageUrls } — for retry// server's own poll-time failover already walked the async lanes before this.let autoLaneHops = 0;let currentCreationId = null;+// The rows currently rendered in "Your creations", kept so a delete can drop+// one card in place (count, compare state, empty state) without a refetch.+let galleryCreations = [];// The quality tier the on-screen result was produced at — drives the "Refine"// affordance, which re-runs the same job exactly one tier higher.let currentResultTier = null;@@ -2056,6 +2059,7 @@ async function loadGallery() {return;}els.creationsGrid.innerHTML = '';+ galleryCreations = creations;for (const c of creations) {const card = document.createElement('button');card.type = 'button';@@ -2126,13 +2130,96 @@ async function loadGallery() {openCreation(c);});- els.creationsGrid.appendChild(card);+ // The card is itself a <button>, so the delete control lives beside it in+ // a positioning wrapper rather than nested inside (invalid HTML).+ const cell = document.createElement('div');+ cell.className = 'creation-wrap';+ cell.appendChild(card);+ if (c.id) cell.appendChild(makeDeleteButton(c, cell));+ els.creationsGrid.appendChild(cell);}els.creationsCount.textContent = `${creations.length} saved`;els.creations.classList.remove('is-hidden');compare.setCreations(creations);}+// Two-tap delete for a gallery card: the first tap arms a visible "Delete?"+// confirm state, the second (within 4s) permanently deletes the creation+// server-side (the stored model, its preview, and any uploaded reference+// photos) and drops the card in place. Blur, Escape, or the timeout disarms.+function makeDeleteButton(c, cell) {+ const del = document.createElement('button');+ del.type = 'button';+ del.className = 'creation-del';+ del.textContent = '×';+ del.title = 'Delete this creation';+ del.setAttribute('aria-label', `Delete: ${c.prompt || 'forged model'}`);+ let armed = false;+ let disarmTimer = 0;+ const disarm = () => {+ armed = false;+ clearTimeout(disarmTimer);+ del.classList.remove('is-armed');+ del.textContent = '×';+ del.title = 'Delete this creation';+ del.setAttribute('aria-label', `Delete: ${c.prompt || 'forged model'}`);+ };+ del.addEventListener('blur', disarm);+ del.addEventListener('keydown', (e) => {+ if (e.key === 'Escape') disarm();+ });+ del.addEventListener('click', async (e) => {+ // The wrapper sits inside the card's click target visually; never let a+ // delete tap open (or compare-pick) the model underneath.+ e.stopPropagation();+ if (!armed) {+ armed = true;+ del.classList.add('is-armed');+ del.textContent = 'Delete?';+ del.title = 'Click again to permanently delete';+ del.setAttribute('aria-label', 'Confirm permanent delete');+ disarmTimer = setTimeout(disarm, 4000);+ return;+ }+ clearTimeout(disarmTimer);+ del.disabled = true;+ del.textContent = '…';+ let ok = false;+ try {+ const res = await fetch(`/api/forge-creation?id=${encodeURIComponent(c.id)}`, {+ method: 'DELETE',+ headers: CLIENT_HEADERS,+ });+ const body = await res.json().catch(() => ({}));+ // A 404 means the row is already gone (deleted from another tab); the+ // card should disappear either way.+ ok = (res.ok && body?.deleted === true) || res.status === 404;+ } catch {+ ok = false;+ }+ if (!ok) {+ del.disabled = false;+ disarm();+ del.title = "Couldn't delete. Check your connection and try again.";+ return;+ }+ removeCreationFromGallery(c.id, cell);+ });+ return del;+}++// Drop a deleted creation's card in place: no refetch, no skeleton flash.+// Keeps the count, compare state, and empty state truthful, and clears the+// feedback handle so a verdict can't target the deleted row.+function removeCreationFromGallery(id, cell) {+ cell.remove();+ galleryCreations = galleryCreations.filter((x) => String(x.id) !== String(id));+ compare.setCreations(galleryCreations);+ if (els.creationsCount) els.creationsCount.textContent = `${galleryCreations.length} saved`;+ if (galleryCreations.length === 0) els.creations.classList.add('is-hidden');+ if (String(currentCreationId) === String(id)) currentCreationId = null;+}+// Load a creation into the viewer — shared by gallery card clicks and the// share-link path. `c` is a creation row from /api/forge-gallery or// /api/forge-creation; both return the same shape.diff --git a/tests/forge-store-delete.test.js b/tests/forge-store-delete.test.jsnew file mode 100644index 000000000..dafb788fc--- /dev/null+++ b/tests/forge-store-delete.test.js@@ -0,0 +1,218 @@+/**+ * deleteCreation() + source-upload tracking (the "Your creations" delete flow).+ *+ * A creation must be fully erasable by its owner: the stored GLB, the stored+ * preview, every recorded source upload (an image-to-3D run's reference+ * photos), and the row itself. These tests pin three contracts:+ *+ * 1. deleteCreation removes every bucket object the row points at (key+ * columns, URL-derived legacy keys, source_image_keys) and then the row.+ * 2. Object-storage failure aborts BEFORE the row delete, so the user can+ * retry; bytes are never stranded without a handle.+ * 3. createCreation resolves bucket-hosted reference URLs to object keys at+ * insert time and drops provider-hosted ones (not ours to delete).+ *+ * Only the db/object-storage boundaries are stubbed, matching this repo's+ * forge-store test conventions (see tests/forge-store-materialize.test.js).+ */+import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest';++beforeAll(() => {+ Object.assign(process.env, {+ DATABASE_URL: 'postgres://test:test@localhost:5432/test',+ S3_ENDPOINT: 'https://s3.example.com',+ S3_BUCKET: 'test-bucket',+ S3_PUBLIC_DOMAIN: 'https://cdn.example.com',+ S3_ACCESS_KEY_ID: 'test-key',+ S3_SECRET_ACCESS_KEY: 'test-secret',+ });+});++let selectRows = [];+const sqlMock = vi.fn(async (strings, ...values) => {+ const text = Array.isArray(strings) ? strings.join(' ') : String(strings);+ if (text.includes('select')) return selectRows;+ return [];+});++vi.mock('../api/_lib/db.js', () => ({+ sql: (...args) => sqlMock(...args),+ isDbUnavailableError: () => false,+}));++const deleteObjectMock = vi.fn(async () => {});+vi.mock('../api/_lib/r2.js', () => ({+ putObject: vi.fn(async () => {}),+ publicUrl: (key) => `https://cdn.example.com/${key}`,+ deleteObject: (...args) => deleteObjectMock(...args),+ keyFromPublicUrl: (url) =>+ typeof url === 'string' && url.startsWith('https://cdn.example.com/')+ ? url.slice('https://cdn.example.com/'.length).split(/[?#]/)[0]+ : null,+}));++vi.mock('../api/_lib/forge-events.js', () => ({+ recordGenerationEvent: vi.fn(async () => {}),+}));++const { deleteCreation, createCreation } = await import('../api/_lib/forge-store.js');++afterEach(() => {+ sqlMock.mockClear();+ deleteObjectMock.mockClear();+ deleteObjectMock.mockImplementation(async () => {});+ selectRows = [];+});++function deleteStatements() {+ return sqlMock.mock.calls+ .map(([strings]) => (Array.isArray(strings) ? strings.join(' ') : String(strings)))+ .filter((t) => t.includes('delete from forge_creations'));+}++describe('deleteCreation', () => {+ it('removes the stored GLB, preview, source uploads, and the row', async () => {+ selectRows = [+ {+ id: 'c-1',+ glb_key: 'forge/client-abc/c-1.glb',+ glb_url: 'https://cdn.example.com/forge/client-abc/c-1.glb',+ preview_key: 'forge/client-abc/c-1.png',+ preview_image_url: 'https://cdn.example.com/forge/client-abc/c-1.png',+ source_image_keys: ['forge/uploads/client-abc/photo-1.jpg', 'forge/uploads/client-abc/photo-2.jpg'],+ },+ ];+ const out = await deleteCreation({ id: 'c-1', clientKey: 'client-key' });+ expect(out).toBe('deleted');+ const deletedKeys = deleteObjectMock.mock.calls.map(([k]) => k).sort();+ expect(deletedKeys).toEqual([+ 'forge/client-abc/c-1.glb',+ 'forge/client-abc/c-1.png',+ 'forge/uploads/client-abc/photo-1.jpg',+ 'forge/uploads/client-abc/photo-2.jpg',+ ]);+ expect(deleteStatements()).toHaveLength(1);+ });++ it('derives legacy keys from URLs when the key columns are empty', async () => {+ // Rows written before the *_key columns (or whose preview copy failed and+ // still points at the raw upload) must still have their bytes removed.+ selectRows = [+ {+ id: 'c-2',+ glb_key: null,+ glb_url: 'https://cdn.example.com/forge/client-abc/c-2.glb',+ preview_key: null,+ preview_image_url: 'https://cdn.example.com/forge/uploads/client-abc/original.png',+ source_image_keys: null,+ },+ ];+ const out = await deleteCreation({ id: 'c-2', clientKey: 'client-key' });+ expect(out).toBe('deleted');+ const deletedKeys = deleteObjectMock.mock.calls.map(([k]) => k).sort();+ expect(deletedKeys).toEqual([+ 'forge/client-abc/c-2.glb',+ 'forge/uploads/client-abc/original.png',+ ]);+ });++ it('never deletes outside the forge/ namespace, even from a poisoned row', async () => {+ selectRows = [+ {+ id: 'c-3',+ glb_key: 'u/someone-else/avatar.glb',+ glb_url: 'https://cdn.example.com/u/someone-else/avatar.glb',+ preview_key: 'forge/client-abc/c-3.png',+ preview_image_url: null,+ source_image_keys: ['../../etc/passwd', 'u/victim/photo.png'],+ },+ ];+ const out = await deleteCreation({ id: 'c-3', clientKey: 'client-key' });+ expect(out).toBe('deleted');+ expect(deleteObjectMock.mock.calls.map(([k]) => k)).toEqual(['forge/client-abc/c-3.png']);+ });++ it("returns not_found for a row the caller doesn't own, touching nothing", async () => {+ selectRows = [];+ const out = await deleteCreation({ id: 'c-4', clientKey: 'client-key' });+ expect(out).toBe('not_found');+ expect(deleteObjectMock).not.toHaveBeenCalled();+ expect(deleteStatements()).toHaveLength(0);+ });++ it('keeps the row when object storage refuses, so the user can retry', async () => {+ selectRows = [+ {+ id: 'c-5',+ glb_key: 'forge/client-abc/c-5.glb',+ glb_url: null,+ preview_key: null,+ preview_image_url: null,+ source_image_keys: null,+ },+ ];+ deleteObjectMock.mockImplementation(async () => {+ throw new Error('storage down');+ });+ const out = await deleteCreation({ id: 'c-5', clientKey: 'client-key' });+ expect(out).toBe('error');+ expect(deleteStatements()).toHaveLength(0);+ });+});++describe('createCreation source-upload tracking', () => {+ function insertedValues() {+ const call = sqlMock.mock.calls.find(([strings]) =>+ (Array.isArray(strings) ? strings.join(' ') : '').includes('insert into forge_creations'),+ );+ return call ? call.slice(1) : [];+ }++ it('records bucket-hosted reference views as object keys, dropping external URLs', async () => {+ const id = await createCreation({+ clientKey: 'client-key',+ prompt: 'me as a 3d model',+ previewImageUrl: 'https://cdn.example.com/forge/uploads/client-abc/selfie.jpg',+ sourceImageUrls: [+ 'https://cdn.example.com/forge/uploads/client-abc/selfie.jpg',+ 'https://cdn.example.com/forge/uploads/client-abc/side-view.jpg',+ 'https://replicate.delivery/pbxt/external-flux-view.png',+ ],+ backend: 'trellis',+ tier: 'standard',+ path: 'image',+ });+ expect(id).toBeTruthy();+ const stored = insertedValues().find((v) => typeof v === 'string' && v.startsWith('['));+ expect(JSON.parse(stored)).toEqual([+ 'forge/uploads/client-abc/selfie.jpg',+ 'forge/uploads/client-abc/side-view.jpg',+ ]);+ });++ it('falls back to the preview URL when no explicit list is passed', async () => {+ await createCreation({+ clientKey: 'client-key',+ prompt: 'single view',+ previewImageUrl: 'https://cdn.example.com/forge/uploads/client-abc/only.png',+ backend: 'trellis',+ tier: 'standard',+ path: 'image',+ });+ const stored = insertedValues().find((v) => typeof v === 'string' && v.startsWith('['));+ expect(JSON.parse(stored)).toEqual(['forge/uploads/client-abc/only.png']);+ });++ it('stores null for text-to-3D rows whose preview is provider-hosted', async () => {+ await createCreation({+ clientKey: 'client-key',+ prompt: 'a fox',+ previewImageUrl: 'https://replicate.delivery/pbxt/flux-preview.png',+ backend: 'trellis',+ tier: 'standard',+ path: 'text',+ });+ const stored = insertedValues().find((v) => typeof v === 'string' && v.startsWith('['));+ expect(stored).toBeUndefined();+ });+});diff --git a/tests/r2-key-from-public-url.test.js b/tests/r2-key-from-public-url.test.jsnew file mode 100644index 000000000..c1db3e87c--- /dev/null+++ b/tests/r2-key-from-public-url.test.js@@ -0,0 +1,43 @@+/**+ * keyFromPublicUrl() is the reverse of publicUrl(): it resolves a public CDN+ * URL back to the bucket key it serves, so deletion paths (forge-store+ * deleteCreation) can remove the actual bytes behind a URL-bearing column.+ * Real module, env stubbed only.+ */+import { describe, it, expect, beforeAll } from 'vitest';++beforeAll(() => {+ Object.assign(process.env, {+ S3_ENDPOINT: 'https://s3.example.com',+ S3_BUCKET: 'test-bucket',+ S3_PUBLIC_DOMAIN: 'https://cdn.example.com',+ S3_ACCESS_KEY_ID: 'test-key',+ S3_SECRET_ACCESS_KEY: 'test-secret',+ });+});++const { keyFromPublicUrl, publicUrl } = await import('../api/_lib/r2.js');++describe('keyFromPublicUrl', () => {+ it('round-trips publicUrl, including keys with encodable characters', () => {+ for (const key of [+ 'forge/uploads/client-abc/photo.jpg',+ 'forge/client-abc/creation.glb',+ 'forge/uploads/client-abc/my photo (1).png',+ ]) {+ expect(keyFromPublicUrl(publicUrl(key))).toBe(key);+ }+ });++ it('strips query strings and fragments', () => {+ expect(keyFromPublicUrl('https://cdn.example.com/forge/a.glb?x=1#frag')).toBe('forge/a.glb');+ });++ it('returns null for URLs outside our bucket domain', () => {+ expect(keyFromPublicUrl('https://replicate.delivery/pbxt/thing.png')).toBeNull();+ expect(keyFromPublicUrl('https://cdn.example.com.evil.com/forge/a.glb')).toBeNull();+ expect(keyFromPublicUrl('https://cdn.example.com')).toBeNull();+ expect(keyFromPublicUrl(null)).toBeNull();+ expect(keyFromPublicUrl('')).toBeNull();+ });+});