SurfSense/surfsense_web/components/layout/ui/sidebar
Trevin Chow a2ddf47650 refactor(anon-chat): route upload through anonymousChatApiService
Fixes #1245. Deduplicate the anonymous-chat file upload request, which
was inlined verbatim in DocumentsSidebar.tsx and free-composer.tsx
while anonymousChatApiService.uploadDocument already existed.

Key change: service now returns a discriminated result instead of
throwing on 409. Callers need to distinguish 409 (quota exceeded, ->
gate to login) from other non-OK responses (real errors, -> throw).

  export type AnonUploadResult =
    | { ok: true; data: { filename: string; size_bytes: number } }
    | { ok: false; reason: "quota_exceeded" };

Both call sites now do:

  const result = await anonymousChatApiService.uploadDocument(file);
  if (!result.ok) {
    if (result.reason === "quota_exceeded") gate("upload more documents");
    return;
  }
  const data = result.data;

Dropped the BACKEND_URL import in both files (no longer used). Verified
zero remaining /api/v1/public/anon-chat/upload references in
surfsense_web/.
2026-04-23 03:26:42 -07:00
..
AllPrivateChatsSidebar.tsx chore: ran linting 2026-04-07 05:55:39 +05:30
AllSharedChatsSidebar.tsx chore: ran linting 2026-04-07 05:55:39 +05:30
AnnouncementsSidebar.tsx refactor: unify sidebar state management in LayoutDataProvider to allow only one slide-out panel open at a time 2026-03-22 00:01:31 +05:30
ChatListItem.tsx feat: implement dropdown menu state management in DocumentNode and sidebar components 2026-03-28 02:32:03 +05:30
DocumentsSidebar.tsx refactor(anon-chat): route upload through anonymousChatApiService 2026-04-23 03:26:42 -07:00
InboxSidebar.tsx feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
index.ts refactor: unify sidebar state management in LayoutDataProvider to allow only one slide-out panel open at a time 2026-03-22 00:01:31 +05:30
MobileSidebar.tsx feat: enhance chat sidebar functionality and UI 2026-03-17 03:55:49 +05:30
NavSection.tsx chore: linting 2026-03-31 21:42:03 -07:00
PageUsageDisplay.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
PremiumTokenUsageDisplay.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
Sidebar.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
SidebarButton.tsx refactor: update document processing status handling and improve sidebar components 2026-03-31 21:29:46 -07:00
SidebarCollapseButton.tsx feat: enhance sidebar and toolbar components with shortcut key display, improving user interaction and accessibility 2026-03-07 02:50:01 +05:30
SidebarHeader.tsx fix: remove unused useRouter and useParams in SidebarHeader 2026-03-25 10:32:53 +08:00
SidebarSection.tsx chore: ran linting 2026-03-17 04:40:46 +05:30
SidebarSlideOutPanel.tsx feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
SidebarUserProfile.tsx feat: implement download functionality for different OS in SidebarUserProfile and DownloadButton components, enhance user experience with localized download messages 2026-04-10 19:53:13 +05:30