mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
feat: add artifacts open/close actions
This commit is contained in:
parent
71f16c93dd
commit
d568905661
1 changed files with 23 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { atom } from "jotai";
|
||||
import { rightPanelCollapsedAtom, rightPanelTabAtom } from "@/atoms/layout/right-panel.atom";
|
||||
import type { ChatArtifact } from "../model/artifact";
|
||||
|
||||
/** Artifacts of the active thread, synced from the message stream by `useSyncChatArtifacts`. */
|
||||
|
|
@ -6,3 +7,25 @@ export const chatArtifactsAtom = atom<ChatArtifact[]>([]);
|
|||
|
||||
/** Whether the artifacts sidebar is open in the right panel. */
|
||||
export const artifactsPanelOpenAtom = atom(false);
|
||||
|
||||
/** Snapshot of `rightPanelCollapsedAtom` taken before the panel opens, restored on close. */
|
||||
const preArtifactsCollapsedAtom = atom<boolean | null>(null);
|
||||
|
||||
export const openArtifactsPanelAtom = atom(null, (get, set) => {
|
||||
if (!get(artifactsPanelOpenAtom)) {
|
||||
set(preArtifactsCollapsedAtom, get(rightPanelCollapsedAtom));
|
||||
}
|
||||
set(artifactsPanelOpenAtom, true);
|
||||
set(rightPanelTabAtom, "artifacts");
|
||||
set(rightPanelCollapsedAtom, false);
|
||||
});
|
||||
|
||||
export const closeArtifactsPanelAtom = atom(null, (get, set) => {
|
||||
set(artifactsPanelOpenAtom, false);
|
||||
set(rightPanelTabAtom, "sources");
|
||||
const prev = get(preArtifactsCollapsedAtom);
|
||||
if (prev !== null) {
|
||||
set(rightPanelCollapsedAtom, prev);
|
||||
set(preArtifactsCollapsedAtom, null);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue