Preview fallback for fake docx artifacts and readable Office errors #96

Merged
weichen merged 11 commits from feature/preview-sniff-fallback into main 2026-10-01 05:20:49 +00:00
Owner

Track 2 of the fake-docx remediation (siblings: feature/docx-generation handles the generation-side root cause).

Why

Agent-generated ".docx" artifacts were historically plain-text bytes; the docx preview fed them straight to mammoth/JSZip which threw Can't find end of central directory (reproduced verbatim with JSZip.loadAsync on text bytes).

Changes

  • @ui previewKindOf: .docx stays docx; legacy .doc (binary Word, not OOXML) routes to binary + download fallback instead of a guaranteed JSZip explosion.
  • @ui OfficePreview: user-facing error converges to one actionable line (corrupted / not a valid DOCX / pseudo-Office file); raw error goes to console.
  • frontend docxLoader: sniff ZIP magic (PK\x03\x04 / PK\x05\x06) before mammoth; non-ZIP bytes render as markdown with a readable note — stock fake docx artifacts become readable immediately.
  • parent: .gitignore gains .mimosa/ (Mimosa plugin per-session state kept dirtying the tree and blocking precheck).

Verification

  • make test-ui: tsc --noEmit clean + vitest 49/49 (new: 旧文档.doc → binary, error-note assertion)
  • make test-frontend: vitest 33/33; frontend tsc --noEmit clean
  • task-sync checkpoint: sync_base=d64742c71c tested_head=af13fba (2026-09-30T17:51:59Z)

Impact

Preview-layer only, no contract change. Until the generation-side track merges, newly written .docx remains text but previews readably.

Refs: .task/feature-preview-sniff-fallback.md; merge order: Agent-System-UI / Agent-System-Frontend PRs first, then this parent PR (pins those heads).

Track 2 of the fake-docx remediation (siblings: feature/docx-generation handles the generation-side root cause). ## Why Agent-generated ".docx" artifacts were historically plain-text bytes; the docx preview fed them straight to mammoth/JSZip which threw `Can't find end of central directory` (reproduced verbatim with JSZip.loadAsync on text bytes). ## Changes - @ui `previewKindOf`: `.docx` stays docx; legacy `.doc` (binary Word, not OOXML) routes to binary + download fallback instead of a guaranteed JSZip explosion. - @ui `OfficePreview`: user-facing error converges to one actionable line (corrupted / not a valid DOCX / pseudo-Office file); raw error goes to console. - frontend `docxLoader`: sniff ZIP magic (PK\x03\x04 / PK\x05\x06) before mammoth; non-ZIP bytes render as markdown with a readable note — stock fake docx artifacts become readable immediately. - parent: `.gitignore` gains `.mimosa/` (Mimosa plugin per-session state kept dirtying the tree and blocking precheck). ## Verification - make test-ui: tsc --noEmit clean + vitest 49/49 (new: `旧文档.doc → binary`, error-note assertion) - make test-frontend: vitest 33/33; frontend tsc --noEmit clean - task-sync checkpoint: sync_base=d64742c71c tested_head=af13fba (2026-09-30T17:51:59Z) ## Impact Preview-layer only, no contract change. Until the generation-side track merges, newly written .docx remains text but previews readably. Refs: .task/feature-preview-sniff-fallback.md; merge order: Agent-System-UI / Agent-System-Frontend PRs first, then this parent PR (pins those heads).
weichen added 3 commits 2026-09-30 17:52:46 +00:00
Why: track 2 of the fake-docx remediation — read-only preview fallback for
stock text-masquerading docx artifacts; also ignore the Mimosa plugin's
per-session .mimosa state dir that kept dirtying the tree and blocking precheck.

Evidence: modules/ui 83367f7 (doc->binary dispatch + readable Office error),
modules/frontend cd77340 (PK magic sniff + markdown fallback); make test-ui
49/49, make test-frontend 33/33, frontend tsc --noEmit clean.

Impact: parent pins move to the two submodule branches; .gitignore gains
.mimosa/; no code outside those modules.

Refs: .task/feature-preview-sniff-fallback.md
Record the sync checkpoint
ci / test (pull_request) Failing after 1m37s
af13fbadf8
weichen added 3 commits 2026-09-30 18:11:23 +00:00
weichen added 3 commits 2026-10-01 04:08:36 +00:00
Why: the open preview-sniff PRs were cut before the shell redesign, so
they could not merge. UI and Frontend now contain origin/main plus the
ZIP sniff, including xlsx and pptx text fallback.

Evidence: UI vitest 68 and tsc clean; Frontend vitest 40 and tsc clean.
UI pulls/21 and Frontend pulls/22 updated.

Impact: gitlinks only. Dev still needs to merge origin/main before the
parent PR can land.

Refs: task feature/preview-sniff-fallback
Co-authored-by: Cursor <cursoragent@cursor.com>
Why: the preview sniff branch predated the shell redesign and could not
merge. Module gitlinks now include current main plus ZIP fallback for
docx, xlsx, and pptx.

Evidence: conflict was only the shared sync-log card; both sides' rows
kept. UI and Frontend tests passed on the updated module SHAs.

Impact: parent branch contains origin/main. .mimosa/ ignore stays.

Refs: task feature/preview-sniff-fallback, Dev PR #96
Co-authored-by: Cursor <cursoragent@cursor.com>
Record the preview sniff sync and xlsx fallback
ci / test (pull_request) Failing after 31s
5f9b33ae22
Why: the task card still described xlsx/pptx sniff as out of scope, and
the combo test had not been written down after the merge.

Evidence: make test passed on a11fed4 (frontend 40, ui 68).

Impact: task card only.

Refs: Dev PR #96
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen added 2 commits 2026-10-01 05:20:44 +00:00
weichen merged commit 3072611209 into main 2026-10-01 05:20:49 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Dev#96