feat(webui): refine attachment galleries and file cards (#6457)

* feat(webui): refine attachment galleries and file cards

* fix(webui): align attachment tests and Escape handling
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-25 22:39:44 +08:00
1 parent 44a7ef53ce
commit eed7b47753
19 files changed
+660 -255

No files matched your search

+7 -8
View File
@@ -184,17 +184,16 @@ def signed_media_attachments(
*,
sign_path: SignedMediaPath,
) -> list[dict[str, Any]]:
"""Map persisted media paths to WebUI attachment dicts with fresh signed URLs."""
"""Keep every attachment in order, signing only files available at projection time."""
out: list[dict[str, Any]] = []
for pstr in paths:
path = Path(pstr)
att = sign_path(path)
if att is None:
continue
url = att.get("url")
if not url:
continue
name = att.get("name") or path.name
try:
att = sign_path(path) if path.is_file() else None
except OSError:
att = None
name = (att.get("name") if att else None) or path.name
url = (att.get("url") if att else None) or ""
out.append({"kind": media_attachment_kind(name), "url": url, "name": name})
return out
+9 -4
View File
@@ -96,9 +96,14 @@ class WebUIMediaGateway:
media: list[dict[str, Any]] = []
for raw in paths:
path = Path(raw)
if raw in local:
url = self.local_attachment_url(raw, session_key=session_key) if path.is_file() else ""
else:
url = sign_media_path(path, secret=self.secret, media_dir=self._media_dir) or ""
try:
if not path.is_file():
url = ""
elif raw in local:
url = self.local_attachment_url(raw, session_key=session_key)
else:
url = sign_media_path(path, secret=self.secret, media_dir=self._media_dir) or ""
except OSError:
url = ""
media.append({"kind": media_attachment_kind(path.name), "name": path.name, "url": url})
return media