SurfSense/surfsense_web/components/layout
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
..
hooks chore: linting 2026-03-31 14:45:46 -07:00
providers feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
types refactor: update LayoutDataProvider and NavSection components to use DocumentsProcessingStatus for improved document processing status handling 2026-03-08 21:16:52 +05:30
ui refactor(anon-chat): route upload through anonymousChatApiService 2026-04-23 03:26:42 -07:00
index.ts Merge branch 'dev' into implement-surfsense-docs-mentions 2026-01-13 00:55:16 -08:00