- Update .gitignore to exclude database files, extensions, and .cursor directory - Enhance chat streaming API with safe enqueue and close functions to prevent errors - Integrate ConversationSidebar component into ClientHome for better UI - Add dependencies like better-sqlite3 and esbuild packages for database functionality This commit introduces database persistence for conversations, improves error handling in streaming responses, and adds a sidebar for managing chats, enhancing overall app robustness and user experience.
29 lines
708 B
TypeScript
29 lines
708 B
TypeScript
"use client";
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
|
|
export type CopyMode = "markdown" | "text";
|
|
|
|
const KEY = "ollahub-copy-mode";
|
|
|
|
export function useCopyPrefs() {
|
|
const [copyMode, setCopyModeState] = useState<CopyMode>("markdown");
|
|
|
|
useEffect(() => {
|
|
if (typeof window === "undefined") return;
|
|
const saved = localStorage.getItem(KEY) as CopyMode | null;
|
|
if (saved === "markdown" || saved === "text") {
|
|
setCopyModeState(saved);
|
|
}
|
|
}, []);
|
|
|
|
const setCopyMode = useCallback((mode: CopyMode) => {
|
|
setCopyModeState(mode);
|
|
if (typeof window !== "undefined") {
|
|
localStorage.setItem(KEY, mode);
|
|
}
|
|
}, []);
|
|
|
|
return { copyMode, setCopyMode };
|
|
}
|