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.
78 lines
3.0 KiB
TypeScript
78 lines
3.0 KiB
TypeScript
import Row from "@moduletrace/twui/layout/Row";
|
|
import Link from "@moduletrace/twui/layout/Link";
|
|
import { FileText, Image as ImageIcon } from "lucide-react";
|
|
import Span from "@moduletrace/twui/layout/Span";
|
|
import type { TaskFile } from "@/src/types";
|
|
import fileRef from "@/src/utils/file-ref";
|
|
|
|
type Props = {
|
|
file: TaskFile;
|
|
/**
|
|
* A crew manager can unlink it.
|
|
*/
|
|
onDetach?: () => void;
|
|
busy?: boolean;
|
|
};
|
|
|
|
/**
|
|
* One file on a task: its name, opening the bytes at `/media/<id>` (private,
|
|
* so only someone who reaches the task can load it), and its file ref (built by `fileRef`) when it
|
|
* lives in a bot's or workspace's folder (so the file's real home is
|
|
* reachable too).
|
|
*/
|
|
export default function TaskFileRow({ file, onDetach, busy }: Props) {
|
|
if (file.missing) {
|
|
return (
|
|
<Row className="w-full min-h-10 gap-2! flex-nowrap items-center px-1 py-1">
|
|
<FileText size={16} className="shrink-0 text-ink-disabled" aria-hidden />
|
|
<Span className="grow min-w-0 text-[13px] leading-[18px] text-ink-disabled truncate">
|
|
{file.name || `File ${file.media_id}`} (gone)
|
|
</Span>
|
|
</Row>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Row className="w-full min-h-10 gap-2! flex-nowrap items-center px-1 py-1">
|
|
{file.media_type == "image" ? (
|
|
<ImageIcon size={16} className="shrink-0 text-ink-secondary" aria-hidden />
|
|
) : (
|
|
<FileText size={16} className="shrink-0 text-ink-secondary" aria-hidden />
|
|
)}
|
|
<Link
|
|
href={`/media/${file.media_id}`}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
title={file.name || "Open the file"}
|
|
className="grow min-w-0 text-[13px] leading-[18px] text-ink truncate hover:underline"
|
|
>
|
|
{file.name || `File ${file.media_id}`}
|
|
</Link>
|
|
{file.kind == "reference" ? (
|
|
<Span className="shrink-0 text-[11px] leading-4 text-ink-secondary">reference</Span>
|
|
) : null}
|
|
{file.bot_file_id ? (
|
|
<Span className="shrink-0 text-[11px] leading-4 text-ink-secondary">
|
|
{fileRef({ id: file.bot_file_id })}
|
|
</Span>
|
|
) : null}
|
|
{onDetach ? (
|
|
<Span
|
|
role="button"
|
|
tabIndex={0}
|
|
aria-disabled={busy}
|
|
title="Unlink this file"
|
|
onClick={() => (busy ? undefined : onDetach())}
|
|
onKeyDown={(event) => {
|
|
if (busy) return;
|
|
if (event.key == "Enter" || event.key == " ") onDetach();
|
|
}}
|
|
className="shrink-0 px-1 text-[11px] leading-4 text-ink-secondary cursor-pointer hover:text-ink"
|
|
>
|
|
Unlink
|
|
</Span>
|
|
) : null}
|
|
</Row>
|
|
);
|
|
}
|