feat: improve document editor panel behavior

This commit is contained in:
Anish Sarkar 2026-05-20 02:02:59 +05:30
parent 89a8438864
commit cb1cf26ef3
8 changed files with 380 additions and 81 deletions

View file

@ -3,10 +3,11 @@ import { rightPanelCollapsedAtom, rightPanelTabAtom } from "@/atoms/layout/right
interface EditorPanelState {
isOpen: boolean;
kind: "document" | "local_file";
kind: "document" | "local_file" | "memory";
documentId: number | null;
localFilePath: string | null;
searchSpaceId: number | null;
memoryScope: "user" | "team" | null;
title: string | null;
}
@ -16,6 +17,7 @@ const initialState: EditorPanelState = {
documentId: null,
localFilePath: null,
searchSpaceId: null,
memoryScope: null,
title: null,
};
@ -38,6 +40,12 @@ export const openEditorPanelAtom = atom(
title?: string;
searchSpaceId?: number;
}
| {
kind: "memory";
memoryScope: "user" | "team";
title?: string;
searchSpaceId?: number;
}
) => {
if (!get(editorPanelAtom).isOpen) {
set(preEditorCollapsedAtom, get(rightPanelCollapsedAtom));
@ -49,6 +57,21 @@ export const openEditorPanelAtom = atom(
documentId: null,
localFilePath: payload.localFilePath,
searchSpaceId: payload.searchSpaceId ?? null,
memoryScope: null,
title: payload.title ?? null,
});
set(rightPanelTabAtom, "editor");
set(rightPanelCollapsedAtom, false);
return;
}
if (payload.kind === "memory") {
set(editorPanelAtom, {
isOpen: true,
kind: "memory",
documentId: null,
localFilePath: null,
searchSpaceId: payload.searchSpaceId ?? null,
memoryScope: payload.memoryScope,
title: payload.title ?? null,
});
set(rightPanelTabAtom, "editor");
@ -61,6 +84,7 @@ export const openEditorPanelAtom = atom(
documentId: payload.documentId,
localFilePath: null,
searchSpaceId: payload.searchSpaceId,
memoryScope: null,
title: payload.title ?? null,
});
set(rightPanelTabAtom, "editor");