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.

fix(irl): cover View-in-AR routing with a test and drop the duplicate print-sign link

nirholas511d752a8dcf
diff --git a/pages/irl.html b/pages/irl.html
index f93d6315b..939e52c86 100644
--- a/pages/irl.html
+++ b/pages/irl.html
@@ -1675,7 +1675,7 @@
.irl-pin-place.is-approx { color: #93c5fd; background: rgba(96,165,250,0.13); border-color: rgba(96,165,250,0.3); }
.irl-pin-caption { font-size: 12.5px; color: #9ca3af; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.irl-pin-meta { font-size: 11.5px; color: #9ca3af; margin-top: 3px; }
- /* "Sign" — opens /irl/sign preselected on this pin. A placed agent is
+ /* "Sign": opens /irl/sign preselected on this pin. A placed agent is
undiscoverable until something in the physical world points at it, so the
printable sign sits right next to the pin it belongs to. */
.irl-pin-sign { flex-shrink: 0; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(126,200,227,0.28); background: rgba(126,200,227,0.10); color: #7ec8e3; font: 600 12px inherit; text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s; white-space: nowrap; }
diff --git a/src/dashboard-next/pages/irl-placements.js b/src/dashboard-next/pages/irl-placements.js
index 87843fda3..7d9cb0f39 100644
--- a/src/dashboard-next/pages/irl-placements.js
+++ b/src/dashboard-next/pages/irl-placements.js
@@ -576,7 +576,6 @@ function cardHtml(pin, ixList) {
<button class="irl-action" data-loc-toggle>Move on map</button>
<button class="irl-action" data-visit="${esc(pin.id)}" type="button">Visit link</button>
<a class="irl-action" href="/irl?pin=${esc(pin.id)}" target="_blank" rel="noopener">View in IRL ↗</a>
- <a class="irl-action" href="/irl/sign?pin=${esc(pin.id)}" target="_blank" rel="noopener">Print a sign ↗</a>
<button class="irl-action remove" data-remove="${esc(pin.id)}">Remove</button>
</div>
</div>
diff --git a/tests/irl-pin-ar.test.js b/tests/irl-pin-ar.test.js
new file mode 100644
index 000000000..cff94d02e
--- /dev/null
+++ b/tests/irl-pin-ar.test.js
@@ -0,0 +1,106 @@
+// "View in AR" for a discovered pin (src/irl/pin-ar.js).
+//
+// A visitor who taps somebody else's agent on /irl gets one button that stands
+// that agent on their real floor. Which native AR stack answers depends on the
+// device, and the GLB has to be handed over as an absolute https URL that Quick
+// Look, Scene Viewer and /api/ar all accept. Those rules are pure; pin them here
+// so a phone test never has to rediscover them.
+
+import { describe, it, expect } from 'vitest';
+
+import {
+ arLaneFor,
+ arButtonCopy,
+ absoluteGlbUrl,
+ arLaunchUrl,
+ quickLookBannerFor,
+ pinDisplayName,
+} from '../src/irl/pin-ar.js';
+
+const ORIGIN = 'https://three.ws';
+
+describe('arLaneFor', () => {
+ it('routes each placement capability to its AR lane', () => {
+ expect(arLaneFor('quicklook')).toBe('quicklook');
+ expect(arLaneFor('webxr')).toBe('webxr');
+ expect(arLaneFor('pin')).toBe('link');
+ });
+
+ it('falls back to the universal link lane on anything unexpected', () => {
+ expect(arLaneFor(undefined)).toBe('link');
+ expect(arLaneFor('')).toBe('link');
+ expect(arLaneFor('webar')).toBe('link');
+ });
+});
+
+describe('arButtonCopy', () => {
+ it('keeps one visible label and a device-specific accessible name', () => {
+ const lanes = ['quicklook', 'webxr', 'link'];
+ const labels = new Set(lanes.map((l) => arButtonCopy(l).label));
+ expect(labels.size).toBe(1);
+ expect(arButtonCopy('quicklook').aria).toMatch(/Quick Look/);
+ expect(arButtonCopy('webxr').aria).toMatch(/floor/);
+ expect(arButtonCopy('link').aria).toMatch(/viewer/);
+ });
+});
+
+describe('absoluteGlbUrl', () => {
+ it('resolves a site-relative model path against the origin', () => {
+ expect(absoluteGlbUrl('/avatars/default.glb', ORIGIN)).toBe('https://three.ws/avatars/default.glb');
+ });
+
+ it('passes an absolute CDN URL through untouched', () => {
+ const cdn = 'https://cdn.three.ws/models/abc.glb?v=2';
+ expect(absoluteGlbUrl(cdn, ORIGIN)).toBe(cdn);
+ });
+
+ it('returns null for an empty or non-string model', () => {
+ expect(absoluteGlbUrl('', ORIGIN)).toBeNull();
+ expect(absoluteGlbUrl(' ', ORIGIN)).toBeNull();
+ expect(absoluteGlbUrl(null, ORIGIN)).toBeNull();
+ });
+});
+
+describe('arLaunchUrl', () => {
+ it('builds the device-aware /api/ar link marked as a living avatar', () => {
+ const url = arLaunchUrl({ avatar_url: '/avatars/default.glb', avatar_name: 'Nova' }, ORIGIN);
+ const u = new URL(url);
+ expect(u.origin + u.pathname).toBe('https://three.ws/api/ar');
+ expect(u.searchParams.get('src')).toBe('https://three.ws/avatars/default.glb');
+ expect(u.searchParams.get('title')).toBe('Nova');
+ expect(u.searchParams.get('kind')).toBe('avatar');
+ });
+
+ it('refuses a model that cannot be expressed as https (what /api/ar would reject)', () => {
+ expect(arLaunchUrl({ avatar_url: '/avatars/default.glb' }, 'http://localhost:3000')).toBeNull();
+ expect(arLaunchUrl({ avatar_url: 'blob:https://three.ws/123' }, ORIGIN)).toBeNull();
+ expect(arLaunchUrl({ avatar_url: '' }, ORIGIN)).toBeNull();
+ });
+
+ it('clamps a runaway name so the title never balloons the URL', () => {
+ const long = 'x'.repeat(500);
+ const url = arLaunchUrl({ avatar_url: '/a.glb', avatar_name: long }, ORIGIN);
+ expect(new URL(url).searchParams.get('title').length).toBeLessThanOrEqual(60);
+ });
+});
+
+describe('quickLookBannerFor', () => {
+ it('names the agent and makes the banner tap a conversation, not a placement', () => {
+ const b = quickLookBannerFor({ avatar_name: 'Nova', caption: 'Ask me about the pier' });
+ expect(b.title).toBe('Nova');
+ expect(b.subtitle).toBe('Ask me about the pier');
+ expect(b.callToAction).toBe('Talk to Nova');
+ });
+
+ it('falls back to the platform line when the pin has no caption', () => {
+ expect(quickLookBannerFor({ avatar_name: 'Nova' }).subtitle).toBe('Living agent on three.ws');
+ });
+});
+
+describe('pinDisplayName', () => {
+ it('defaults to Agent and trims whitespace', () => {
+ expect(pinDisplayName({})).toBe('Agent');
+ expect(pinDisplayName({ avatar_name: ' Nova ' })).toBe('Nova');
+ expect(pinDisplayName(null)).toBe('Agent');
+ });
+});