Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix: preserve Word document chrome in desktop docx previews

6 months ago

862e38d
Authored
mweinbach4/17/2026, 3:18:21 PM
The in-app DOCX preview was flattening Word-specific structure into a generic
Mammoth rendering, which made the live desktop view diverge sharply from the
actual work document in Microsoft Word. This keeps Mammoth for text extraction
but layers in a small DOCX layout-hints reader so the preview can recover the
header artwork, footer text, accent colors, divider rule, and intro-block
hierarchy from the OOXML package without adding another renderer dependency.

Constraint: No new desktop dependency for DOCX rendering; reuse the existing mammoth bundle and renderer token system
Rejected: Add a dedicated docx-preview dependency | violates the repo's no-new-dependency guidance for this fix
Rejected: Shell out to Word or LibreOffice for every preview | too slow and platform-brittle for an interactive modal
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep DOCX chrome extraction preview-only and token-safe; if richer document fidelity is needed later, expand the preview parser deliberately instead of bypassing it with ad hoc shelling out
Tested: bun run typecheck; bun run typecheck:desktop; cd apps/desktop && bun test; bun test; live Electron preview compared against Microsoft Word for the Intel Pro Day 2026 work doc
Not-tested: DOCX files that store primary chrome outside header1/footer1 OOXML parts

Parent49a0ed2

5 files changed
  • apps/desktop/src/lib/docxPreview.ts+235−0
  • apps/desktop/src/mammoth-internals.d.ts+10−0
  • apps/desktop/src/ui/FilePreviewModal.tsx+60−11
  • apps/desktop/test/docx-preview.test.ts+41−0
  • apps/desktop/test/file-preview-modal.test.tsx+22−0