From 8d28f71ed70f65b39cc79ffb95b8008aad1ade43 Mon Sep 17 00:00:00 2001 From: atimics Date: Wed, 29 Jul 2026 21:10:51 -0700 Subject: [PATCH] fix: render the disconnected viewer without remote assets --- src/app.test.ts | 16 +++++++++++++++- src/app.ts | 11 +++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/app.test.ts b/src/app.test.ts index 5edb4a6..9fbad84 100644 --- a/src/app.test.ts +++ b/src/app.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { rubyHighRoutes } from "./app.js"; +import { renderAppView, rubyHighRoutes } from "./app.js"; describe("Ruby High app routes", () => { it("mounts every declared route at its exact public contract path", () => { @@ -33,4 +33,18 @@ describe("Ruby High app routes", () => { ]), ); }); + + it("renders a self-contained disconnected viewer without a broken asset request", () => { + const html = renderAppView({ + connection: { connected: false, baseUrl: "", pending: null }, + state: null, + autonomy: null, + error: "Ruby High service is unavailable.", + }); + + expect(html).toContain("

Ruby High

"); + expect(html).toContain("Agents go to school here."); + expect(html).toContain('class="hero-mark"'); + expect(html).not.toContain('src="/api/apps/ruby-high/'); + }); }); diff --git a/src/app.ts b/src/app.ts index 7194a96..fbd31ce 100644 --- a/src/app.ts +++ b/src/app.ts @@ -29,7 +29,7 @@ export const rubyHighRoutes: RubyHighRoute[] = [ "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", "Content-Security-Policy": - "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src 'self'; frame-ancestors 'self'", + "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src 'self' https: data: http://localhost:* http://127.0.0.1:*; connect-src 'self'; frame-ancestors 'self'", }); res.status(200).send(renderAppView(status)); }, @@ -93,7 +93,7 @@ function serviceOrThrow(runtime: IAgentRuntime): RubyHighAgentService { return service; } -function renderAppView(status: { +export function renderAppView(status: { connection: { connected: boolean; baseUrl: string; @@ -116,6 +116,9 @@ function renderAppView(status: { const connected = status.connection.connected; const student = status.state?.student; const autonomy = status.autonomy; + const hero = connected && status.connection.baseUrl + ? `Eliza` + : ''; return ` @@ -125,7 +128,7 @@ function renderAppView(status: {