There is no public media any more. `/media/public/<id>` served a media row with no session at all, so anyone with the id could read a file. The public/private split is gone: the path is `/media/<id>` (and `/media/<id>/thumbnail`), every request is signed in first, and `grabUserMedia` decides whether the user may see it: their own upload, a bot's or workspace's picture or file they reach, or a file on a task they reach. Anything else is a 404 before a path is built. The `media.is_private` column and the two per-user directories went with it: uploads live in `media/<user_id>/` and there is nothing to pick between. The files browser's media volume is now the viewer's own folder whatever their role. Bots also say which of the two things they mean. A `[file:ID]` ref is a saved file and its chip opens the bytes; a folder is a new `[folder:volume:owner:path]` ref (`src/utils/folder-ref.ts`) whose chip opens the files browser there and downloads nothing. The old `[path:...]` ref and the extension sniffing that guessed file from folder are gone, so `import_file` names the folder holding a file it copied rather than the file itself. The prompts say what the Assistant got wrong: list before importing or saving, one copy per artifact, never split a file into parts unless asked, never claim the store is empty without a fresh list, and never invent a size cap. A re-import now says the path already existed instead of silently overwriting and reporting a fresh copy.
29 lines
898 B
TypeScript
29 lines
898 B
TypeScript
/**
|
|
* How a bot names one of its files in a message: `[file:12]`. The chat
|
|
* turns it into a link to the file (`linkComputerRefs`), which a chip
|
|
* renders with the file's name and opens the bytes at `/media/<id>`.
|
|
*
|
|
* A file ref is always a file. A folder is named with a `folderRef`
|
|
* (`[folder:bot:3:reports]`), which opens the files browser instead and
|
|
* never downloads anything.
|
|
*/
|
|
export default function fileRef({ id }: { id: number | string }) {
|
|
return `[file:${id}]`;
|
|
}
|
|
|
|
/**
|
|
* The link target a file ref becomes, e.g. `#file-12`.
|
|
*/
|
|
export const FileRefHrefPrefix = "#file-";
|
|
|
|
/**
|
|
* The id in a file ref's link target, or null.
|
|
*/
|
|
export function fileRefId({ href }: { href?: string | null }) {
|
|
if (!href?.startsWith(FileRefHrefPrefix)) return null;
|
|
|
|
const id = Number(href.slice(FileRefHrefPrefix.length));
|
|
|
|
return Number.isFinite(id) && id > 0 ? id : null;
|
|
}
|