Generated PDF reports (#24) #45

Merged
jfro merged 11 commits from pdf-reports into main 2026-10-22 20:58:42 +00:00
Owner

Ready for review.

Implements #24. Design and the tablet-check guide: docs/generated-pdfs.md.

Done

  • fe74570 New PDF items in the cloud (Remarkable.NewPdf): .metadata + .content (formatVersion 2 with cPages, like tablet-written PDFs) + .pdf, root index schema 4. Written after a sync, snapshot first, 412 retry ×3, never added twice, printed text extracted after.
  • a81654f Typst compiler (Reports, Reports.Typst): Typst 0.15.1 pinned (Dockerfile sha256, CI, mise). Templates summary / weekly-review / notes-digest. All Markdown text escaped. Package downloads blocked. rM2 screen-sized pages.
  • 395dcf5 Base PDFs (Reports.Bases): bundled set in priv/report_templates/base/ (dot grid, lined, Cornell; made here with Typst, sources + license in README) and any library PDF by doc id, within the scope's reach.
  • 0a9c4a3 RM_NEW_PDF_CONTENT=rmapi fallback to the rmapi-js .content shape; tests that @preview imports fail and that abc".len() stays text.
  • 3e773f7 make_pdf (PdfReports): chat draft card (first page via pdf.js, Add to library / Discard, superseded by later drafts, retry-safe); MCP tool for write keys writes at once, only into folders and over PDFs the key reaches. Docs updated (generated-pdfs, mcp, verification).
  • mix precommit: 834 tests pass.

Still to do

  • Tablet check by Jeremy (steps in docs/generated-pdfs.md → "How to do the tablet check"): does the tablet open/annotate the new PDF, does the page fill the screen.
  • Nye's review.
  • Swap in or add third-party base templates if Nye finds free-to-use ones.
Ready for review. Implements #24. Design and the tablet-check guide: [docs/generated-pdfs.md](https://git.knope.dev/jfro/rm-analyzer/src/branch/pdf-reports/docs/generated-pdfs.md). ## Done - `fe74570` **New PDF items in the cloud** (`Remarkable.NewPdf`): .metadata + .content (formatVersion 2 with cPages, like tablet-written PDFs) + .pdf, root index schema 4. Written after a sync, snapshot first, 412 retry ×3, never added twice, printed text extracted after. - `a81654f` **Typst compiler** (`Reports`, `Reports.Typst`): Typst 0.15.1 pinned (Dockerfile sha256, CI, mise). Templates summary / weekly-review / notes-digest. All Markdown text escaped. Package downloads blocked. rM2 screen-sized pages. - `395dcf5` **Base PDFs** (`Reports.Bases`): bundled set in `priv/report_templates/base/` (dot grid, lined, Cornell; made here with Typst, sources + license in README) **and** any library PDF by doc id, within the scope's reach. - `0a9c4a3` `RM_NEW_PDF_CONTENT=rmapi` fallback to the rmapi-js .content shape; tests that `@preview` imports fail and that `abc".len()` stays text. - `3e773f7` **`make_pdf`** (`PdfReports`): chat draft card (first page via pdf.js, Add to library / Discard, superseded by later drafts, retry-safe); MCP tool for write keys writes at once, only into folders and over PDFs the key reaches. Docs updated (generated-pdfs, mcp, verification). - `mix precommit`: 834 tests pass. ## Still to do - Tablet check by Jeremy (steps in docs/generated-pdfs.md → "How to do the tablet check"): does the tablet open/annotate the new PDF, does the page fill the screen. - Nye's review. - Swap in or add third-party base templates if Nye finds free-to-use ones.
NewPdf builds a PDF item from scratch as the tablet keeps one (formatVersion 2
.content with a cPages entry per PDF page, .metadata, the .pdf), plans it with
Commit (adding exactly that item, in a folder that's in the cloud), and writes
it after a sync like typed pages: snapshot first, 412 retried up to 3 times,
sync after, printed text read at once. Page ids derive from the item id, so a
retry builds the same item and finds it already there.

Also pins Typst 0.15.1 in the Dockerfile runtime stage, CI and mise.toml.
feat(reports): compile PDF reports with Typst from templates
Some checks failed
CI / test (pull_request) Failing after 1m21s
a81654f30c
RmAnalyzer.Reports typesets a report from a template in
priv/report_templates (summary, weekly review, notes digest), its fields and a
Markdown body, at the tablet's screen size (rM2 by default, Paper Pro and Move
too), or over a base PDF from the blob store at its page size, its pages drawn
behind the report's. Typst runs in a temp dir as --root, with no package
downloads, killed at a timeout; TYPST_PATH overrides the command.

Reports.Typst turns Markdown (MDEx) into Typst markup, escaping every text
node so text in the notes or the LLM's answer never runs as markup or code.

Also PdfInfo.page_count/1, and docs/generated-pdfs.md and README updated.
feat(reports): base PDFs from a bundled set or the library
Some checks failed
CI / test (pull_request) Failing after 1m21s
395dcf5f27
Bundled bases (dot grid, lined, Cornell) made with Typst in
priv/report_templates/base/, with sources, bases.json and a README
listing each one's source and license. Reports.Bases resolves a bundled
name or a library PDF by document id, within the scope's reach.
compile/4 takes {:file, path} as well as a blob hash.
RM_NEW_PDF_CONTENT=rmapi writes a new PDF's .content as rmapi-js does
(formatVersion 1, pages, redirectionPageMap) in case a tablet won't open
the tablet-shaped one. Tests: a template importing @preview fails, and
text like abc".len() stays text.
feat(reports): make_pdf in the chat (draft card) and over MCP
Some checks failed
CI / test (pull_request) Failing after 1m22s
3e773f762a
PdfReports checks a make_pdf call (name, Markdown, template, fields,
folder, bundled or library base, device, digest pages) and compiles it.
The chat drafts it into pdf_drafts with the new document's UUID chosen
up front; the card shows the first page via pdf.js with Add/Discard,
and a later answer's draft supersedes it. Write keys over MCP get it
written at once, only into folders and over PDFs the key reaches.
Docs: make_pdf, base sources, and how to do the tablet check.
fix(reports): kill a stuck Typst with the shell's builtin
All checks were successful
CI / test (pull_request) Successful in 1m21s
c250072c52
CI's image (and slim release images) have no kill binary, so the
timeout crashed with :enoent instead of stopping Typst.
check_parent now reads the parent's .metadata from the cloud snapshot:
it must be a CollectionType that isn't deleted and isn't in the trash,
itself or through a folder above it. A notebook or PDF parent gets a
sentence an agent can act on ("Meetings" (a) is a notebook, not a
folder). The chat and MCP make_pdf both write through NewPdf.plan, so
both get the check against the cloud, not only the local library.

Review finding F1.
feat(reports): graph, meeting and weekly bases; bases are CC0-1.0
All checks were successful
CI / test (pull_request) Successful in 1m24s
80af5043de
Six bundled bases now, all made here with Typst. The README states
CC0-1.0 outright instead of pointing at a license the repo doesn't have.
fix(reports): cap base PDFs, keep app-filled fields from callers
All checks were successful
CI / test (pull_request) Successful in 1m23s
deec76ff00
Review notes from Nye: a base PDF is capped at 50 MB and 500 pages before
it's copied into the compile root; a template field marked (app), the
notes digest's pages, isn't listed and can't be passed by a caller; the
docs say CJK text has no font yet.
docs(reports): run the branch locally for the tablet check
All checks were successful
CI / test (pull_request) Successful in 1m24s
f8d1048538
feat(reports): left margin clears the tablet's toolbar, configurable
All checks were successful
CI / test (pull_request) Successful in 1m23s
34c5abaabf
Tablet check feedback: the rM2 toolbar (about 13.5 mm) covered text at the
old 12 mm left margin. Reports.Layout now holds the margins in one place
(left 24, right 14, top 9, bottom 16 mm) and Reports passes all four to
every template. The left one comes from RM_REPORTS_LEFT_MARGIN_MM, then a
per-account setting on the reMarkable settings page, then 24 mm. A base's
margins win but never bring the left one closer than that.

The six bundled bases are redrawn (still CC0, rM2 size) so dots, grid,
rules and labels start at the 24 mm margin where the text does.
jfro changed title from WIP: Generated PDF reports (#24) to Generated PDF reports (#24) 2026-10-22 20:52:33 +00:00
jfro merged commit ee0fe03291 into main 2026-10-22 20:58:42 +00:00
jfro deleted branch pdf-reports 2026-10-22 20:58:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!45
No description provided.