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.

feat(create-agent): autosave guest drafts so a build survives leaving the page

nirholas9582ce86de3d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4344cca7b..bfc336406 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Language links now always win, and the switcher stays out of the way** — Two fixes for the new 41-language experience. Opening a link with a language in the URL (like ?lang=te for Telugu) now always shows that language, even if you had previously browsed in another one; before, your first visit's language silently overrode every shared link. The floating language switcher also joins the site's shared bottom-corner layout, so it no longer overlaps the Getting Started guide. (`/what-is?lang=te`) `[fix, improvement]`
- **Marketplace checkout: visible steps and proof-phase launch pricing** — Buying a skill now shows the whole flow up front (Connect, Approve, Confirm, Record) with live progress instead of one changing status line. Creators' dynamic pricing rules (like a cheaper price for the first N buyers) now genuinely apply at checkout, and active proof-phase promos display the struck-through list price with a real spots-left counter. (`/marketplace`) `[improvement, fix]`
- **Markets data now survives outages with five new free sources** — The markets hub picked up a deeper safety net of free public data sources. Bitcoin, Ethereum and Solana price charts and headline prices now fall back to live exchange data (Kraken, Coinbase, Bitfinex) whenever the primary aggregator is rate-limited, so the /coins charts keep drawing instead of going blank. The /derivatives perp table gains a Hyperliquid backup with live funding, open interest and volume for about 200 contracts. Solana token panels add Raydium's own pool index as a final price source, and the paid Market Mood endpoint now includes Deribit's DVOL implied-volatility index for BTC and ETH at no extra cost. (`/coins`) `[improvement, infra]`
+- **More paid agent services now settle on the x402 marketplace** — Fixed a payment bug where an endpoint's own listing text, echoed back inside the payment envelope, was rejected by the Coinbase settlement layer, so many of our pay-per-call agent services silently failed to settle on Base and never appeared in the agent marketplace. Payments now carry a clean envelope and settle reliably, bringing dozens more three.ws services (model inspection, gas and market data, avatar pipelines, identity and reputation checks) into agent discovery. Also repaired the model-check sample link that pointed at a missing asset. `[fix, infra]`
- **Motion Swap now captures hands and fingers** — Motion capture from video just got hands. When you swap yourself for your avatar at /motion-swap, the capture now tracks both hands (21 points each) and solves every finger joint, so waves, counting, pointing, and sign-language handshapes come through on your avatar instead of a stiff flat hand. Wrist rotation is also solved from the palm itself, making hand orientation far more faithful. Works with any rigged avatar; if your hands leave the frame the capture holds the last hand pose instead of snapping flat. (`/motion-swap`) `[improvement]`
- **Motion Swap: replace yourself in a video with your 3D avatar** — Upload a video of yourself (a house tour, a demo, a walk-through) at /motion-swap and get it back with your avatar performing your exact motion instead of you. The platform tracks your body pose in every frame, masks you out, and pins your chosen avatar over you, matching your position and size; you stay pixelated underneath. Compositing and video export run right in your browser, and any rigged humanoid GLB works, including avatars you generated or captured from a selfie. (`/motion-swap`) `[feature]`
- **Steadier free 3D generation and model snapshots** — Two reliability fixes for the free lanes: the model snapshot renderer no longer fails under a burst of simultaneous requests (renders now queue instead of overloading the server, with more memory behind them), and free text-to-3D requests no longer time out early when the primary GPU provider is degraded; the fallback lane now gets the time it needs to finish your model. `[fix, infra]`
@@ -76,6 +77,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Docs · Voice Lab** (`/docs/voice-lab`) — Clone your voice from a short browser recording, play it in the TTS playground, and assign it to an agent.
- **Docs · x402 Studio** (`/docs/x402-studio`) — The merchant console for running a paid x402 business: products and pricing, payout and agent wallets, real USDC send and receive with .sol resolution, a storefront and pay-button builder, giving, and security.
- **36 new in-depth feature guides in the docs** — The docs now carry a dedicated, in-depth guide for every major studio and surface that was missing one: the 3D creation studios (Forge, Image to 3D, Diorama, Cosmos, Splat viewer, Scene Capture, Restyle, Scene Studio, Scene Composer, Animation Studio, Avatar Studio, Mocap Studio, Selfie to Avatar, Daily Forge, AR Studio), voice and video (Voice Lab, Lipsync, Talking Avatar Video), agent building (Instant Agent Genesis, Agent Genome, Agent Studio, Multi-LLM Brain, Agent Galaxy, Integrations), and the trading and markets surfaces (Coin Autopilot, Signal Marketplace, the AGI, Alpha Co-pilot, Guardian, Strategy Objects, Mission Control, Smart Money Radar, Coin Radar, Coin Clash, x402 Studio, Fact Check). Each guide explains why the feature exists, how it actually works, a first-time walkthrough, runnable examples, its states and limits, and links to related surfaces. Browse them from the docs sidebar. (`/docs/forge`) `[docs]`
+- **Build an agent, leave, come back: never lose a build in progress** — The create-agent wizard now autosaves your work as you go, so a signed-out visitor who starts building and then closes the tab can return and pick up on the exact step they left, with everything filled in. A subtle Start fresh option is always one click away if you would rather begin anew, and abandoned drafts expire after a week. This closes the last gap in the try-first flow: you can now build across visits without an account, and only sign in at the final ship step. (`/create-agent`) `[improvement]`
- **Image understanding is more reliable across every image host** — The vision endpoint (used to describe and check 3D renders and avatars) now fetches your image itself and hands it straight to the free model, instead of asking the model's server to go fetch the link. Some image hosts block that server-side fetch, which used to push the request onto a paid fallback and, when that fallback was unavailable, fail outright. Now the free lane serves the request regardless of how the image is hosted, so describe/critique calls stop returning errors on perfectly good images. (`/pulse`) `[fix, improvement]`
- **New: a 3D avatar assistant widget for any website** — One script tag now puts a three.ws avatar on any site as a floating assistant. Click the launcher and a real animated 3D character pops up, standing directly on the page (transparent), or against a color or gradient you pick. It has two modes: a chatbot that answers visitors' questions using the free model chain, with the option to bring your own Groq or OpenRouter key that never leaves the browser, and a speak mode where the avatar says exactly what you type, out loud, with a speech bubble. Configure everything and copy your snippet at three.ws/assistant. (`/assistant`) `[feature]`
- **On-chain reads stay smooth when a data provider hits its daily cap** — The platform reads Solana through a prioritized chain of RPC providers and automatically fails over the instant one is throttled. It now recognizes the specific 'daily request limit reached' signal that metered providers return when a plan's daily quota is spent, and parks that provider for the rest of the day instead of re-checking it every few minutes. On-chain data (balances, prices, live trades) keeps flowing through a healthy provider without a stumble, and the failover leaves the retry chatter behind. A dedicated reserve endpoint was also wired in as deep insurance for the rare case the whole free provider pool is down at once. `[infra, improvement]`
diff --git a/data/changelog.json b/data/changelog.json
index 296b11dbc..f183d70dd 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,24 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-07-18",
+ "title": "Build an agent, leave, come back: never lose a build in progress",
+ "summary": "The create-agent wizard now autosaves your work as you go, so a signed-out visitor who starts building and then closes the tab can return and pick up on the exact step they left, with everything filled in. A subtle Start fresh option is always one click away if you would rather begin anew, and abandoned drafts expire after a week. This closes the last gap in the try-first flow: you can now build across visits without an account, and only sign in at the final ship step.",
+ "tags": [
+ "improvement"
+ ],
+ "link": "/create-agent"
+ },
+ {
+ "date": "2026-07-19",
+ "title": "More paid agent services now settle on the x402 marketplace",
+ "summary": "Fixed a payment bug where an endpoint's own listing text, echoed back inside the payment envelope, was rejected by the Coinbase settlement layer, so many of our pay-per-call agent services silently failed to settle on Base and never appeared in the agent marketplace. Payments now carry a clean envelope and settle reliably, bringing dozens more three.ws services (model inspection, gas and market data, avatar pipelines, identity and reputation checks) into agent discovery. Also repaired the model-check sample link that pointed at a missing asset.",
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-07-19",
"title": "Steadier free 3D generation and model snapshots",
diff --git a/public/changelog.json b/public/changelog.json
index 744f637d9..30f87c452 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-19T15:09:18.622Z",
+ "generated_at": "2026-07-19T20:34:15.672Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -186,6 +186,17 @@
"infra"
]
},
+ {
+ "date": "2026-07-19",
+ "type": "update",
+ "title": "More paid agent services now settle on the x402 marketplace",
+ "summary": "Fixed a payment bug where an endpoint's own listing text, echoed back inside the payment envelope, was rejected by the Coinbase settlement layer, so many of our pay-per-call agent services silently failed to settle on Base and never appeared in the agent marketplace. Payments now carry a clean envelope and settle reliably, bringing dozens more three.ws services (model inspection, gas and market data, avatar pipelines, identity and reputation checks) into agent discovery. Also repaired the model-check sample link that pointed at a missing asset.",
+ "link": null,
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-07-19",
"type": "update",
@@ -693,6 +704,16 @@
"docs"
]
},
+ {
+ "date": "2026-07-18",
+ "type": "update",
+ "title": "Build an agent, leave, come back: never lose a build in progress",
+ "summary": "The create-agent wizard now autosaves your work as you go, so a signed-out visitor who starts building and then closes the tab can return and pick up on the exact step they left, with everything filled in. A subtle Start fresh option is always one click away if you would rather begin anew, and abandoned drafts expire after a week. This closes the last gap in the try-first flow: you can now build across visits without an account, and only sign in at the final ship step.",
+ "link": "/create-agent",
+ "tags": [
+ "improvement"
+ ]
+ },
{
"date": "2026-07-18",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 8cd9b53bc..07524d112 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -142,6 +142,14 @@
<category>improvement</category>
<description>The markets hub picked up a deeper safety net of free public data sources. Bitcoin, Ethereum and Solana price charts and headline prices now fall back to live exchange data (Kraken, Coinbase, Bitfinex) whenever the primary aggregator is rate-limited, so the /coins charts keep drawing instead of going blank. The /derivatives perp table gains a Hyperliquid backup with live funding, open interest and volume for about 200 contracts. Solana token panels add Raydium's own pool index as a final price source, and the paid Market Mood endpoint now includes Deribit's DVOL implied-volatility index for BTC and ETH at no extra cost.</description>
</item>
+ <item>
+ <title>More paid agent services now settle on the x402 marketplace</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-07-19:More paid agent services now settle on the x402 marketplace</guid>
+ <pubDate>Sun, 19 Jul 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Fixed a payment bug where an endpoint's own listing text, echoed back inside the payment envelope, was rejected by the Coinbase settlement layer, so many of our pay-per-call agent services silently failed to settle on Base and never appeared in the agent marketplace. Payments now carry a clean envelope and settle reliably, bringing dozens more three.ws services (model inspection, gas and market data, avatar pipelines, identity and reputation checks) into agent discovery. Also repaired the model-check sample link that pointed at a missing asset.</description>
+ </item>
<item>
<title>Motion Swap now captures hands and fingers</title>
<link>https://three.ws/motion-swap</link>
@@ -542,6 +550,14 @@
<category>docs</category>
<description>The docs now carry a dedicated, in-depth guide for every major studio and surface that was missing one: the 3D creation studios (Forge, Image to 3D, Diorama, Cosmos, Splat viewer, Scene Capture, Restyle, Scene Studio, Scene Composer, Animation Studio, Avatar Studio, Mocap Studio, Selfie to Avatar, Daily Forge, AR Studio), voice and video (Voice Lab, Lipsync, Talking Avatar Video), agent building (Instant Agent Genesis, Agent Genome, Agent Studio, Multi-LLM Brain, Agent Galaxy, Integrations), and the trading and markets surfaces (Coin Autopilot, Signal Marketplace, the AGI, Alpha Co-pilot, Guardian, Strategy Objects, Mission Control, Smart Money Radar, Coin Radar, Coin Clash, x402 Studio, Fact Check). Each guide explains why the feature exists, how it actually works, a first-time walkthrough, runnable examples, its states and limits, and links to related surfaces. Browse them from the docs sidebar.</description>
</item>
+ <item>
+ <title>Build an agent, leave, come back: never lose a build in progress</title>
+ <link>https://three.ws/create-agent</link>
+ <guid isPermaLink="false">2026-07-18:Build an agent, leave, come back: never lose a build in progress</guid>
+ <pubDate>Sat, 18 Jul 2026 12:00:00 GMT</pubDate>
+ <category>improvement</category>
+ <description>The create-agent wizard now autosaves your work as you go, so a signed-out visitor who starts building and then closes the tab can return and pick up on the exact step they left, with everything filled in. A subtle Start fresh option is always one click away if you would rather begin anew, and abandoned drafts expire after a week. This closes the last gap in the try-first flow: you can now build across visits without an account, and only sign in at the final ship step.</description>
+ </item>
<item>
<title>Image understanding is more reliable across every image host</title>
<link>https://three.ws/pulse</link>
diff --git a/src/create-agent-draft.js b/src/create-agent-draft.js
new file mode 100644
index 000000000..e6332b8ed
--- /dev/null
+++ b/src/create-agent-draft.js
@@ -0,0 +1,35 @@
+// Pure draft helpers for the create-agent wizard.
+//
+// Kept separate from create-agent.js (which is DOM-bound and boots on import) so
+// the two bits of real logic — "is there anything worth saving?" and "is this
+// draft still fresh?" — can be unit-tested without a browser. The localStorage
+// read/write wrappers stay in create-agent.js and lean on these.
+
+// A draft older than this is stale: don't resurrect a build the visitor
+// abandoned a week ago; start them fresh instead.
+export const DRAFT_TTL_MS = 7 * 24 * 60 * 60 * 1000;
+
+// True once the wizard holds anything worth preserving. Guards autosave so an
+// untouched form never writes an empty draft that would then "resume". Mirrors
+// the wizard's default model mode ('starter' with no pick = untouched).
+export function draftHasContent(state) {
+ if (!state) return false;
+ const s = (v) => (typeof v === 'string' ? v.trim() : '');
+ return Boolean(
+ s(state.name) ||
+ s(state.description) ||
+ (Array.isArray(state.tags) && state.tags.length) ||
+ s(state.greeting) ||
+ s(state.persona) ||
+ state.category ||
+ (state.model && state.model.mode !== 'starter') ||
+ (state.model && state.model.starterId),
+ );
+}
+
+// A draft with no timestamp (older format) is treated as fresh; one past the TTL
+// is stale. `now` is injectable so tests never depend on the wall clock.
+export function isDraftFresh(draft, now = Date.now()) {
+ if (!draft || typeof draft.savedAt !== 'number') return true;
+ return now - draft.savedAt <= DRAFT_TTL_MS;
+}
diff --git a/src/create-agent.js b/src/create-agent.js
index 606871d82..8721fd1e0 100644
--- a/src/create-agent.js
+++ b/src/create-agent.js
@@ -18,6 +18,7 @@ import { peekGuestAgent, clearGuestAgent } from './agents/guest-agent.js';
import { log } from './shared/log.js';
import { isValidGlbMagic } from './shared/glb-magic.js';
import { track, trackFunnelStep, trackError, ANALYTICS_EVENTS } from './analytics.js';
+import { draftHasContent, isDraftFresh } from './create-agent-draft.js';
const TOTAL_STEPS = 5;
const STEP_LABELS = ['Basics', 'Model', 'Skills', 'Personality', 'Review'];
@@ -128,6 +129,8 @@ function saveDraft() {
try {
const d = {
v: 1,
+ savedAt: Date.now(),
+ step: state.step,
name: state.name,
description: state.description,
tags: state.tags,
@@ -160,12 +163,51 @@ function loadDraft() {
const raw = localStorage.getItem(DRAFT_KEY);
if (!raw) return null;
const d = JSON.parse(raw);
- return d && d.v === 1 && typeof d.name === 'string' ? d : null;
+ if (!d || d.v !== 1 || typeof d.name !== 'string') return null;
+ // Expire stale drafts so a long-abandoned build never silently resumes.
+ if (!isDraftFresh(d)) {
+ clearDraft();
+ return null;
+ }
+ return d;
} catch {
return null;
}
}
+// Debounced autosave so a guest who builds and then closes the tab (without
+// reaching the ship step) can pick up exactly where they left off. Only writes
+// once there's real content; never overwrites a draft with an empty form.
+let draftSaveTimer;
+// Set once the agent is created — stops autosave from resurrecting a draft for
+// an agent that already exists (the success screen still holds the state).
+let submitted = false;
+function scheduleDraftSave() {
+ if (submitted) return;
+ clearTimeout(draftSaveTimer);
+ draftSaveTimer = setTimeout(() => {
+ if (draftHasContent(state)) saveDraft();
+ }, 600);
+}
+
+// Actionable "you're resumed, want a clean slate?" note for a returning guest.
+function showResumeNote() {
+ el.footMsg.className = 'foot-msg';
+ el.footMsg.innerHTML =
+ 'Resumed your saved draft. <button type="button" class="msg-link" id="msg-start-fresh">Start fresh</button>';
+ $('msg-start-fresh')?.addEventListener('click', startFresh);
+}
+
+// Abandon the restored draft and start a clean build. Stop autosave first — the
+// `beforeunload` flush would otherwise re-save the draft during the reload and
+// resurrect exactly what we just cleared.
+function startFresh() {
+ submitted = true;
+ clearTimeout(draftSaveTimer);
+ clearDraft();
+ window.location.reload();
+}
+
function clearDraft() {
try {
localStorage.removeItem(DRAFT_KEY);
@@ -235,12 +277,14 @@ async function boot() {
$('page-loading')?.remove();
state.authed = Boolean(me);
- // A saved draft means the visitor built an agent, got sent to sign in, and
- // came back — restore everything and drop them on Review to ship in one click.
+ // A saved draft means the visitor built something before and came back —
+ // either via the ship-step sign-in bounce, or just by leaving and returning
+ // (autosave). Restore it and put them back where they were.
const draft = loadDraft();
if (draft) {
const { uploadLost } = restoreDraft(draft);
if (state.authed) {
+ // Signed in (typically the ship-step bounce): drop straight on Review.
clearDraft();
showStep(TOTAL_STEPS - 1);
setMsg(
@@ -248,7 +292,13 @@ async function boot() {
'ok',
);
} else {
- showStep(0);
+ // Guest returning to an in-progress build: resume the exact step, and
+ // offer a clean start so restore is never a surprise.
+ const savedStep = Number.isInteger(draft.step)
+ ? Math.min(Math.max(draft.step, 0), TOTAL_STEPS - 1)
+ : 0;
+ showStep(uploadLost ? 1 : savedStep);
+ if (!uploadLost) showResumeNote();
}
if (uploadLost) {
setMsg('Re-attach your uploaded model on step 2, or we’ll give it the default body.', '');
@@ -258,6 +308,15 @@ async function boot() {
showStep(0);
}
+ // Autosave the in-progress build: one delegated listener covers every text,
+ // select, and checkbox field; button-driven changes (model, voice, step nav)
+ // are caught by showStep and the unload flush below.
+ el.form.addEventListener('input', scheduleDraftSave);
+ el.form.addEventListener('change', scheduleDraftSave);
+ window.addEventListener('beforeunload', () => {
+ if (!submitted && draftHasContent(state)) saveDraft();
+ });
+
applyAuthAffordances();
}
@@ -380,6 +439,9 @@ function showStep(n) {
);
requestAnimationFrame(() => focusable?.focus?.({ preventScroll: true }));
el.body.scrollIntoView({ behavior: 'smooth', block: 'start' });
+
+ // Persist progress on every step change so a returning guest resumes here.
+ scheduleDraftSave();
}
function wireNav() {
@@ -1421,6 +1483,10 @@ function resetSubmitButton() {
}
function succeed(agent) {
+ // The agent exists now — stop autosave from writing the draft back after it
+ // was cleared (the success screen still holds the form state).
+ submitted = true;
+ clearTimeout(draftSaveTimer);
// Swap the form body for the success state.
el.panels.forEach((p) => p.classList.remove('is-active'));
el.foot.style.display = 'none';
diff --git a/tests/create-agent-draft.test.js b/tests/create-agent-draft.test.js
new file mode 100644
index 000000000..82f6f8fb6
--- /dev/null
+++ b/tests/create-agent-draft.test.js
@@ -0,0 +1,88 @@
+// Tests for the pure create-agent draft helpers — the "is there anything worth
+// saving?" and "is this draft still fresh?" logic behind guest draft autosave.
+
+import { describe, it, expect } from 'vitest';
+import { DRAFT_TTL_MS, draftHasContent, isDraftFresh } from '../src/create-agent-draft.js';
+
+// Minimal state matching the wizard's shape at its untouched default.
+function emptyState() {
+ return {
+ name: '',
+ description: '',
+ tags: [],
+ greeting: '',
+ persona: '',
+ category: '',
+ model: { mode: 'starter', starterId: '' },
+ };
+}
+
+describe('draftHasContent', () => {
+ it('is false for an untouched wizard (no empty-draft autosave)', () => {
+ expect(draftHasContent(emptyState())).toBe(false);
+ });
+
+ it('is false for whitespace-only text fields', () => {
+ const s = emptyState();
+ s.name = ' ';
+ s.persona = '\n\t ';
+ expect(draftHasContent(s)).toBe(false);
+ });
+
+ it('is true once any real field is set', () => {
+ for (const mut of [
+ (s) => (s.name = 'Nova'),
+ (s) => (s.description = 'a guide'),
+ (s) => (s.tags = ['alpha']),
+ (s) => (s.greeting = 'hi'),
+ (s) => (s.persona = 'You are Nova.'),
+ (s) => (s.category = 'education'),
+ ]) {
+ const s = emptyState();
+ mut(s);
+ expect(draftHasContent(s)).toBe(true);
+ }
+ });
+
+ it('is true when the model is no longer the untouched default', () => {
+ const picked = emptyState();
+ picked.model = { mode: 'starter', starterId: 'cz' };
+ expect(draftHasContent(picked)).toBe(true);
+
+ const uploaded = emptyState();
+ uploaded.model = { mode: 'upload', starterId: '' };
+ expect(draftHasContent(uploaded)).toBe(true);
+ });
+
+ it('handles a missing/garbage state without throwing', () => {
+ expect(draftHasContent(null)).toBe(false);
+ expect(draftHasContent(undefined)).toBe(false);
+ expect(draftHasContent({})).toBe(false);
+ });
+});
+
+describe('isDraftFresh', () => {
+ const now = 1_000_000_000_000;
+
+ it('treats a just-saved draft as fresh', () => {
+ expect(isDraftFresh({ savedAt: now }, now)).toBe(true);
+ expect(isDraftFresh({ savedAt: now - 60_000 }, now)).toBe(true);
+ });
+
+ it('treats a draft exactly at the TTL boundary as fresh', () => {
+ expect(isDraftFresh({ savedAt: now - DRAFT_TTL_MS }, now)).toBe(true);
+ });
+
+ it('treats a draft past the TTL as stale', () => {
+ expect(isDraftFresh({ savedAt: now - DRAFT_TTL_MS - 1 }, now)).toBe(false);
+ });
+
+ it('treats a legacy draft with no timestamp as fresh (never drops old data blindly)', () => {
+ expect(isDraftFresh({ name: 'Nova' }, now)).toBe(true);
+ expect(isDraftFresh(null, now)).toBe(true);
+ });
+
+ it('DRAFT_TTL_MS is 7 days', () => {
+ expect(DRAFT_TTL_MS).toBe(7 * 24 * 60 * 60 * 1000);
+ });
+});