SurfSense/surfsense_web/lib
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
..
announcements chore: linting 2026-02-20 22:44:56 -08:00
apis refactor(anon-chat): route upload through anonymousChatApiService 2026-04-23 03:26:42 -07:00
chat feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
comments refactor: move pure utility functions out of UI components (#1194) 2026-04-14 17:39:11 +09:30
connectors refactor: completely remove Local Folder connector references and update folder sync logic 2026-04-02 22:21:16 +05:30
documents refactor: move pure utility functions out of UI components (#1194) 2026-04-14 17:39:11 +09:30
hitl feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
posthog feat: implement analytics tracking for desktop app events 2026-04-18 14:35:14 -07:00
query-client feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
remotion chore: ran linting 2026-03-25 00:27:24 +05:30
auth-errors.ts refactor: update authentication error handling to prevent user enumeration and improve error messages 2026-02-09 12:57:32 +05:30
auth-utils.ts feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
desktop-download-utils.ts 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
env-config.ts refactor: make Azure Document Intelligence an internal LLAMACLOUD accelerator instead of a standalone ETL service 2026-04-08 03:26:24 +05:30
error-toast.ts feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
error.ts feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
folder-sync-upload.ts feat: add processing mode support for document uploads and ETL pipeline, improded error handling ux 2026-04-14 21:26:00 -07:00
format-date.ts chore: ran frontend and backend linting 2026-02-01 22:54:25 +05:30
layout-events.ts refactor: move pure utility functions out of UI components (#1194) 2026-04-14 17:39:11 +09:30
provider-icons.tsx feat: enhance model selector UI abd added github models icon 2026-04-14 20:35:16 +05:30
source.ts chore: removed announcements from navbar and rewrote tagline 2026-02-27 15:45:48 -08:00
supported-extensions.ts chore: ran linting 2026-04-08 05:20:03 +05:30
utils.ts Add clipboard utility with fallback and show selectable URLs 2026-02-04 18:54:59 +02:00