SurfSense/surfsense_web/components/layout/ui
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
..
dialogs refactor: optimize button rendering in CreateSearchSpaceDialog and enhance watched folder ID retrieval in DocumentsSidebar 2026-04-08 16:17:34 +05:30
header feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
icon-rail refactor: update various components to enhance styling consistency and improve user interaction by removing unnecessary classes and adjusting dialog and dropdown styles 2026-03-07 04:15:40 +05:30
right-panel refactor: enhance DocumentsFilters and FolderTreeView components for improved filter handling and search functionality 2026-04-06 14:41:53 +05:30
shell perf: lazy-load DocumentTabContent to reduce initial dashboard bundle size 2026-04-19 14:50:55 +02:00
sidebar refactor(anon-chat): route upload through anonymousChatApiService 2026-04-23 03:26:42 -07:00
tabs fix: replace window.location with router.push for client-side navigation 2026-04-08 00:01:30 -07:00
index.ts Merge branch 'dev' into implement-surfsense-docs-mentions 2026-01-13 00:55:16 -08:00