← Back to Pull requests

Preview files in My files without downloading them, HEIC included #154

Closed
unknown closed this pull request without merging on Nov 28, 2026 16:56 UTC
View on GitHub
unknown unknown commented on Nov 28, 2026 07:10 UTC
Author

What changed

Clicking a file in My files used to offer only its details and a download. Now:

  • The details panel shows the photo itself (or a video's first frame) in place of the generic icon. Clicking it, or the new Preview button above Download file, opens a full-size viewer over the list.

  • The viewer shows photos, video, music, PDFs and plain text. The arrow keys (or the arrow buttons) step through the other files in the folder, in the order they're listed. Anything it can't show offers its download instead, and closing it leaves the last file's details open.

  • iPhone photos (HEIC), which only Safari draws, now show in any browser when the host is a Mac: the host makes a JPEG of each the first time it's looked at. This also covers files opened through shared links.

  • Photos, videos and music get their own icons in the list.
  • How it works

    Showing files. GET /api/files/file?path= sends one of your own files inline. It uses the same allow-list (SharePreview) and locked-down security headers as shared links' /api/shared/{token}/file, so HTML, SVG and the like are still only ever downloads. The path is opened before the kind is checked, so anything a download refuses (paths outside your folder, hidden folders, links) is refused the same way. /api/files now lists each file's preview kind. Both file routes go through one helper, ShowAsync.

    HEIC. PhotoPreviews converts with macOS's built-in /usr/bin/sips into a JPEG of at most 2560px (never enlarged). An 8.7 MB HEIC became a 485 KB JPEG in about 0.45 s the first time and 3 ms afterwards. Details:

  • The same photo requested twice at once (by the details panel and the viewer) is converted only once, and at most two photos convert at a time across the host.

  • A request that's cancelled doesn't stop the conversion, so the next look finds it ready.

  • Editing a photo in place gets it converted again.

  • Download still gives the original.
  • The cache. Converted JPEGs live under the account's .homebase/previews (never browsed, copied or synced). It's capped at 512 MB per account, roughly 1,000 photos, and the least recently viewed are deleted first. Backups exclude it and the account's own "You use…" figure leaves it out. The host-wide storage cap still counts it, since it does take up disk.

    Hosts that can't convert. On a Linux host, or for a file sips can't read, the photo is sent as it is, same as before. Safari shows it; other browsers show "can't show this file" and offer the download.

    Refactor. The shared-link page already had a viewer. It moves from SharedPage.tsx into Preview.tsx, takes its show and download addresses as arguments instead of a link token, and both pages use it. Behaviour on shared pages is unchanged.

    Things worth a look

  • Security. The file route shows only the existing allow-listed kinds, with nosniff and a sandboxed CSP. sips is run with an argument list, never a shell, on a path that PathPolicy has already resolved inside the account. A shared-link visitor can cause the owner's HEIC to be converted, but only for a photo the link already shares.

  • Image sizes. Non-HEIC photos are still sent at full size, including for the small picture in the details panel. Server-made thumbnails would help over remote access; docs/ios.md already plans /api/files/thumbnail, which could reuse this cache.

  • Linux. Linux hosts get no HEIC conversion. Nothing suitable is built in there, and adding a native image library is the open question docs/ios.md describes.
  • Testing

  • Server: all 530 tests pass. New ones cover the inline route, the HTML/SVG refusal and the security checks (paths outside the folder, links, other accounts, signed out). PhotoPreviewTests covers convert-once, same-request dedupe, re-converting after an edit, shared links, both fallbacks, the cache budget and usage. The test host defaults to "can't convert" and uses a stand-in converter, so CI behaves the same on macOS and Ubuntu. The one test of real sips runs only on macOS.

  • Web: all 193 tests pass, including 3 new ones for the details picture, stepping through the viewer and the fallback. Type-check and production build are clean.

  • By hand: I ran a throwaway server with sample files in the browser pane and checked JPEG, HEIC (before and after the change), text, PDF and HTML, desktop and narrow layouts, and the cache on disk.
  • 🤖 Generated with Claude Code

    Diff: 564 lines (+423 / -141) across 7 files Reviewer: ethanteng Review duration: 586m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 564 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #154"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%