feat(webui): add initial webui with websocket chat flow

This commit is contained in:
Xubin Ren
2026-04-18 18:51:53 +00:00
parent 6bfb75ed03
commit 9ed3031a42
76 changed files with 7088 additions and 38 deletions
+37
View File
@@ -0,0 +1,37 @@
import { createContext, useContext, type ReactNode } from "react";
import type { NanobotClient } from "@/lib/nanobot-client";
interface ClientContextValue {
client: NanobotClient;
token: string;
modelName: string | null;
}
const ClientContext = createContext<ClientContextValue | null>(null);
export function ClientProvider({
client,
token,
modelName = null,
children,
}: {
client: NanobotClient;
token: string;
modelName?: string | null;
children: ReactNode;
}) {
return (
<ClientContext.Provider value={{ client, token, modelName }}>
{children}
</ClientContext.Provider>
);
}
export function useClient(): ClientContextValue {
const ctx = useContext(ClientContext);
if (!ctx) {
throw new Error("useClient must be used within a ClientProvider");
}
return ctx;
}