Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/genui/a2ui-playground/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function findLocalIp(): string {

function buildRspeedyBundleUrl(port: number): string {
const ip = findLocalIp();
return `http://${ip}:${port}/main.lynx.js`;
return `http://${ip}:${port}/a2ui.lynx.js`;
}

export default defineConfig({
Expand Down
14 changes: 12 additions & 2 deletions packages/genui/a2ui-playground/src/pages/DemosPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ function formatUrlForDisplay(url: string): string {
return `${head}…${tail}`;
}

function getDeployedLynxBundleUrl(): string {
try {
return new URL('a2ui.lynx.js', window.location.href).toString();
} catch {
return '';
}
}

function useRspeedyDevUrl(): string {
const [url, setUrl] = useState('');
// Default to the deployed bundle next to the current page so that the
// "Native Preview" QR is available in production (no rspeedy dev server).
const [url, setUrl] = useState<string>(() => getDeployedLynxBundleUrl());
useEffect(() => {
let cancelled = false;
void (async () => {
Expand All @@ -47,7 +57,7 @@ function useRspeedyDevUrl(): string {
});
if (!res.ok) return;
const data = (await res.json()) as { url?: string };
if (!cancelled && typeof data.url === 'string') {
if (!cancelled && typeof data.url === 'string' && data.url) {
setUrl(data.url);
}
} catch {
Expand Down
14 changes: 12 additions & 2 deletions packages/genui/a2ui-playground/src/pages/OpenUIDemosPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ const COMPACT_CODE_MIN_HEIGHT = 220;
const COMPACT_PREVIEW_MIN_HEIGHT = 320;
const RESIZE_BREAKPOINT = 980;

function getDeployedLynxBundleUrl(): string {
try {
return new URL('a2ui.lynx.js', window.location.href).toString();
} catch {
return '';
}
}

function useRspeedyDevUrl(): string {
const [url, setUrl] = useState('');
// Default to the deployed bundle next to the current page so that the
// "Native Preview" QR is available in production (no rspeedy dev server).
const [url, setUrl] = useState<string>(() => getDeployedLynxBundleUrl());
useEffect(() => {
let cancelled = false;
void (async () => {
Expand All @@ -29,7 +39,7 @@ function useRspeedyDevUrl(): string {
});
if (!res.ok) return;
const data = (await res.json()) as { url?: string };
if (!cancelled && typeof data.url === 'string') {
if (!cancelled && typeof data.url === 'string' && data.url) {
setUrl(data.url);
}
} catch {
Expand Down
Loading