Files
cobble/src/functions/backend/db/bot-files/store-chat-attachments.test.ts
T
tbenandClaude Opus 5.5 ac3ebc43d4 Keep searchable text only in knowledgebases
Every bot file was chunked into bot_file_chunks and embedded into
bot_file_vectors, and uploads kept their extracted text in
media.text_content, which together took most of the database. Bot
files are no longer indexed: bots find them by name or path with
list_files and read them with read_file, and search_files, ingest_file
and the files modal's re-read button are gone. Attachments keep no
text; a reply reads a document from the file. Only knowledgebase
documents keep text.

The schema drops both tables and the ingest columns. At boot,
dropStoredFileText removes what older versions stored (file jobs,
upload text) and vacuums once much of the database is free. The
media:prune-text script it replaces is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 04:44:46 +01:00

33 lines
1.0 KiB
TypeScript

import { describe, expect, test } from "bun:test";
/**
* The module's own source, since the regression it guards is what the code
* writes to the database, not what it returns.
*/
async function source() {
return await Bun.file(
`${import.meta.dir}/store-chat-attachments.ts`,
).text();
}
describe("storeChatAttachments", () => {
/**
* The same text used to be copied onto the new `bot-file` media row,
* so a chat upload kept a second copy of its extracted text. Bot files
* keep no text at all: a bot reads the bytes when it needs them.
*/
test("never writes text_content onto the file's media row", async () => {
const code = await source();
expect(code).not.toContain("SET text_content");
expect(code).not.toContain("text_content = ?");
});
test("saves the bytes and indexes nothing", async () => {
const code = await source();
expect(code).toContain("recordBotFile(");
expect(code).not.toContain("enqueueFileIngest(");
});
});