From c379ab1155fd37a6006d3355df21145c93991bf8 Mon Sep 17 00:00:00 2001
From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com>
Date: Mon, 6 Jul 2026 10:04:17 +0530
Subject: [PATCH] feat(workspace): refactor search space handling to workspace
---
.../dashboard/[workspace_id]/onboard/page.tsx | 2 +-
.../components/assistant-ui/markdown-text.tsx | 9 +--
.../components/assistant-ui/thread.tsx | 16 ++---
.../components/assistant-ui/user-message.tsx | 9 +--
.../components/editor-panel/memory.ts | 2 +-
.../layout/ui/sidebar/DocumentsSidebar.tsx | 7 ++-
.../layout/ui/sidebar/InboxSidebar.tsx | 3 +-
.../components/layout/ui/sidebar/Sidebar.tsx | 3 +-
.../components/new-chat/prompt-picker.tsx | 5 +-
.../components/providers/I18nProvider.tsx | 2 +-
.../settings/auto-reload-settings.tsx | 3 +-
.../settings/buy-credits-content.tsx | 3 +-
.../settings/earn-credits-content.tsx | 3 +-
.../model-provider-connections-panel.tsx | 15 +++++
.../contracts/types/document.types.ts | 18 ++++--
.../contracts/types/members.types.ts | 61 ++++++++++++-------
surfsense_web/contracts/types/roles.types.ts | 16 ++++-
.../contracts/types/search-space.types.ts | 2 +-
.../hooks/use-search-source-connectors.ts | 6 +-
.../lib/apis/agent-permissions-api.service.ts | 8 +--
.../lib/apis/automations-api.service.ts | 9 ++-
.../lib/apis/chat-comments-api.service.ts | 2 +-
.../lib/apis/chat-threads-api.service.ts | 2 +-
.../lib/apis/connectors-api.service.ts | 10 +--
.../lib/apis/documents-api.service.ts | 45 +++++++++-----
surfsense_web/lib/apis/folders-api.service.ts | 10 +--
.../lib/apis/image-generations-api.service.ts | 2 +-
surfsense_web/lib/apis/invites-api.service.ts | 8 +--
surfsense_web/lib/apis/logs-api.service.ts | 13 ++--
surfsense_web/lib/apis/members-api.service.ts | 10 +--
.../lib/apis/model-connections-api.service.ts | 33 ++++++++--
.../lib/apis/notifications-api.service.ts | 8 +--
.../lib/apis/podcasts-api.service.ts | 2 +-
surfsense_web/lib/apis/prompts-api.service.ts | 5 +-
surfsense_web/lib/apis/reports-api.service.ts | 2 +-
surfsense_web/lib/apis/roles-api.service.ts | 10 +--
.../lib/apis/search-spaces-api.service.ts | 16 ++---
surfsense_web/lib/apis/stripe-api.service.ts | 6 +-
.../apis/video-presentations-api.service.ts | 2 +-
surfsense_web/lib/chat/thread-persistence.ts | 6 +-
surfsense_web/lib/route-params.ts | 11 ++++
.../tests/fixtures/chat-thread.fixture.ts | 2 +-
surfsense_web/tests/helpers/api/chat.ts | 2 +-
surfsense_web/tests/helpers/api/connectors.ts | 6 +-
surfsense_web/tests/helpers/api/documents.ts | 2 +-
.../tests/helpers/api/search-spaces.ts | 4 +-
surfsense_web/tests/smoke/chat-stream.spec.ts | 2 +-
surfsense_web/zero/schema/automations.ts | 2 +-
surfsense_web/zero/schema/chat.ts | 2 +-
surfsense_web/zero/schema/documents.ts | 4 +-
surfsense_web/zero/schema/folders.ts | 2 +-
surfsense_web/zero/schema/inbox.ts | 2 +-
surfsense_web/zero/schema/podcasts.ts | 2 +-
53 files changed, 268 insertions(+), 169 deletions(-)
create mode 100644 surfsense_web/lib/route-params.ts
diff --git a/surfsense_web/app/dashboard/[workspace_id]/onboard/page.tsx b/surfsense_web/app/dashboard/[workspace_id]/onboard/page.tsx
index 861ceaa07..9da14ef4a 100644
--- a/surfsense_web/app/dashboard/[workspace_id]/onboard/page.tsx
+++ b/surfsense_web/app/dashboard/[workspace_id]/onboard/page.tsx
@@ -74,7 +74,7 @@ export default function OnboardPage() {
: ;
diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx
index 3716c59aa..34ff4888f 100644
--- a/surfsense_web/components/assistant-ui/thread.tsx
+++ b/surfsense_web/components/assistant-ui/thread.tsx
@@ -108,6 +108,7 @@ import { useElectronAPI } from "@/hooks/use-platform";
import { captureDisplayToPngDataUrl } from "@/lib/chat/display-media-capture";
import { getMentionDocKey } from "@/lib/chat/mention-doc-key";
import { slideoutOpenedTickAtom } from "@/lib/layout-events";
+import { getWorkspaceIdNumber } from "@/lib/route-params";
import { cn } from "@/lib/utils";
import {
DocumentMentionPicker,
@@ -458,7 +459,9 @@ const Composer: FC = () => {
const prevMentionedDocsRef = useRef