mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-24 19:41:14 +02:00
When the backend has no CloudFront signer configured, attachment metadata
returns a server-relative `download_url` like `/api/attachments/{id}/download`.
The CLI already handles relative URLs but the UI clients did not, leaving
the unified-endpoint path failing on Desktop downloads + Mobile Linking +
RN image previews.
Desktop renderer (web + Electron):
- packages/views/editor/use-download-attachment.ts: resolve via
`resolvePublicFileUrl` from @multica/core/workspace/avatar-url before
handing to Electron's `downloadURLSafely` bridge or to the web
placeholder/last-resort window.location redirect.
- packages/views/editor/attachment-preview-modal.tsx: resolve at
`normalize()` so `<img>`/`<iframe>`/`<video>` srcs are absolute when an
apiBaseUrl is configured; web with empty base keeps same-origin behaviour.
Mobile (RN):
- apps/mobile/lib/attachment-url.ts: new mirror helper using
`EXPO_PUBLIC_API_URL` (mobile sharing rule: mirror, don't import core).
- apps/mobile/components/issue/comment-attachment-list.tsx: resolve before
`Linking.openURL` (RN rejects relative URLs with 'Cannot open URL').
- apps/mobile/lib/markdown/markdown-image.tsx: extend `resolvedUri` memo to
feed the result through the helper for both `mc://` lookups and pass-through
paths so the RN image loader receives an absolute URL.
Tests:
- Three new desktop cases in use-download-attachment.test.tsx (relative URL
resolved against base, base trailing slash trimmed, absolute pass-through).
- New describe block in attachment-preview-modal.test.tsx covering image src,
iframe src, web same-origin keep-as-is, trailing slash trim, absolute
pass-through.
Verified: pnpm -C packages/views run typecheck, pnpm -C apps/desktop run
typecheck (node + web), pnpm -C apps/mobile run typecheck, vitest for the
two affected files (40 tests) and the full views suite (1158 tests).
Co-authored-by: multica-agent <github@multica.ai>