SurfSense/surfsense_web/components/free-chat
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
..
anonymous-chat.tsx feat: implement analytics tracking for desktop app events 2026-04-18 14:35:14 -07:00
free-chat-page.tsx chore: linting 2026-04-22 01:05:31 -07:00
free-composer.tsx refactor(anon-chat): route upload through anonymousChatApiService 2026-04-23 03:26:42 -07:00
free-model-selector.tsx fix(dialogs): move open-reset effects into onOpenChange handlers 2026-04-19 16:09:34 +05:30
free-right-panel.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
free-thread.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
quota-bar.tsx feat: no login experience and prem tokens 2026-04-15 17:02:00 -07:00
quota-warning-banner.tsx cloud: added openrouter integration with global configs 2026-04-15 23:46:29 -07:00