From ec617c1c6b591197695762f3f36f40450ef5f7f0 Mon Sep 17 00:00:00 2001
From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com>
Date: Mon, 6 Jul 2026 10:09:30 +0530
Subject: [PATCH] refactor(workspace): update terminology from search space to
workspace
- Changed references from "search space" to "workspace" in various components for consistency.
- Updated the LayoutDataProvider to handle workspace data more effectively.
- Adjusted UI elements in IconRail and MobileSidebar to reflect the new terminology.
- Modified messages in the localization file to align with the updated terminology.
---
.../[workspace_id]/client-layout.tsx | 2 +-
.../layout/providers/LayoutDataProvider.tsx | 25 +++++++++++++------
.../layout/ui/icon-rail/IconRail.tsx | 4 +--
.../layout/ui/sidebar/MobileSidebar.tsx | 2 +-
surfsense_web/messages/en.json | 4 +--
5 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/surfsense_web/app/dashboard/[workspace_id]/client-layout.tsx b/surfsense_web/app/dashboard/[workspace_id]/client-layout.tsx
index 0cd650a9a..3c4099fa3 100644
--- a/surfsense_web/app/dashboard/[workspace_id]/client-layout.tsx
+++ b/surfsense_web/app/dashboard/[workspace_id]/client-layout.tsx
@@ -214,7 +214,7 @@ export function DashboardClientLayout({
return (
- {children}
+ {children}
);
}
diff --git a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx
index 433d66353..0f79fb0bb 100644
--- a/surfsense_web/components/layout/providers/LayoutDataProvider.tsx
+++ b/surfsense_web/components/layout/providers/LayoutDataProvider.tsx
@@ -111,8 +111,8 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid
? Number(Array.isArray(params.chat_id) ? params.chat_id[0] : params.chat_id)
: currentThreadState.id;
- // Fetch current search space (for caching purposes)
- useQuery({
+ // Fetch current workspace as a fallback for the selector while the full list catches up.
+ const { data: currentWorkspace } = useQuery({
queryKey: cacheKeys.searchSpaces.detail(searchSpaceId),
queryFn: () => searchSpacesApiService.getSearchSpace({ id: Number(searchSpaceId) }),
enabled: !!searchSpaceId,
@@ -267,11 +267,22 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid
}));
}, [searchSpacesData]);
- // Find active search space from list (has is_owner and member_count)
+ // Find active workspace from list, falling back to the route-scoped detail query.
const activeSearchSpace: SearchSpace | null = useMemo(() => {
- if (!searchSpaceId || !searchSpaces.length) return null;
- return searchSpaces.find((s) => s.id === Number(searchSpaceId)) ?? null;
- }, [searchSpaceId, searchSpaces]);
+ if (!searchSpaceId) return null;
+ const searchSpaceIdNumber = Number(searchSpaceId);
+ const listedSpace = searchSpaces.find((s) => s.id === searchSpaceIdNumber);
+ if (listedSpace) return listedSpace;
+ if (!currentWorkspace || currentWorkspace.id !== searchSpaceIdNumber) return null;
+ return {
+ id: currentWorkspace.id,
+ name: currentWorkspace.name,
+ description: currentWorkspace.description,
+ isOwner: false,
+ memberCount: 0,
+ createdAt: currentWorkspace.created_at,
+ };
+ }, [currentWorkspace, searchSpaceId, searchSpaces]);
// Safety redirect: if the current search space is no longer in the user's list
// (e.g. deleted by background task, membership revoked), redirect to a valid space.
@@ -280,7 +291,7 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid
return;
if (searchSpaces.length > 0 && !activeSearchSpace) {
router.replace(`/dashboard/${searchSpaces[0].id}/new-chat`);
- } else if (searchSpaces.length === 0 && searchSpacesLoaded) {
+ } else if (searchSpaces.length === 0 && searchSpacesLoaded && !activeSearchSpace) {
router.replace("/dashboard");
}
}, [
diff --git a/surfsense_web/components/layout/ui/icon-rail/IconRail.tsx b/surfsense_web/components/layout/ui/icon-rail/IconRail.tsx
index a47b00e5c..05db59f11 100644
--- a/surfsense_web/components/layout/ui/icon-rail/IconRail.tsx
+++ b/surfsense_web/components/layout/ui/icon-rail/IconRail.tsx
@@ -102,11 +102,11 @@ export function IconRail({
className="h-10 w-10 rounded-lg border-2 border-dashed border-muted-foreground/30 hover:border-muted-foreground/50"
>
- Add search space
+ Add workspace
- Add search space
+ Add workspace
diff --git a/surfsense_web/components/layout/ui/sidebar/MobileSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/MobileSidebar.tsx
index 89a01d0c7..cb192ba37 100644
--- a/surfsense_web/components/layout/ui/sidebar/MobileSidebar.tsx
+++ b/surfsense_web/components/layout/ui/sidebar/MobileSidebar.tsx
@@ -133,7 +133,7 @@ export function MobileSidebar({
className="h-10 w-10 shrink-0 rounded-lg border-2 border-dashed border-muted-foreground/30 hover:border-muted-foreground/50"
>
- Add search space
+ Add workspace
diff --git a/surfsense_web/messages/en.json b/surfsense_web/messages/en.json
index df29de9de..ed994d9a6 100644
--- a/surfsense_web/messages/en.json
+++ b/surfsense_web/messages/en.json
@@ -682,9 +682,9 @@
"no_archived_chats": "No archived chats",
"error_archiving_chat": "Failed to archive chat",
"new_chat": "New chat",
- "select_search_space": "Select Search Space",
+ "select_search_space": "Select Workspace",
"manage_members": "Manage members",
- "search_space_settings": "Search Space settings",
+ "search_space_settings": "Workspace settings",
"logs": "Logs",
"see_all_search_spaces": "See all search spaces",
"expand_sidebar": "Expand sidebar",