mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 00:22:31 +00:00
fix(webui): remove eager markdown preload
Remove the eager preloading of markdown/code-highlighting chunk at startup. The markdown renderer will now only be loaded when actually needed to render content.
This commit is contained in:
parent
0a25f696ab
commit
52a9300d9e
@ -5,7 +5,7 @@ import { Sidebar } from "@/components/Sidebar";
|
|||||||
import { SettingsView } from "@/components/settings/SettingsView";
|
import { SettingsView } from "@/components/settings/SettingsView";
|
||||||
import { ThreadShell } from "@/components/thread/ThreadShell";
|
import { ThreadShell } from "@/components/thread/ThreadShell";
|
||||||
import { Sheet, SheetContent } from "@/components/ui/sheet";
|
import { Sheet, SheetContent } from "@/components/ui/sheet";
|
||||||
import { preloadMarkdownText } from "@/components/MarkdownText";
|
|
||||||
import { useSessions } from "@/hooks/useSessions";
|
import { useSessions } from "@/hooks/useSessions";
|
||||||
import { useTheme } from "@/hooks/useTheme";
|
import { useTheme } from "@/hooks/useTheme";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@ -157,22 +157,7 @@ export default function App() {
|
|||||||
return bootstrapWithSecret(saved);
|
return bootstrapWithSecret(saved);
|
||||||
}, [bootstrapWithSecret]);
|
}, [bootstrapWithSecret]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const warm = () => preloadMarkdownText();
|
|
||||||
const win = globalThis as typeof globalThis & {
|
|
||||||
requestIdleCallback?: (
|
|
||||||
callback: IdleRequestCallback,
|
|
||||||
options?: IdleRequestOptions,
|
|
||||||
) => number;
|
|
||||||
cancelIdleCallback?: (handle: number) => void;
|
|
||||||
};
|
|
||||||
if (typeof win.requestIdleCallback === "function") {
|
|
||||||
const id = win.requestIdleCallback(warm, { timeout: 1500 });
|
|
||||||
return () => win.cancelIdleCallback?.(id);
|
|
||||||
}
|
|
||||||
const id = globalThis.setTimeout(warm, 250);
|
|
||||||
return () => globalThis.clearTimeout(id);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (state.status === "loading") {
|
if (state.status === "loading") {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -10,9 +10,7 @@ interface MarkdownTextProps {
|
|||||||
const loadMarkdownRenderer = () => import("@/components/MarkdownTextRenderer");
|
const loadMarkdownRenderer = () => import("@/components/MarkdownTextRenderer");
|
||||||
const LazyMarkdownRenderer = lazy(loadMarkdownRenderer);
|
const LazyMarkdownRenderer = lazy(loadMarkdownRenderer);
|
||||||
|
|
||||||
export function preloadMarkdownText(): void {
|
|
||||||
void loadMarkdownRenderer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lightweight markdown renderer mirroring agent-chat-ui: GFM + math via
|
* Lightweight markdown renderer mirroring agent-chat-ui: GFM + math via
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user