Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(assistant-ui-demo): correct mock runtime provider import path

Steven Enamakelb1b31ca611fd
diff --git a/app/src/pages/dev/assistant-ui-demo/MockRuntimeProvider.tsx b/app/src/pages/dev/assistant-ui-demo/MockRuntimeProvider.tsx
new file mode 100644
index 0000000000..3a5ecf087f
--- /dev/null
+++ b/app/src/pages/dev/assistant-ui-demo/MockRuntimeProvider.tsx
@@ -0,0 +1,62 @@
+/**
+ * Mounts a fully mocked assistant-ui runtime for the vendored `base` demo.
+ *
+ * Deliberately isolated from the app's real runtime
+ * (`providers/AssistantUiRuntimeProvider`, which projects OpenHuman's Redux
+ * state through an external store). This one owns its own in-memory state: a
+ * thread list that lives for the lifetime of the page, a canned chat model, and
+ * attachment/feedback adapters that never leave the browser. Mounting it cannot
+ * touch a thread, a message, or the core.
+ */
+import {
+ AssistantRuntimeProvider,
+ CompositeAttachmentAdapter,
+ InMemoryThreadListAdapter,
+ SimpleImageAttachmentAdapter,
+ SimpleTextAttachmentAdapter,
+ useLocalRuntime,
+ useRemoteThreadListRuntime,
+} from '@assistant-ui/react';
+import debugFactory from 'debug';
+import { type ReactNode, useMemo, useState } from 'react';
+
+import { mockChatModelAdapter } from './mockChatModel';
+
+const debug = debugFactory('openhuman:assistant-ui-demo');
+
+/**
+ * The per-thread runtime. `useRemoteThreadListRuntime` calls this once per live
+ * thread, so each thread in the list gets its own message history.
+ */
+function useDemoThreadRuntime() {
+ const adapters = useMemo(
+ () => ({
+ attachments: new CompositeAttachmentAdapter([
+ new SimpleImageAttachmentAdapter(),
+ new SimpleTextAttachmentAdapter(),
+ ]),
+ feedback: {
+ submit: ({ type }: { type: 'positive' | 'negative' }) => {
+ debug('[assistant-ui-demo] feedback=%s (mock, discarded)', type);
+ },
+ },
+ }),
+ []
+ );
+
+ return useLocalRuntime(mockChatModelAdapter, { adapters });
+}
+
+export function MockRuntimeProvider({ children }: { children: ReactNode }) {
+ // One adapter instance for the page's lifetime — the options doc requires a
+ // stable reference, since replacing it reloads the list and drops threads.
+ const [adapter] = useState(() => new InMemoryThreadListAdapter());
+ const runtime = useRemoteThreadListRuntime({
+ runtimeHook: useDemoThreadRuntime,
+ adapter,
+ });
+
+ return <AssistantRuntimeProvider runtime={runtime}>{children}</AssistantRuntimeProvider>;
+}
+
+export default MockRuntimeProvider;
diff --git a/app/src/pages/dev/assistant-ui-demo/index.tsx b/app/src/pages/dev/assistant-ui-demo/index.tsx
new file mode 100644
index 0000000000..3c52f4f6b5
--- /dev/null
+++ b/app/src/pages/dev/assistant-ui-demo/index.tsx
@@ -0,0 +1,29 @@
+/**
+ * `/dev/assistant-ui` — the upstream assistant-ui `base` demo, vendored.
+ *
+ * Source: https://www.assistant-ui.com/demos/base
+ * (`apps/docs/components/pages/examples/base.tsx` in assistant-ui/assistant-ui)
+ *
+ * Vendored verbatim apart from the host-specific bits that cannot survive the
+ * move: Next's `Image`/`next/public` asset import, the docs site's live model
+ * catalogue, and the shadcn `@/components/ui` + `@/lib/utils` aliases, which
+ * this repo scopes under `@/components/assistant-ui`. Keeping the rest byte-for-
+ * byte is the point — it is a reference for what the primitives can render, so
+ * a local rewrite would make it stop being one.
+ *
+ * The runtime under it is mock-only (see `MockRuntimeProvider`).
+ */
+import { BaseDemo } from './BaseDemo';
+import { MockRuntimeProvider } from './MockRuntimeProvider';
+
+export function AssistantUiDemoPage() {
+ return (
+ <div className="h-dvh w-full overflow-hidden">
+ <MockRuntimeProvider>
+ <BaseDemo />
+ </MockRuntimeProvider>
+ </div>
+ );
+}
+
+export default AssistantUiDemoPage;