From a49ee05456380baa1a0f147fcf1630f23e9672ac Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Sun, 17 May 2026 03:17:12 +0530 Subject: [PATCH] refactor: enhance layout structure by introducing WorkspacePanel and updating component styles --- .../[search_space_id]/buy-more/page.tsx | 56 ++++++++--------- .../[search_space_id]/more-pages/page.tsx | 18 +++--- .../layout/providers/LayoutDataProvider.tsx | 5 +- .../layout/ui/shell/LayoutShell.tsx | 61 ++++++++++++------- .../layout/ui/shell/WorkspacePanel.tsx | 28 +++++++++ .../components/layout/ui/shell/index.ts | 1 + 6 files changed, 107 insertions(+), 62 deletions(-) create mode 100644 surfsense_web/components/layout/ui/shell/WorkspacePanel.tsx diff --git a/surfsense_web/app/dashboard/[search_space_id]/buy-more/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/buy-more/page.tsx index ba13a6239..da2b5787b 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/buy-more/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/buy-more/page.tsx @@ -18,35 +18,33 @@ export default function BuyMorePage() { const [activeTab, setActiveTab] = useState("pages"); return ( -
- -
- {TABS.map((tab) => ( - - ))} -
+ +
+ {TABS.map((tab) => ( + + ))} +
- {activeTab === "pages" ? : } -
-
+ {activeTab === "pages" ? : } + ); } diff --git a/surfsense_web/app/dashboard/[search_space_id]/more-pages/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/more-pages/page.tsx index 448706caf..9c0b2c4e7 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/more-pages/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/more-pages/page.tsx @@ -5,15 +5,13 @@ import { MorePagesContent } from "@/components/settings/more-pages-content"; export default function MorePagesPage() { return ( -
- - - -
+ + + ); } diff --git a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx index 6884da7c7..d774ae862 100644 --- a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx +++ b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx @@ -136,7 +136,7 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid // Documents sidebar state (shared atom so Composer can toggle it) const [isDocumentsSidebarOpen, setIsDocumentsSidebarOpen] = useAtom(documentsSidebarOpenAtom); const [isDocumentsDocked, setIsDocumentsDocked] = useState(true); - const [isRightPanelCollapsed, setIsRightPanelCollapsed] = useAtom(rightPanelCollapsedAtom); + const setIsRightPanelCollapsed = useSetAtom(rightPanelCollapsedAtom); // Open documents sidebar by default on desktop (docked mode) const documentsInitialized = useRef(false); @@ -668,6 +668,8 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid // Detect if we're on the chat page (needs overflow-hidden for chat's own scroll) const isChatPage = pathname?.includes("/new-chat") ?? false; + const useWorkspacePanel = + pathname?.endsWith("/buy-more") === true || pathname?.endsWith("/more-pages") === true; return ( <> @@ -705,6 +707,7 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid theme={theme} setTheme={setTheme} isChatPage={isChatPage} + useWorkspacePanel={useWorkspacePanel} isLoadingChats={isLoadingThreads} activeSlideoutPanel={activeSlideoutPanel} onSlideoutPanelChange={setActiveSlideoutPanel} diff --git a/surfsense_web/components/layout/ui/shell/LayoutShell.tsx b/surfsense_web/components/layout/ui/shell/LayoutShell.tsx index 841190256..ad1d809ab 100644 --- a/surfsense_web/components/layout/ui/shell/LayoutShell.tsx +++ b/surfsense_web/components/layout/ui/shell/LayoutShell.tsx @@ -31,6 +31,7 @@ import { } from "../sidebar"; import { SidebarSlideOutPanel } from "../sidebar/SidebarSlideOutPanel"; import { TabBar } from "../tabs/TabBar"; +import { WorkspacePanel } from "./WorkspacePanel"; const DocumentTabContent = dynamic( () => import("../tabs/DocumentTabContent").then((m) => ({ default: m.DocumentTabContent })), @@ -98,6 +99,7 @@ interface LayoutShellProps { setTheme?: (theme: "light" | "dark" | "system") => void; defaultCollapsed?: boolean; isChatPage?: boolean; + useWorkspacePanel?: boolean; children: React.ReactNode; className?: string; // Unified slide-out panel state @@ -166,6 +168,10 @@ function MainContentPanel({ ); } +function DesktopWorkspaceRegion({ children }: { children: React.ReactNode }) { + return
{children}
; +} + export function LayoutShell({ searchSpaces, activeSearchSpaceId, @@ -198,6 +204,7 @@ export function LayoutShell({ setTheme, defaultCollapsed = false, isChatPage = false, + useWorkspacePanel = false, children, className, activeSlideoutPanel = null, @@ -287,9 +294,13 @@ export function LayoutShell({ isLoadingChats={isLoadingChats} /> -
- {children} -
+ {useWorkspacePanel ? ( + {children} + ) : ( +
+ {children} +
+ )} {/* Mobile unified slide-out panel */} - {/* Main content panel */} - - {children} - + + {useWorkspacePanel ? ( + {children} + ) : ( + <> + {/* Main content panel */} + + {children} + - {/* Right panel — tabbed Sources/Report (desktop only) */} - {documentsPanel && ( -
- -
- )} + {/* Right panel — tabbed Sources/Report (desktop only) */} + {documentsPanel ? ( + + ) : null} + + )} +
diff --git a/surfsense_web/components/layout/ui/shell/WorkspacePanel.tsx b/surfsense_web/components/layout/ui/shell/WorkspacePanel.tsx new file mode 100644 index 000000000..d6dbe1870 --- /dev/null +++ b/surfsense_web/components/layout/ui/shell/WorkspacePanel.tsx @@ -0,0 +1,28 @@ +import type { ReactNode } from "react"; +import { cn } from "@/lib/utils"; + +interface WorkspacePanelProps { + children: ReactNode; + className?: string; + contentClassName?: string; +} + +/** + * Full workspace area to the right of the left rail/sidebar. + * Use this when a route should own the whole workspace instead of rendering + * inside the normal TabBar/Header/main/right-panel chrome. + */ +export function WorkspacePanel({ children, className, contentClassName }: WorkspacePanelProps) { + return ( +
+
+
{children}
+
+
+ ); +} diff --git a/surfsense_web/components/layout/ui/shell/index.ts b/surfsense_web/components/layout/ui/shell/index.ts index d7d96a574..e58da76c1 100644 --- a/surfsense_web/components/layout/ui/shell/index.ts +++ b/surfsense_web/components/layout/ui/shell/index.ts @@ -1 +1,2 @@ export { LayoutShell } from "./LayoutShell"; +export { WorkspacePanel } from "./WorkspacePanel";