Skip to content

fix: render research PDFs from canonical Markdown - #164

Merged
iamjr15 merged 1 commit into
mainfrom
fix/research-markdown-pdf
Aug 5, 2026
Merged

fix: render research PDFs from canonical Markdown#164
iamjr15 merged 1 commit into
mainfrom
fix/research-markdown-pdf

Conversation

@iamjr15

@iamjr15 iamjr15 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Render the validated research report Markdown directly into the PDF instead of flattening it into a separate section/paragraph model.
  • Preserve the same headings, prose, lists, task items, tables, code, links, citations, and ordering shown in chat.
  • Keep structured claim provenance internal while returning a smaller user-facing research tool result.

Architecture

The research synthesis remains the single content source. The Worker parses that bounded Markdown with a pinned GFM parser, stages the Markdown and its semantic tokens in the existing hidden artifact-input path, and the sandbox's existing React PDF runtime renders those tokens into a durable workspace/R2 PDF.

No database, storage, sandbox snapshot, or deployment-topology change is required.

Decisions Made

Decision Choice Alternatives considered Reasoning
Content source Use report.report verbatim Rebuild a document from claims and sources Prevents chat/PDF drift and removes synthetic appendices the user did not see in chat.
Markdown parsing Pin marked in agent-core Regex parsing; add runtime dependencies Gives standards-based GFM tokens without requiring a new Daytona snapshot.
PDF runtime Reuse React PDF and baked Liberation fonts Browser print-to-PDF; new PDF vendor Keeps rendering deterministic, sandbox-local, and compatible with the current document boundary.
Tool result Return report + artifact only Return all findings, claims, and sources Provenance is validated internally; the smaller result makes verbatim chat presentation reliable.

Edge Cases Handled

Scenario Handling
Long multi-page reports A4 wrapping, widow/orphan controls, and heading presence rules prevent clipping and orphaned headings.
Nested, ordered, and task lists Semantic list tokens retain nesting, numbering, and task state.
Comparison tables Header, alignment, cell borders, and row-safe pagination are preserved.
Citations Safe HTTP(S)/mailto links remain visible and clickable PDF annotations.
Inline HTML or unsafe URLs HTML is rendered as inert text and unsupported URL schemes are not made clickable.

How to Review

  1. Start with research-report-document-support.ts and research-tools.ts for the one-source data flow.
  2. Review execute.ts and scripts.ts for parsing, staging, and semantic PDF rendering.
  3. Review the synthesis/system prompts and README for the chat/PDF contract.

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm turbo build --force
  • pnpm deadcode
  • pnpm architecture:check
  • pnpm turbo skills:build
  • Rendered a five-page hostile GFM fixture and visually inspected every page.
  • Verified extracted text, A4 metadata, and clickable link annotations with Poppler.

Render validated report Markdown directly into PDF.

Chat and deliverable retain the same structure, citations, and ordering.

Add print-safe GFM styles and exclude internal provenance from the user-facing artifact.
@iamjr15
iamjr15 merged commit f1b0f63 into main Aug 5, 2026
4 checks passed
@iamjr15
iamjr15 deleted the fix/research-markdown-pdf branch August 5, 2026 04:56
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