Skip to content

Let macro-enabled .xlsm and .docm files open — today a folder drops them as unreadable, the preview has no format to name, and the assistant's read ends in 'import a UTF-8 copy', though the app's own parsers read both #265

Open

Description

@bencode

Problem

.xlsm and .docm — the macro-enabled workbook and document formats Excel and Word write natively — are classified unsupported by previewKindFor, which matches only the docx/xlsx extensions and the two plain media types (ui-packages/web/src/core/files.ts:112-113). Yet these files are zip packages holding the same worksheet/document XML as their plain siblings plus a vbaProject.bin, and the app's own parsers read them: verified with the repo's dependencies (read-excel-file 9.3.10, mammoth), a minimal .xlsm parsed to its sheet and cells ([{"sheet":"Budget","data":[["Revenue",1250]]}]), and a minimal .docm converted to correct <p>Hello from a macro-enabled document.</p>; both ignore the macro part.

What each layer does with that classification:

  • A folder import silently drops them (ui-packages/web/src/core/folder-import.ts:36) and the status lumps them into "Left out N that were hidden, oversized or unreadable" (ui-packages/web/src/features/resources/use-file-library.ts:73) — a financial model indistinguishable from a node_modules entry.
  • Added one by one, they store fine but open as "There is no preview for this format." with no further advice (ui-packages/web/src/features/reader/file-preview.tsx:78-92); the "Save it as .xlsx" guidance exists only for legacy .doc/.xls (ui-packages/web/src/core/files.ts:120-126).
  • The assistant lists an under-5-MiB one as textReadable: true (ui-packages/web/src/features/assistant/document-access.ts:20-29, surfaced at ui-packages/web/src/features/assistant/document-tools.ts:94-100), then open falls through to openTextSource, where decoding the zip bytes fails as "This file is not UTF-8 text. If it is text in another encoding, import a UTF-8 copy." (ui-packages/web/src/features/assistant/text-source.ts:17-20) — nonsense for a workbook, the same false promise Binary files overpromise at every layer — a stored .doc previews as 'usable as context', lists as textReadable, then read fails with encoding advice #162 removed for .doc/.xls.

Proposal

  • Classify .xlsm as xlsx and .docm as docx: match the extensions and the macro-enabled media types (application/vnd.ms-excel.sheet.macroEnabled.12, application/vnd.ms-word.document.macroEnabled.main+xml).
  • Everything downstream follows from the existing kinds: the sheet grid and sheet_info/sheet_read for the workbook, the markdown conversion with its unconverted markers for the document, folder imports keeping them.
  • The macro project (vbaProject.bin) is not read and needs no marker: it is code, not reading content, and neither text view claims to hold it.

Goal

After this, an .xlsm opens in the sheet grid with its tabs and cells and the assistant reads it with the sheet tools like any .xlsx; a .docm opens as the document's markdown with the same unconverted markers as a .docx; a folder import keeps both instead of counting them among the unreadable.

Verification

pnpm --filter @gamma-reader/web test src/core
grep -n 'xlsm' ui-packages/web/src/core/files.ts
pnpm check

Refs

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 27, 2026
  2. bencode commented on Oct 27, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire source:scheduled proposals. Audited against main@dbf9cb6d.

    Evidence audit: every anchor exact — files.ts:112-113 (only docx/xlsx extensions + plain media types; .xlsm/.docm fall to return 'unsupported' at :117), :119-126 legacy set, folder-import.ts:36 drop, use-file-library.ts:73 exact status text, file-preview.tsx:88-90 message, document-access.ts:20-29 readability, text-source.ts:19-21 exact UTF-8 error.

    The load-bearing claim independently reproduced with the repo's own deps: synthetic .xlsm/.docm OOXML packages (macro-enabled content types, vbaProject.bin present) parsed by read-excel-file@9.3.10 → [{"sheet":"Budget","data":[["Revenue",1250]]}] and by mammoth → <p>Hello from a macro-enabled document.</p> — both ignoring the macro part, both matching the issue's reported output verbatim. The premise holds.

    Duplicate check: clean across open + closed; #243/#210 (closed) are same-family precedents, #162 (closed) is the legacy-binary mirror — none cover the macro-enabled formats.

    Sensor: lint ✓; verify ✗ (grep xlsm files.ts fails today — the anchor discriminates).

    Verdict: valid, keep open. Sharpening:

    1. Media-type slip: .docm's registered type is application/vnd.ms-word.document.macroEnabled.12, not ...macroEnabled.main+xml (that resembles the XML part type); the .xlsm one is correct. Worth correcting so media-type matching catches real uploads.
    2. Outcome anchor over the presence grep: a files.ts unit test — previewKindFor('budget.xlsm', 'application/vnd.ms-excel.sheet.macroEnabled.12') → xlsx, and the .docm equivalent → docx — is the regression that actually pins the fix.
    3. Scope note worth stating in the issue: folder-import.ts:36 and getReadability's convertedKinds both key off previewKindFor, so the fix is files.ts alone — keeps the diff honest.
  3. bencode commented on Oct 29, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. Previous review ran against main@dbf9cb6; this beat re-audited against main@d05b6b6 (HEAD unchanged since). git diff dbf9cb6..d05b6b6 over every cited file is empty — the plugins commits (#279, #283) touch none of them.

  4. bencode commented on Nov 1, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit at d05b6b6 — valid, stays open (HEAD unchanged since the last review; this pass adds the gate-health check the 10-31 → 11-01 round gave the other issues).

  5. bencode commented on Nov 6, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Renewal @ 2026-11-07, HEAD still d05b6b6 — valid, stays open. No commits since the 11-01 re-audit; checks re-run, not assumed.

  6. bencode commented on Nov 10, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Renewal @ 2026-11-11, HEAD still d05b6b6 — valid, stays open. Checks re-run rather than assumed.

    • Anchors exact: files.ts:112-117 (docx/xlsx-only checks → 'unsupported'), folder-import.ts:36 (the !== 'unsupported' filter that drops them); xlsm/docm still appear nowhere in files.ts.
    • Sensor: lint ✓; verify ✗ on main ✓ — src/core suite 9 files / 46 tests green (counts identical to prior reviews), failure is the xlsm grep. Correctly red.
    • Duplicates: nothing filed or closed since the 11-07 renewal overlaps the macro-enabled formats. Still clean.
    • Standing sharpening unchanged and unaddressed: pin the outcome with previewKindFor(…xlsm, application/vnd.ms-excel.sheet.macroEnabled.12) → xlsx (and the .docm twin) unit tests — the presence grep alone would green on a comment.
  7. bencode commented on Nov 13, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Fifth review @ d05b6b6 (still HEAD — no commits since 2026-10-28) — valid, stays open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions