Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

feat(studio): add a static web build that replays the precomputed demonstration

FABIOTESSc3d7756caca2
diff --git a/studio/.gitignore b/studio/.gitignore
index a547bf36..9c711234 100644
--- a/studio/.gitignore
+++ b/studio/.gitignore
@@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
+dist-web
*.local
# Editor directories and files
diff --git a/studio/package.json b/studio/package.json
index 543ef0d5..842ea28e 100644
--- a/studio/package.json
+++ b/studio/package.json
@@ -9,7 +9,8 @@
"preview": "vite preview",
"tauri": "tauri",
"prepare-engine": "node ./scripts/prepare-engine.mjs",
- "test": "vitest run"
+ "test": "vitest run",
+ "build:web": "VITE_DEMO_MODE=replay tsc && VITE_DEMO_MODE=replay vite build --base ./ --outDir dist-web && mkdir -p dist-web/precomputed && cp ../demo/precomputed/bundle.json dist-web/precomputed/bundle.json"
},
"dependencies": {
"@tailwindcss/vite": "^4.2.1",
diff --git a/studio/src/PublicDemo.tsx b/studio/src/PublicDemo.tsx
new file mode 100644
index 00000000..0d1faea4
--- /dev/null
+++ b/studio/src/PublicDemo.tsx
@@ -0,0 +1,117 @@
+import { useEffect, useState } from 'react'
+import type { Contradiction, DemoSource, Document, GraphView } from './lib/demo-source'
+import { getDemoSource } from './lib/source-factory'
+import './App.css'
+
+/**
+ * The static web build's entry surface. Task 12 wires the full desktop
+ * Layout (TreeView, Graph3D, ChatPanel, ...) to DemoSource; until then this
+ * is the minimal proof that the construction site in source-factory.ts
+ * actually works end to end: no engine, no Tauri, no network, and the
+ * corpus, graph and findings still render from the committed artifacts.
+ */
+export function PublicDemo() {
+ const [source, setSource] = useState<DemoSource | null>(null)
+ const [corpus, setCorpus] = useState<Document[] | null>(null)
+ const [graph, setGraph] = useState<GraphView | null>(null)
+ const [findings, setFindings] = useState<Contradiction[] | null>(null)
+ const [error, setError] = useState<string | null>(null)
+
+ useEffect(() => {
+ let cancelled = false
+ getDemoSource()
+ .then(async (src) => {
+ if (cancelled) return
+ setSource(src)
+ const [c, g, f] = await Promise.all([src.corpus(), src.graph(), src.findings()])
+ if (cancelled) return
+ setCorpus(c)
+ setGraph(g)
+ setFindings(f)
+ })
+ .catch((e) => {
+ if (!cancelled) setError(e instanceof Error ? e.message : String(e))
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [])
+
+ if (error) {
+ return (
+ <div className="p-8" style={{ color: 'var(--error)' }}>
+ <h1 className="text-lg font-semibold mb-2">Could not load the demonstration</h1>
+ <p>{error}</p>
+ </div>
+ )
+ }
+
+ return (
+ <div className="min-h-screen p-8 mx-auto" style={{ maxWidth: 960, color: 'var(--text-primary)' }}>
+ <header className="mb-8">
+ <h1 className="text-xl font-semibold" style={{ color: 'var(--accent)' }}>
+ Open Ontologies &mdash; offline demonstration
+ </h1>
+ <p className="text-sm mt-1" style={{ color: 'var(--text-secondary)' }}>
+ Replayed entirely from committed artifacts. No engine, no model, no network call.
+ </p>
+ </header>
+
+ <section className="mb-8">
+ <h2 className="text-sm font-semibold uppercase tracking-wide mb-3" style={{ color: 'var(--text-secondary)' }}>
+ Corpus {corpus ? `(${corpus.length} documents)` : ''}
+ </h2>
+ {!corpus && <p style={{ color: 'var(--text-secondary)' }}>Loading&hellip;</p>}
+ <ul className="space-y-1 text-sm">
+ {corpus?.map((doc) => (
+ <li key={doc.id} className="px-3 py-1.5 rounded" style={{ background: 'var(--bg-panel)' }}>
+ {doc.title}
+ </li>
+ ))}
+ </ul>
+ </section>
+
+ <section className="mb-8">
+ <h2 className="text-sm font-semibold uppercase tracking-wide mb-3" style={{ color: 'var(--text-secondary)' }}>
+ Graph
+ </h2>
+ {!graph && <p style={{ color: 'var(--text-secondary)' }}>Loading&hellip;</p>}
+ {graph && (
+ <p className="text-sm" style={{ color: 'var(--text-primary)' }}>
+ {graph.classes.length} classes, {graph.properties.length} properties, {graph.edges.length} edges
+ </p>
+ )}
+ </section>
+
+ <section>
+ <h2 className="text-sm font-semibold uppercase tracking-wide mb-3" style={{ color: 'var(--text-secondary)' }}>
+ Findings {findings ? `(${findings.length})` : ''}
+ </h2>
+ {!findings && <p style={{ color: 'var(--text-secondary)' }}>Loading&hellip;</p>}
+ <ul className="space-y-3 text-sm">
+ {findings?.map((f) => (
+ <li key={f.id} className="px-3 py-2 rounded" style={{ background: 'var(--bg-panel)' }}>
+ <div className="font-medium" style={{ color: 'var(--accent)' }}>
+ {f.subject} <span style={{ color: 'var(--text-secondary)' }}>[{f.kind}]</span>
+ </div>
+ <ul className="mt-1 space-y-0.5">
+ {f.claims.map((c, i) => (
+ <li key={i} style={{ color: 'var(--text-secondary)' }}>
+ <span style={{ color: 'var(--text-primary)' }}>{c.document}</span> {c.predicate}: {c.object}
+ </li>
+ ))}
+ </ul>
+ </li>
+ ))}
+ </ul>
+ </section>
+
+ {source && (
+ <p className="mt-8 text-xs" style={{ color: 'var(--text-secondary)' }}>
+ Source ready. The full desktop application (open-ontologies studio) adds live graph
+ exploration and chat over a running engine.
+ </p>
+ )}
+ </div>
+ )
+}
diff --git a/studio/src/lib/__tests__/source-factory.test.ts b/studio/src/lib/__tests__/source-factory.test.ts
new file mode 100644
index 00000000..21398db6
--- /dev/null
+++ b/studio/src/lib/__tests__/source-factory.test.ts
@@ -0,0 +1,11 @@
+import { describe, it, expect } from 'vitest'
+import { chooseSourceKind } from '../source-factory'
+
+describe('source selection', () => {
+ it('replays when the build target says web', () => {
+ expect(chooseSourceKind({ VITE_DEMO_MODE: 'replay' })).toBe('replay')
+ })
+ it('goes live by default', () => {
+ expect(chooseSourceKind({})).toBe('live')
+ })
+})
diff --git a/studio/src/lib/source-factory.ts b/studio/src/lib/source-factory.ts
new file mode 100644
index 00000000..b2a133a0
--- /dev/null
+++ b/studio/src/lib/source-factory.ts
@@ -0,0 +1,21 @@
+import type { DemoSource } from './demo-source'
+import { createReplaySource, type ReplayFixtures } from './replay-source'
+import { liveSource } from './live-source'
+
+// The single construction site: everything downstream consumes DemoSource
+// and never mcp-client or the precomputed fixtures directly.
+export function chooseSourceKind(env: Record<string, string | undefined>): 'live' | 'replay' {
+ return env.VITE_DEMO_MODE === 'replay' ? 'replay' : 'live'
+}
+
+export async function getDemoSource(): Promise<DemoSource> {
+ if (chooseSourceKind(import.meta.env as unknown as Record<string, string | undefined>) === 'replay') {
+ const response = await fetch('./precomputed/bundle.json')
+ if (!response.ok) {
+ throw new Error(`Could not load the precomputed demonstration: ${response.status}`)
+ }
+ const fixtures = (await response.json()) as ReplayFixtures
+ return createReplaySource(fixtures)
+ }
+ return liveSource()
+}
diff --git a/studio/src/main.tsx b/studio/src/main.tsx
index 2be325ed..14972374 100644
--- a/studio/src/main.tsx
+++ b/studio/src/main.tsx
@@ -1,9 +1,17 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
+import { PublicDemo } from "./PublicDemo";
+import { chooseSourceKind } from "./lib/source-factory";
+
+// The static web build (npm run build:web) sets VITE_DEMO_MODE=replay. The
+// desktop Tauri shell never sets it, so it always gets the full App, which
+// talks to the bundled engine. This is the same construction site
+// getDemoSource() reads; here it picks the surface, there it picks the data.
+const isReplay = chooseSourceKind(import.meta.env as unknown as Record<string, string | undefined>) === "replay";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
- <App />
+ {isReplay ? <PublicDemo /> : <App />}
</React.StrictMode>,
);