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.

Pose studio: unsaved-work recovery prompt, overflow menu, mobile panels

nirholasff914e261beb
diff --git a/pages/pose.html b/pages/pose.html
index 9630b25a3..f30a646e2 100644
--- a/pages/pose.html
+++ b/pages/pose.html
@@ -56,7 +56,7 @@
--text-3: #71717a;
--accent: #ffffff;
--accent-2: #cccccc;
- --danger: var(--danger);
+ --danger: #f87171;
--ok: #ffffff;
--nav-h: 69px;
}
@@ -95,13 +95,34 @@
grid-area: top;
display: flex;
align-items: center;
- gap: 10px;
+ gap: 6px;
padding: 0 14px;
border-bottom: 1px solid var(--border);
background: rgba(0, 0, 0, 0.85);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
z-index: 10;
+ scrollbar-width: none;
+ }
+ /* Neutralize style.css's legacy `header:not(.nav)` chrome: it
+ forces height/line-height 56px (buttons inherit it via
+ `font: inherit` and balloon into oversized pills) and marks the
+ bar as an app-drag region. That selector hides an ID inside
+ :has(), so a bare #pose-top loses — double the ID to outrank it.
+ The grid row sizes this bar; overflow-x is the narrow-width
+ safety net so buttons scroll instead of truncating mid-label. */
+ #pose-app #pose-top {
+ height: auto;
+ line-height: 1.45;
+ -webkit-app-region: no-drag;
+ overflow-x: auto;
+ overflow-y: hidden;
+ }
+ #pose-top::-webkit-scrollbar {
+ display: none;
+ }
+ #pose-top > * {
+ flex-shrink: 0;
}
#pose-top .brand {
display: flex;
@@ -245,6 +266,72 @@
display: none;
}
+ /* Overflow ("More") menu — low-frequency toolbar actions live here so
+ the top bar never truncates at laptop widths. The panel is
+ position:fixed and placed from the trigger's rect in JS, so the
+ scrollable top bar can never clip it. */
+ #pose-more {
+ font-size: 16px;
+ letter-spacing: 0.08em;
+ padding: 6px 10px;
+ line-height: 1;
+ }
+ #pose-more[aria-expanded='true'] {
+ background: rgba(255, 255, 255, 0.12);
+ color: var(--text);
+ }
+ .pose-menu {
+ position: fixed;
+ min-width: 200px;
+ background: var(--panel-solid);
+ border: 1px solid var(--border-strong);
+ border-radius: 12px;
+ padding: 5px;
+ box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ z-index: 200;
+ animation: pose-menu-in 0.14s ease both;
+ }
+ @keyframes pose-menu-in {
+ from {
+ opacity: 0;
+ transform: translateY(-4px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .pose-menu {
+ animation: none;
+ }
+ }
+ .pose-menu[hidden] {
+ display: none;
+ }
+ .pose-menu .pose-btn {
+ width: 100%;
+ box-sizing: border-box;
+ justify-content: flex-start;
+ border-radius: 8px;
+ border-color: transparent;
+ background: transparent;
+ color: var(--text-2);
+ padding: 8px 10px;
+ margin: 0;
+ }
+ .pose-menu .pose-btn:hover,
+ .pose-menu .pose-btn:focus-visible {
+ background: rgba(255, 255, 255, 0.08);
+ color: var(--text);
+ }
+ .pose-menu .pose-btn:focus-visible {
+ outline: none;
+ }
+
/* ── Left panel: joint picker + controls ──────────────── */
#pose-left {
grid-area: left;
@@ -498,6 +585,83 @@
color: var(--danger);
border-color: rgba(248, 113, 113, 0.4);
}
+ #pose-recovery {
+ position: absolute;
+ left: 50%;
+ bottom: 58px;
+ transform: translateX(-50%);
+ display: flex;
+ align-items: center;
+ gap: 18px;
+ width: min(500px, calc(100% - 32px));
+ background: rgba(20, 20, 20, 0.94);
+ border: 1px solid var(--border-strong);
+ border-radius: 14px;
+ padding: 12px 14px 12px 16px;
+ box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
+ backdrop-filter: blur(10px);
+ -webkit-backdrop-filter: blur(10px);
+ z-index: 20;
+ animation: pose-recovery-in 0.22s ease both;
+ }
+ @keyframes pose-recovery-in {
+ from {
+ opacity: 0;
+ transform: translate(-50%, 8px);
+ }
+ to {
+ opacity: 1;
+ transform: translate(-50%, 0);
+ }
+ }
+ .pose-recovery-body {
+ flex: 1 1 auto;
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-width: 0;
+ }
+ .pose-recovery-icon {
+ flex: none;
+ width: 30px;
+ height: 30px;
+ display: grid;
+ place-items: center;
+ border-radius: 8px;
+ background: var(--border);
+ color: var(--text);
+ font-size: 15px;
+ }
+ .pose-recovery-copy {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+ }
+ .pose-recovery-copy strong {
+ font-size: 12.5px;
+ font-weight: 600;
+ color: var(--text);
+ }
+ .pose-recovery-copy span {
+ font-size: 11.5px;
+ color: var(--text-2);
+ }
+ .pose-recovery-actions {
+ flex: none;
+ display: flex;
+ gap: 8px;
+ }
+ @media (max-width: 560px) {
+ #pose-recovery {
+ flex-direction: column;
+ align-items: stretch;
+ gap: 12px;
+ }
+ .pose-recovery-actions {
+ justify-content: flex-end;
+ }
+ }
/* ── Right panel: presets + props ──────────────────── */
#pose-right {
@@ -1673,18 +1837,23 @@
@media (max-width: 900px) {
#pose-app {
grid-template-columns: 1fr;
- grid-template-rows: 52px minmax(46vh, 1fr) auto auto;
+ grid-template-rows: 52px minmax(46vh, 1fr) auto auto auto;
grid-template-areas:
'top'
'stage'
'timeline'
+ 'right'
'left';
/* Stacked panels can exceed one screen — let the page scroll. */
height: auto;
min-height: calc(100dvh - var(--nav-h));
}
+ /* Animation library + presets stay reachable on small screens:
+ they stack under the timeline instead of disappearing. */
#pose-right {
- display: none;
+ border-left: none;
+ border-top: 1px solid var(--border);
+ max-height: 44vh;
}
#pose-left {
border-right: none;
@@ -1695,6 +1864,12 @@
.tl-field-name {
display: none;
}
+ /* The empty-state hint wraps on narrow screens and collides
+ with the ruler labels — scrim the whole track while empty. */
+ .tl-empty {
+ inset: 0;
+ background: rgba(0, 0, 0, 0.6);
+ }
}
</style>
@@ -1839,27 +2014,49 @@
Reset pose
</button>
- <label class="pose-btn file-label" title="Load a pose from JSON" data-i18n-attr="title:pose.load_a_pose_from_json_title">
- Import
+ <button
+ type="button"
+ id="pose-more"
+ class="pose-btn"
+ title="More actions"
+ aria-label="More actions"
+ aria-haspopup="menu"
+ aria-expanded="false"
+ aria-controls="pose-more-menu"
+ >
+ ⋯
+ </button>
+ </header>
+
+ <!-- Overflow menu panel. Lives OUTSIDE the scrollable top bar
+ (position:fixed, placed from the trigger's rect in JS) so
+ focusing its items can never scroll or clip the toolbar. -->
+ <div class="pose-menu" id="pose-more-menu" role="menu" aria-label="More actions" hidden>
+ <label class="pose-btn file-label" role="menuitem" tabindex="-1" title="Load a pose from JSON" data-i18n-attr="title:pose.load_a_pose_from_json_title">
+ Import pose JSON
<input type="file" id="pose-import-json" accept="application/json,.json" />
</label>
<button
type="button"
id="pose-export-json"
class="pose-btn"
+ role="menuitem"
+ tabindex="-1"
title="Save pose as JSON"
data-i18n="pose.export_json" data-i18n-attr="title:pose.save_pose_as_json_title">
- Export JSON
+ Export pose JSON
</button>
<button
type="button"
id="pose-screenshot"
class="pose-btn"
+ role="menuitem"
+ tabindex="-1"
title="Download a PNG of the current view"
data-i18n="pose.png_screenshot" data-i18n-attr="title:pose.download_a_png_of_the_curren_title">
PNG screenshot
</button>
- </header>
+ </div>
<!-- LEFT PANEL -->
<aside id="pose-left">
@@ -2199,6 +2396,9 @@
<div class="h-footer-bottom">
<p class="h-footer-legal" data-i18n="pose.2026_three_ws_all_rights_reserved">© 2026 three.ws — All rights reserved.</p>
<div class="h-footer-legal-links">
+ <!-- Placing the switcher here keeps i18n.js from mounting its
+ floating fallback, which sat on top of the timeline. -->
+ <lang-switcher></lang-switcher>
<a href="/legal/privacy" data-i18n="pose.privacy">Privacy</a>
<a href="/legal/tos" data-i18n="pose.terms">Terms</a>
</div>
diff --git a/src/pose-studio.js b/src/pose-studio.js
index 21f27b356..9daa7f37c 100644
--- a/src/pose-studio.js
+++ b/src/pose-studio.js
@@ -991,6 +991,64 @@ function boot() {
});
// ── Top toolbar ──────────────────────────────────────────────────────────
+
+ // Overflow ("More") menu: low-frequency actions (import/export pose JSON,
+ // PNG screenshot) collapse behind one trigger so the bar fits laptop
+ // widths. The panel is position:fixed and placed from the trigger's rect,
+ // because the scrollable top bar would clip an absolutely-positioned child.
+ const moreBtn = $('#pose-more');
+ const moreMenu = $('#pose-more-menu');
+ if (moreBtn && moreMenu) {
+ const menuItems = () => [...moreMenu.querySelectorAll('[role="menuitem"]')];
+ const openMenu = () => {
+ const r = moreBtn.getBoundingClientRect();
+ moreMenu.hidden = false;
+ moreMenu.style.top = `${Math.round(r.bottom + 6)}px`;
+ moreMenu.style.right = `${Math.max(8, Math.round(window.innerWidth - r.right))}px`;
+ moreBtn.setAttribute('aria-expanded', 'true');
+ menuItems()[0]?.focus();
+ };
+ const closeMenu = (refocus = false) => {
+ if (moreMenu.hidden) return;
+ moreMenu.hidden = true;
+ moreBtn.setAttribute('aria-expanded', 'false');
+ if (refocus) moreBtn.focus();
+ };
+ moreBtn.addEventListener('click', () => {
+ if (moreMenu.hidden) openMenu();
+ else closeMenu();
+ });
+ moreMenu.addEventListener('keydown', (ev) => {
+ const list = menuItems();
+ const idx = list.indexOf(document.activeElement);
+ if (ev.key === 'Escape') {
+ closeMenu(true);
+ } else if (ev.key === 'ArrowDown') {
+ ev.preventDefault();
+ list[(idx + 1) % list.length]?.focus();
+ } else if (ev.key === 'ArrowUp') {
+ ev.preventDefault();
+ list[(idx - 1 + list.length) % list.length]?.focus();
+ } else if (
+ (ev.key === 'Enter' || ev.key === ' ') &&
+ document.activeElement?.classList?.contains('file-label')
+ ) {
+ // A <label> doesn't activate its file input from the keyboard.
+ ev.preventDefault();
+ document.activeElement.querySelector('input[type="file"]')?.click();
+ }
+ });
+ moreMenu.addEventListener('click', (ev) => {
+ if (ev.target.closest('[role="menuitem"]')) closeMenu();
+ });
+ document.addEventListener('pointerdown', (ev) => {
+ if (!moreMenu.hidden && !ev.target.closest('#pose-more, #pose-more-menu')) {
+ closeMenu();
+ }
+ });
+ window.addEventListener('resize', () => closeMenu());
+ }
+
$('#pose-reset')?.addEventListener('click', () => {
recordHistory();
state.rig.resetPose();
@@ -1209,7 +1267,11 @@ function boot() {
// warn before unload while the current state differs from the last point it
// was persisted (an account save, or opening a saved clip). On the next boot
// the draft is offered back — unless an explicit deep-link (?anim=) wins.
- const autosave = setupAutosave();
+ // The recovery offer banner (last session's unsaved work), when showing.
+ let recoveryBanner = null;
+ // onSupersede fires when a still-pending recovery offer is overtaken by fresh
+ // work (the user started posing instead of answering) — dismiss the banner.
+ const autosave = setupAutosave({ onSupersede: () => dismissRecoveryPrompt() });
// ── Animation preset library ─────────────────────────────────────────────
// A curated gallery of ready-to-apply motion clips. Picking one retargets it
@@ -1750,7 +1812,7 @@ function boot() {
// Local crash-recovery for in-progress timeline work. Returns null when the
// page has no timeline (the studio markup is absent) so callers no-op safely.
- function setupAutosave() {
+ function setupAutosave({ onSupersede } = {}) {
if (!timeline) return null;
const DRAFT_KEY = 'pose-studio:draft:v2';
// savedBaseline = the document JSON at the last persisted point (account
@@ -1758,6 +1820,11 @@ function boot() {
// the interval skips redundant writes.
let savedBaseline = JSON.stringify(timeline.getDocument());
let lastDraftJson = null;
+ // True while a recovered draft is being OFFERED but not yet applied. The
+ // timeline is empty in that window, so without this guard the periodic
+ // persistDraft() would clear the on-disk draft out from under the prompt
+ // (a reload before the user chooses would then lose the work).
+ let restorePending = false;
const currentJson = () => JSON.stringify(timeline.getDocument());
@@ -1782,6 +1849,14 @@ function boot() {
}
function persistDraft() {
+ // While a recovered draft is being offered, leave it on disk, unless the
+ // user has started fresh keyframe work without answering, in which case
+ // the offer is superseded and this new work takes over the draft slot.
+ if (restorePending) {
+ if (!timeline.getDocument().keyframes.length) return;
+ restorePending = false;
+ onSupersede?.();
+ }
const cur = currentJson();
if (cur === lastDraftJson) return;
lastDraftJson = cur;
@@ -1810,20 +1885,33 @@ function boot() {
clearDraft();
}
- // Offer the previous session's unsaved draft back. Restored work stays
- // "unsaved" (it isn't in the account yet), so the unload guard keeps
- // protecting it until the user Saves.
- function tryRestore() {
+ // Read (without applying) the previous session's unsaved draft, if any.
+ // Boot uses this to OFFER recovery rather than silently applying keyframes
+ // onto whatever rig happens to be loaded — auto-applying a pose made on a
+ // different avatar contorts the mannequin and gives no way back to a clean
+ // figure. Returns { doc, count, savedAt, avatarId } or null.
+ function peekDraft() {
const saved = readDraft();
const count = saved?.doc?.keyframes?.length || 0;
- if (!count) return false;
- timeline.loadDocument(saved.doc);
+ if (!count) return null;
+ // Freeze the on-disk draft until the offer is resolved (see restorePending).
+ restorePending = true;
+ return { doc: saved.doc, count, savedAt: saved.savedAt || null, avatarId: saved.avatarId || null };
+ }
+
+ // Apply a peeked draft's timeline to the live rig. Restored work stays
+ // "unsaved" (it isn't in the account yet), so the unload guard keeps
+ // protecting it until the user Saves.
+ function applyDraft(doc) {
+ restorePending = false;
+ if (!doc) return;
+ timeline.loadDocument(doc);
lastDraftJson = currentJson();
- const when = saved.savedAt ? new Date(saved.savedAt).toLocaleTimeString() : 'a previous session';
- setStatus(
- `Recovered your unsaved animation — ${count} keyframe${count === 1 ? '' : 's'} from ${when}. Save it to keep it.`,
- );
- return true;
+ }
+
+ function discardDraft() {
+ restorePending = false;
+ clearDraft();
}
const interval = setInterval(persistDraft, 1500);
@@ -1839,7 +1927,7 @@ function boot() {
});
window.addEventListener('pagehide', () => clearInterval(interval));
- return { markSaved, tryRestore, hasUnsavedWork };
+ return { markSaved, peekDraft, applyDraft, discardDraft, hasUnsavedWork };
}
// ── Account: save + "My animations" library ──────────────────────────────
@@ -1875,8 +1963,67 @@ function boot() {
const requestedSpell = (_params.get('spell') || '').slice(0, 40);
// An explicit ?anim=, ?spell= or model deep-link wins over any recovered
- // draft; otherwise we offer back last session's unsaved work.
- const recovered = !requestedAnim && !requestedSrc && !requestedSpell && autosave?.tryRestore();
+ // draft; otherwise we OFFER back last session's unsaved work (see boot tail).
+ const hasDeepLink = requestedAvatar || requestedSrc || requestedAnim || requestedSpell;
+ const pendingDraft = !hasDeepLink ? autosave?.peekDraft() : null;
+
+ // Offer the previous session's unsaved work as an explicit choice instead of
+ // silently applying it. Keeps the clean default figure on screen until the
+ // user opts in; Restore reloads the avatar the pose was made on, then applies
+ // the keyframes; Discard drops the local draft for good.
+ function showRecoveryPrompt(draft) {
+ const canvasWrap = document.getElementById('pose-canvas')?.parentElement || document.body;
+ dismissRecoveryPrompt();
+
+ const when = draft.savedAt ? new Date(draft.savedAt).toLocaleTimeString() : 'a previous session';
+
+ const restore = async () => {
+ dismissRecoveryPrompt();
+ setStatus('Restoring your animation…');
+ // Reload the avatar the draft was posed on so the keyframes land on the
+ // same rig (a pose made on a rigged avatar looks wrong on the mannequin).
+ // Apply the timeline regardless of whether that avatar still resolves.
+ if (draft.avatarId && draft.avatarId !== state.avatar?.id) {
+ try {
+ await loadAvatarById(draft.avatarId);
+ } catch (err) {
+ log.warn('[pose] recovery avatar reload failed:', err?.message);
+ setStatus(`Original avatar unavailable (${err?.message || 'removed'}); restoring onto the mannequin.`, 'error');
+ }
+ }
+ autosave.applyDraft(draft.doc);
+ setStatus(
+ `Recovered your unsaved animation. ${draft.count} keyframe${draft.count === 1 ? '' : 's'} from ${when}. Save it to keep it.`,
+ );
+ };
+ const discard = () => {
+ dismissRecoveryPrompt();
+ autosave.discardDraft();
+ setStatus('Ready. Click a body part to pose, or load an avatar.');
+ };
+
+ recoveryBanner = el('div', { id: 'pose-recovery', role: 'status', 'aria-live': 'polite' }, [
+ el('div', { class: 'pose-recovery-body' }, [
+ el('div', { class: 'pose-recovery-icon', 'aria-hidden': 'true' }, ['↺']),
+ el('div', { class: 'pose-recovery-copy' }, [
+ el('strong', {}, ['Unsaved animation found']),
+ el('span', {}, [
+ `${draft.count} keyframe${draft.count === 1 ? '' : 's'} from ${when}. Restore it or start fresh.`,
+ ]),
+ ]),
+ ]),
+ el('div', { class: 'pose-recovery-actions' }, [
+ el('button', { class: 'pose-btn pose-btn-ghost', type: 'button', onclick: discard }, ['Discard']),
+ el('button', { class: 'pose-btn pose-btn-primary', type: 'button', onclick: restore }, ['Restore']),
+ ]),
+ ]);
+ canvasWrap.appendChild(recoveryBanner);
+ }
+
+ function dismissRecoveryPrompt() {
+ recoveryBanner?.remove();
+ recoveryBanner = null;
+ }
// A 36-char UUID is a saved community clip (PoseLibrary.openById); anything
// else is a built-in preset name from the animation library (AnimationLibrary
@@ -1930,8 +2077,11 @@ function boot() {
// A ?src= deep-link that failed the trusted-host gate: say why instead of
// silently opening an empty studio.
setStatus('That model link is not from a trusted host. Pick an avatar instead.', 'error');
+ } else if (pendingDraft) {
+ setStatus('Ready. Click a body part to pose, or load an avatar.');
+ showRecoveryPrompt(pendingDraft);
} else {
- if (!recovered) setStatus('Ready. Click a body part to pose, or load an avatar.');
+ setStatus('Ready. Click a body part to pose, or load an avatar.');
}
}