refactor(word-addin): delete the caller-less readDocumentOoxml helper

↗ view on GitHub · Amal · 2026-08-05 · 74a32df9

WHY THIS MATTERS
useWordDoc exported `readDocumentOoxml()` - a wrapper around Word's
body.getOoxml() - but nothing in the add-in ever called it. Its only
"usage" was the e2e Office shim faithfully counting getOoxml() calls in
an `ooxmlReads` counter that no test asserted on. Dead exports are not
harmless: each one is API surface a reader must understand, a mock
author must simulate (as happened here - the shim grew a whole fake
OOXML serializer for it), and a refactorer must preserve "just in
case". The mock tracking is the tell: test scaffolding that exists only
to observe code that exists only to be observed.

WHAT IS DEAD-CODE GRAVITY
Unused code attracts more unused code. The export looked load-bearing,
so the e2e mock implemented getOoxml(), which made the export look
USED (it appears in grep!), which is precisely how dead code survives
review after review. The way out is to trace real call graphs from
product code, not from test doubles: a symbol whose only references
live in mocks and their bookkeeping has zero callers.

HOW THE FIX WORKS
  - useWordDoc.ts: `readDocumentOoxml` is removed from the hook body
    and its returned API. The genuinely used readers remain -
    readDocumentText() for prompt context and getDocxBlob() for
    uploads (which gets real binary .docx bytes via getFileAsync, not
    OOXML).
  - e2e/support/office-mock.ts: the getOoxml() fake, the `ooxmlReads`
    counter (interface field + initializer + increment), and the
    docstring mention are deleted, so the shim once again models only
    what the add-in actually touches.

If OOXML-level reads are ever needed (e.g. style-preserving export),
the helper is one Word.run() away - with a caller to justify it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Repository open-legal-products/mike
Author Amal <mamalanand3@gmail.com>
Authored
Committed
Parents a2746c66
Stats 2 files changed , +1 , -26
Part of Add a Word add-in for chat and tracked rewrites

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-74a32df9.md from inside the repo you want the change in.

⬇ Download capture-commit-74a32df9.md