Skip to content

Build and run agents you can see, understand and trust.

fix(webui): add missing files in the web ui example (#1661)

DavdGao6d7189c075c0
diff --git a/examples/web_ui/frontend/src/lib/next-navigation-shim.ts b/examples/web_ui/frontend/src/lib/next-navigation-shim.ts
new file mode 100644
index 000000000..83c63f272
--- /dev/null
+++ b/examples/web_ui/frontend/src/lib/next-navigation-shim.ts
@@ -0,0 +1,22 @@
+// Shim for `next/navigation` so libraries written for Next.js (e.g. `onborda`)
+// can run inside this Vite + react-router-dom app. Onborda only calls
+// `router.push(route)` when a step has `nextRoute`/`prevRoute` set; we don't use
+// those, so this no-op router is sufficient. If we ever need real navigation
+// from inside a tour step, swap this for a wrapper that uses `react-router`.
+export const useRouter = () => ({
+ push: async (path: string) => {
+ window.history.pushState({}, '', path);
+ window.dispatchEvent(new PopStateEvent('popstate'));
+ },
+ replace: async (path: string) => {
+ window.history.replaceState({}, '', path);
+ window.dispatchEvent(new PopStateEvent('popstate'));
+ },
+ back: () => window.history.back(),
+ forward: () => window.history.forward(),
+ refresh: () => {},
+ prefetch: async () => {},
+});
+
+export const usePathname = () => window.location.pathname;
+export const useSearchParams = () => new URLSearchParams(window.location.search);
diff --git a/examples/web_ui/frontend/src/lib/utils.ts b/examples/web_ui/frontend/src/lib/utils.ts
new file mode 100644
index 000000000..7637fb9e6
--- /dev/null
+++ b/examples/web_ui/frontend/src/lib/utils.ts
@@ -0,0 +1,6 @@
+import { clsx, type ClassValue } from 'clsx';
+import { twMerge } from 'tailwind-merge';
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}