Skip to content

Add document download#16

Merged
exilis merged 21 commits into
masterfrom
feat/document-download
Jun 26, 2026
Merged

Add document download#16
exilis merged 21 commits into
masterfrom
feat/document-download

Conversation

@exilis

@exilis exilis commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a download button (⤓) in the tab bar that downloads the currently-open document — the original bytes on disk, with the original filename.
  • Works for every document type reefdoc opens (markdown, Allium, code, PDF, DOCX, XLSX, PPTX).
  • Server: new opt-in ?download=1 mode on /api/file sets a sanitized Content-Disposition: attachment header; existing inline behavior, path-safety, and content-type handling are unchanged.
  • Frontend: pure downloadUrl(path) builder, a refreshDownloadButton() visibility helper wired into every active-document state change, native browser download via a temporary <a download>.

Test coverage (4 layers)

  • Go handler unit (server_test.go): header set, basename, filename sanitization (CRLF/quote injection blocked), inline-preservation, body-unchanged.
  • HTTP-level E2E (e2e_test.go): ?download=1 over a real httptest server asserts Content-Disposition and that inline requests omit it.
  • JS unit (app.test.js): pure downloadUrl builder incl. encoding of spaces, slashes, and query-delimiter chars.
  • Browser E2E (web/e2e/download.e2e.js, Playwright + Chromium): builds and drives the real binary; asserts button hidden→appears, text download (byte-exact content), binary download fidelity, and hides after closing the last tab. Verified with a teeth-check (tests fail when the feature is broken). New isolated CI e2e job; dev-only dependency, shipped binary unchanged.

Design & plans

  • Specs: docs/specs/2026-06-26-document-download-design.md, docs/specs/2026-06-26-download-e2e-design.md
  • Plans: docs/plans/2026-06-26-document-download.md, docs/plans/2026-06-26-download-e2e.md

Test Plan

  • go test -race ./... — pass
  • npm test — 60/60 (unit; does not run the e2e file)
  • npm run e2e — 5/5 (Playwright, real binary)
  • go vet / gofmt -l clean
  • Browser E2E now provides the automated click→download smoke coverage

@exilis exilis force-pushed the feat/document-download branch from 9a4da25 to 1501943 Compare June 26, 2026 13:01
@exilis exilis merged commit b79e973 into master Jun 26, 2026
3 checks passed
@exilis exilis deleted the feat/document-download branch June 26, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant