feat: remember sidebar state

This commit is contained in:
Henry Li
2026-01-16 23:03:39 +08:00
parent f9853f037c
commit 6464a67230
4 changed files with 59 additions and 34 deletions

View File

@@ -26,7 +26,7 @@ export default function ChatPage() {
[threadIdFromPath],
);
const [threadId, setThreadId] = useState<string | null>(null);
const { threadContext, setThreadContext } = useLocalSettings();
const [settings, setSettings] = useLocalSettings();
useEffect(() => {
if (threadIdFromPath !== "new") {
@@ -43,7 +43,7 @@ export default function ChatPage() {
isNewThread,
threadId,
thread,
threadContext,
threadContext: settings.context,
afterSubmit() {
router.push(pathOfThread(threadId!));
},
@@ -71,8 +71,8 @@ export default function ChatPage() {
className="w-full max-w-(--container-width-md)"
autoFocus={isNewThread}
status={thread.isLoading ? "streaming" : "ready"}
context={threadContext}
onContextChange={setThreadContext}
context={settings.context}
onContextChange={(context) => setSettings("context", context)}
onSubmit={handleSubmit}
onStop={handleStop}
/>