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:
chengyongru authored and GitHub committed 2026-10-22 18:32:18 +08:00
1 parent 7dfeff9ddf
commit 254f94b068
65 files changed
+1816 -292

No files matched your search

+20 -3
View File
@@ -688,7 +688,16 @@ export function useNanobotStream(
if (turnId) {
setMessages((prev) => transitionTurnDelivery(prev, turnId, "accepted"));
}
if (ev.event === "message_accepted") return;
if (ev.event === "message_accepted") {
if (ev.media_urls?.length) {
setMessages((prev) => prev.map((message) => (
message.role === "user" && message.turnId === ev.turn_id
? { ...message, media: ev.media_urls }
: message
)));
}
return;
}
if (ev.event === "user_message") {
if (ev.provenance?.session_message) {
flushPendingStreamEvents();
@@ -705,7 +714,11 @@ export function useNanobotStream(
setMessages((prev) => {
if (ev.turn_id && prev.some((message) => (
message.role === "user" && message.turnId === ev.turn_id
))) return prev;
))) return ev.media_urls?.length ? prev.map((message) => (
message.role === "user" && message.turnId === ev.turn_id
? { ...message, media: ev.media_urls }
: message
)) : prev;
const row: UIMessage = {
id: crypto.randomUUID(),
role: "user",
@@ -1021,7 +1034,11 @@ export function useNanobotStream(
const turnId = crypto.randomUUID();
const userMessageId = crypto.randomUUID();
if (sideChannel) transcriptRef.current.sideChannelTurnIds.add(turnId);
const previews = hasAttachments ? images!.map((i) => i.preview) : undefined;
const previews = hasAttachments ? images!.map(({ preview }) => (
preview.kind === "video" && preview.url?.startsWith("data:")
? { kind: preview.kind, name: preview.name }
: preview
)) : undefined;
setMessages((prev) => {
let projection = { ...transcriptRef.current.projection, messages: prev };
if ((!sideChannel && !continueActiveTurn) || finalizeActiveTurn) {