feat(agents): make sources optional and drop the synthetic "Default" source

The sources list used to start with a fake "Default" entry that had no id
and, at run time, meant "no source, skip retrieval". The agent form
pre-selected it, snapped back to it when the last source was deselected,
and refused to publish without it, so a new agent always looked like it
had a knowledge base when it had none.

Backend
- /api/sources returns only ingested sources; no placeholder row.
- Publishing an agent no longer requires a source on create or update.
  The legacy "default" value is still accepted and maps to NULL.

Frontend
- The agent source picker starts empty, can be cleared, and shows a hint
  that a source-less agent answers from the model and its tools only.
- The picker groups sources into "Your sources" and "Shared with team"
  when any team-shared source exists, shows "N sources selected" for a
  multi-selection, and gets the same "Go to Sources" / "Upload new"
  footer as the chat picker. A source uploaded from the form is selected
  when it lands.
- Source selection serialisation and the picker id live in one helper
  shared with the chat picker; the four copies in the form are gone.
- The client no longer seeds a placeholder source in the store, and the
  dead auto-select of a "default" document is removed.
This commit is contained in:
Alex committed 2026-09-09 17:59:08 +01:00
1 parent fb15649a3f
commit 79d418f32a
23 files changed
+532 -365

No files matched your search

+1 -3
View File
@@ -55,6 +55,7 @@ import {
partitionAttachmentFiles,
} from '../constants/fileUpload';
import { UserToolType } from '../settings/types';
import { sourceItemId } from '../utils/sourceUtils';
import { isChatToolVisible } from '../utils/toolUtils';
const generateId = (): string =>
@@ -1459,9 +1460,6 @@ export default function MessageInput({
void _docs;
};
// Stable id for matching selected sources: prefer ``id``, fall back to ``date``.
const sourceItemId = (doc: Doc): string => doc.id || doc.date;
const sourceItems: MultiSelectPopoverItem[] = (sourceDocs || []).map(
(doc) => ({
id: sourceItemId(doc),