feat(attachments): support local files and video attachments (#6321)
* feat(attachments): support local files and video attachments Share gateway inspection and send validation for borrowed local paths while preserving binary uploads, original-file ownership, and existing limits. Related to NAN-284. Native provider video input remains outside this change. * test: make cross-platform verification fixtures self-contained * test(webui): align typed fixtures with runtime contracts * fix(webui): preserve uploaded video playback during history sync * test(tui): preserve local attachment drafts across resizes * perf(attachments): preserve upload caches and release video previews * docs(webui): keep attachment guidance user-focused * chore: remove redundant dependency comment * test(providers): make stream idle renewal timing deterministic * fix(attachments): keep upload byte limits out of local references Validate common format/count rules separately from upload byte budgets. Keep local inspection and send-time checks metadata-only, and exclude local references from composer and pending-upload totals. Explain upload size rejections with actual size and maximum in all ten locales. Related to NAN-284. * fix(attachments): retain image references and draft order * fix(attachments): close local reference UX and authorization gaps * fix(attachments): preserve focus during asynchronous path confirmation
This commit is contained in:
1 parent
7dfeff9ddf
commit
254f94b068
65 files changed
+1816
-292
No files matched your search
@@ -13,12 +13,14 @@ interface AttachmentTileProps {
|
||||
className?: string;
|
||||
inline?: boolean;
|
||||
variant?: "default" | "compact";
|
||||
pending?: boolean;
|
||||
}
|
||||
|
||||
export function AttachmentTile({ attachment, className, inline = false, variant = "default" }: AttachmentTileProps) {
|
||||
export function AttachmentTile({ attachment, className, inline = false, variant = "default", pending = false }: AttachmentTileProps) {
|
||||
const { t } = useTranslation();
|
||||
const videoUrl = attachment.url;
|
||||
const [failedUrl, setFailedUrl] = useState<string | undefined>(undefined);
|
||||
const failed = !!attachment.url && failedUrl === attachment.url;
|
||||
const failed = !!videoUrl && failedUrl === videoUrl;
|
||||
const [imageOpen, setImageOpen] = useState(false);
|
||||
const hasUrl = typeof attachment.url === "string" && attachment.url.length > 0;
|
||||
const label = attachmentLabel(attachment, t);
|
||||
@@ -36,7 +38,7 @@ export function AttachmentTile({ attachment, className, inline = false, variant
|
||||
);
|
||||
}
|
||||
|
||||
if (attachment.kind === "video" && hasUrl) {
|
||||
if (attachment.kind === "video" && hasUrl && !failed) {
|
||||
return (
|
||||
<AttachmentFrame
|
||||
attachment={attachment}
|
||||
@@ -45,9 +47,10 @@ export function AttachmentTile({ attachment, className, inline = false, variant
|
||||
variant={variant}
|
||||
>
|
||||
<video
|
||||
src={attachment.url}
|
||||
src={videoUrl}
|
||||
controls
|
||||
preload="metadata"
|
||||
onError={() => setFailedUrl(videoUrl)}
|
||||
className={cn(
|
||||
"block w-full bg-black",
|
||||
variant === "compact" ? "max-h-40" : "max-h-[26rem]",
|
||||
@@ -100,9 +103,15 @@ export function AttachmentTile({ attachment, className, inline = false, variant
|
||||
aria-label={label}
|
||||
>
|
||||
{body}
|
||||
<span className="sr-only">
|
||||
{t("message.attachmentUnavailable", { defaultValue: "Attachment unavailable" })}
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{pending ? t("message.delivery.sending") : t("message.attachmentUnavailable", { defaultValue: "Attachment unavailable" })}
|
||||
</span>
|
||||
{attachment.kind === "video" && failed && !pending ? (
|
||||
<button type="button" onClick={() => setFailedUrl(undefined)}
|
||||
className="shrink-0 rounded-sm px-1 text-foreground underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2">
|
||||
{t("common.retry")}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user