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

+17 -4
View File
@@ -4,6 +4,7 @@ import asyncio
import json
import os
import sqlite3
import subprocess
from functools import partial
from unittest.mock import AsyncMock, MagicMock
@@ -359,7 +360,9 @@ async def test_recovery_rechecks_attachment_workspace_boundary(tmp_path):
manager = make_manager(tmp_path, sessions)
manager.config.agents.defaults.workspace = str(workspace)
manager.config.tools.restrict_to_workspace = True
attachment = workspace / "report.txt"
reports = workspace / "reports"
reports.mkdir()
attachment = reports / "report.txt"
attachment.write_text("report")
msg = message(generation=session.generation)
msg.media = [str(attachment)]
@@ -367,9 +370,19 @@ async def test_recovery_rechecks_attachment_workspace_boundary(tmp_path):
try:
await manager.bus.publish_outbound(msg)
attachment.unlink()
private = tmp_path / "private.txt"
private.write_text("not authorized")
attachment.symlink_to(private)
reports.rmdir()
private = tmp_path / "private"
private.mkdir()
(private / "report.txt").write_text("not authorized")
if os.name == "nt":
# Directory junctions resolve across the same workspace boundary
# without requiring Windows' privileged symlink capability.
subprocess.run(
["cmd", "/c", "mklink", "/J", str(reports), str(private)],
check=True, capture_output=True,
)
else:
reports.symlink_to(private, target_is_directory=True)
await manager._send_scheduled(channel, msg)
channel.send.assert_not_called()
assert rows(manager._outbox)[0]["error"] == "attachment_access_denied"