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
fix(solana-mobile): keep recognising the app after the first page, and boot Seed Vault on the login page
nirholas65f3fe5c1ed1
diff --git a/solana-mobile/src/seeker-detect.js b/solana-mobile/src/seeker-detect.jsindex 0d971a135..1a545be86 100644--- a/solana-mobile/src/seeker-detect.js+++ b/solana-mobile/src/seeker-detect.js@@ -63,6 +63,54 @@ function isFromAnyAndroidAppReferrer() {return (document.referrer || '').startsWith('android-app://');}+// The android-app:// referrer exists on the FIRST navigation only. Every page+// the user reaches afterwards inside the TWA carries the previous page as its+// referrer, so a detector that only reads the live referrer believes the login+// page, the create flow, and every agent page are a plain browser and never+// installs the Seed Vault wallet (observed in an Android 14 emulator: /app was+// detected, the /login it linked to was not). Remember the signal for the+// lifetime of the installed app instead: once a page has been entered from+// the Android app, or through one of the app's own start/shortcut URLs, every+// later standalone page on this device is the app too.+const TWA_MEMORY_KEY = 'threews:twa';+const APP_ENTRY_SOURCES = new Set(['seeker_app', 'seeker_shortcut', 'seeker_dapp_store']);++function isFromAppEntryUrl() {+ if (typeof location === 'undefined') return false;+ try {+ return APP_ENTRY_SOURCES.has(new URLSearchParams(location.search).get('utm_source') || '');+ } catch {+ return false;+ }+}++function storageAreas() {+ const areas = [];+ try { if (typeof localStorage !== 'undefined') areas.push(localStorage); } catch { /* blocked */ }+ try { if (typeof sessionStorage !== 'undefined') areas.push(sessionStorage); } catch { /* blocked */ }+ return areas;+}++function rememberTwaSignal() {+ for (const area of storageAreas()) {+ try { area.setItem(TWA_MEMORY_KEY, '1'); return; } catch { /* next area */ }+ }+}++function hasRememberedTwaSignal() {+ for (const area of storageAreas()) {+ try { if (area.getItem(TWA_MEMORY_KEY) === '1') return true; } catch { /* next area */ }+ }+ return false;+}++/** Forget the remembered app signal (tests, and a future "open in browser" affordance). */+export function forgetTwaSignal() {+ for (const area of storageAreas()) {+ try { area.removeItem(TWA_MEMORY_KEY); } catch { /* ignore */ }+ }+}+function isDeviceHintedSeeker() {if (typeof navigator === 'undefined') return false;const ua = navigator.userAgent || '';@@ -92,7 +140,10 @@ function hasMwaIntent() {export function isSolanaMobileTwa() {if (typeof window === 'undefined') return false;// Hard signal: direct referrer from our TWA package.- if (isFromTwaReferrer()) return true;+ if (isFromTwaReferrer()) {+ rememberTwaSignal();+ return true;+ }// Combined signals under standalone Android Chrome. Standalone alone isn't// enough (installed PWAs on phones look identical) — each needs a second// Android-app-context signal so desktop and plain mobile PWAs never match:@@ -100,9 +151,15 @@ export function isSolanaMobileTwa() {// • the device advertises a Seeker/SAGA hint, or// • the MWA runtime is already present.if (isStandalone() && isAndroidWebView()) {- if (isFromAnyAndroidAppReferrer()) return true;+ if (isFromAnyAndroidAppReferrer() || isFromAppEntryUrl()) {+ rememberTwaSignal();+ return true;+ }if (isDeviceHintedSeeker()) return true;if (hasMwaIntent()) return true;+ // Later navigations inside the app: the entry signal was seen earlier+ // on this device and the page is still a standalone Android display.+ if (hasRememberedTwaSignal()) return true;}return false;}diff --git a/src/privy-login.js b/src/privy-login.jsindex 3d7a3e1f9..0e65bb7db 100644--- a/src/privy-login.js+++ b/src/privy-login.js@@ -3,6 +3,11 @@// Solana wallet uses our own SIWS backend (/api/auth/siws/*) directly.import Privy, { LocalStorage } from '@privy-io/js-sdk-core';+// Seeker / Saga: installs the Seed Vault wallet at window.threeWsWallet inside+// the three.ws app (a no-op everywhere else). getSolanaProvider() below already+// looked for it, but nothing on this page loaded it, so the Solana button+// answered "No Solana wallet detected" inside the app.+import '../solana-mobile/src/index.js';const next =window.__loginNext ||diff --git a/tests/solana-mobile-seeker-detect.test.js b/tests/solana-mobile-seeker-detect.test.jsindex 7190b604e..08e623b1b 100644--- a/tests/solana-mobile-seeker-detect.test.js+++ b/tests/solana-mobile-seeker-detect.test.js@@ -7,7 +7,7 @@// no "Seeker"/"SAGA" hint (the referrer-based fix).import { describe, it, expect, afterEach } from 'vitest';-import { isSolanaMobileTwa, isSolanaMobileDevice } from '../solana-mobile/src/seeker-detect.js';+import { isSolanaMobileTwa, isSolanaMobileDevice, forgetTwaSignal } from '../solana-mobile/src/seeker-detect.js';function setEnv({ ua = '', referrer = '', standalone = false } = {}) {Object.defineProperty(navigator, 'userAgent', { value: ua, configurable: true });@@ -20,6 +20,8 @@ const DESKTOP_CHROME = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/53afterEach(() => {delete window.matchMedia;+ forgetTwaSignal();+ window.history.replaceState(null, '', '/');});describe('isSolanaMobileTwa', () => {@@ -56,6 +58,43 @@ describe('isSolanaMobileTwa', () => {});});+describe('isSolanaMobileTwa across in-app navigation', () => {+ it('stays true on a later page whose referrer is the previous page', () => {+ // First navigation: launched from the Android app.+ setEnv({ ua: ANDROID_CHROME, referrer: 'android-app://ws.three.app', standalone: true });+ expect(isSolanaMobileTwa()).toBe(true);+ // The user taps a link: the referrer is now our own previous page and+ // the UA carries no hint. This is exactly the /login case that showed+ // "No Solana wallet detected" inside the app.+ setEnv({ ua: ANDROID_CHROME, referrer: 'https://three.ws/app', standalone: true });+ expect(isSolanaMobileTwa()).toBe(true);+ });++ it('treats the app start URL and shortcut URLs as the entry signal', () => {+ window.history.replaceState(null, '', '/seeker?utm_source=seeker_app');+ setEnv({ ua: ANDROID_CHROME, referrer: '', standalone: true });+ expect(isSolanaMobileTwa()).toBe(true);+ window.history.replaceState(null, '', '/login');+ setEnv({ ua: ANDROID_CHROME, referrer: 'https://three.ws/seeker', standalone: true });+ expect(isSolanaMobileTwa()).toBe(true);+ });++ it('never lets the memory leak into a non-standalone browser tab', () => {+ setEnv({ ua: ANDROID_CHROME, referrer: 'android-app://ws.three.app', standalone: true });+ expect(isSolanaMobileTwa()).toBe(true);+ setEnv({ ua: ANDROID_CHROME, referrer: '', standalone: false });+ expect(isSolanaMobileTwa()).toBe(false);+ setEnv({ ua: DESKTOP_CHROME, referrer: '', standalone: true });+ expect(isSolanaMobileTwa()).toBe(false);+ });++ it('does not remember anything for a plain installed PWA', () => {+ setEnv({ ua: ANDROID_CHROME, referrer: '', standalone: true });+ expect(isSolanaMobileTwa()).toBe(false);+ expect(localStorage.getItem('threews:twa')).toBe(null);+ });+});+describe('isSolanaMobileDevice', () => {it('is true for an Android UA advertising a Seeker hint', () => {setEnv({ ua: `${ANDROID_CHROME} SolanaMobile` });