mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 03:16:25 +02:00
feat: integrate report panel into chat interface
- Added a new ReportPanel component to display report details inline within the chat interface. - Updated NewChatPage and PublicChatView to include the ReportPanel, enhancing user experience by allowing report viewing alongside chat interactions. - Introduced report panel state management with Jotai atoms to control visibility and data handling. - Refactored existing components to accommodate the new report panel layout and functionality.
This commit is contained in:
parent
acad8c6d2b
commit
e4244829ae
6 changed files with 592 additions and 212 deletions
48
surfsense_web/atoms/chat/report-panel.atom.ts
Normal file
48
surfsense_web/atoms/chat/report-panel.atom.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { atom } from "jotai";
|
||||
|
||||
interface ReportPanelState {
|
||||
isOpen: boolean;
|
||||
reportId: number | null;
|
||||
title: string | null;
|
||||
wordCount: number | null;
|
||||
}
|
||||
|
||||
const initialState: ReportPanelState = {
|
||||
isOpen: false,
|
||||
reportId: null,
|
||||
title: null,
|
||||
wordCount: null,
|
||||
};
|
||||
|
||||
/** Core atom holding the report panel state */
|
||||
export const reportPanelAtom = atom<ReportPanelState>(initialState);
|
||||
|
||||
/** Derived read-only atom for checking if panel is open */
|
||||
export const reportPanelOpenAtom = atom((get) => get(reportPanelAtom).isOpen);
|
||||
|
||||
/** Action atom to open the report panel with a specific report */
|
||||
export const openReportPanelAtom = atom(
|
||||
null,
|
||||
(
|
||||
_get,
|
||||
set,
|
||||
{
|
||||
reportId,
|
||||
title,
|
||||
wordCount,
|
||||
}: { reportId: number; title: string; wordCount?: number }
|
||||
) => {
|
||||
set(reportPanelAtom, {
|
||||
isOpen: true,
|
||||
reportId,
|
||||
title,
|
||||
wordCount: wordCount ?? null,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
/** Action atom to close the report panel */
|
||||
export const closeReportPanelAtom = atom(null, (_, set) => {
|
||||
set(reportPanelAtom, initialState);
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue