Skip to content

feat(files): preview Word documents and Excel workbooks - #19114

Closed
piotrnowakowski wants to merge 5 commits into
pingdotgg:mainfrom
piotrnowakowski:feat/office-file-previews
Closed

piotrnowakowski wants to merge 5 commits into
pingdotgg:mainfrom
piotrnowakowski:feat/office-file-previews

Conversation

@piotrnowakowski

@piotrnowakowski piotrnowakowski commented Oct 13, 2026 •

Copy link
Copy Markdown

Read-only Word (.docx) and Excel (.xlsx) previews are available from Files, chat file links, and attachments beside the conversation.

Preview behavior

  • Word displays document pages, text, tables, images, headers, and footers through a lazy-loaded renderer. Sanitized output runs in a sandboxed frame.
  • Excel offers visible-sheet selection and 100-row pages within a preview window of up to 500 rows and 50 columns. It preserves absolute cell coordinates, including sparse C9000 content and implicit rows, number/date formats, Unicode, rich text, cached formula results, and formula-expression fallback.
  • File refresh reloads the document. Workspace-change checks compare file identity, size, and timestamps so unchanged content retains its selected worksheet and page.
  • Directories with Office-like extensions open in the file tree. Original files can be saved through signed asset URLs and streaming downloads.
  • Mobile workspace links and attachments use the native viewer and Save/share fallback. Office renderer dependencies are confined to web.

Resource management

  • Preview input is capped at 10 MiB and expanded archive content at 64 MiB. Validation checks ZIP headers, offsets, descriptors, effective Unicode filenames, duplicate paths, and actual decompressed sizes before rendering.
  • Word XML, element, media, and decoded-image budgets apply to the parts selected by document relationships, including nonstandard part names.
  • Excel retains the compressed archive and parses the selected worksheet into a bounded cell slice with its required strings and styles. Archive validation still checks every entry. Cells are limited to 2,000 characters, aggregate cell text to 1 MiB of UTF-16 content, and serialized output to 2 MiB.
  • Only the requested page crosses from the worker to the UI. Page changes reuse the selected-sheet window. Rapid sheet changes are coalesced, obsolete work is cancelled, and stale responses are ignored.
  • Validation transfers buffers without an additional copy and uses adaptive decompression chunks up to 4 KiB, with smaller chunks near the remaining size budget. Stalled workers terminate after 15 seconds; closing a preview releases its workers and rendered content.
  • Office file-type checks use metadata without loading binary contents into the text cache. The license generator includes the renderer dependencies and SAX parser notices.

Verification

  • 231 tests pass across 17 focused files, covering parsing, archive and payload limits, Unicode filenames, sparse coordinates, pagination, selected-sheet isolation, permissions, refresh, signing/downloads, cancellation, watchdogs, cleanup, and native fallback lifecycle.
  • Scoped web typecheck, targeted formatting/lint, diff checks, and production web build pass. One existing breadcrumb effect-dependency lint warning remains.
  • The running production web app displays a two-page Word document with its table, image, headers/footers, and Unicode text. Excel checks cover C9000 pages through row 9249, selected-sheet behavior, content limits, and malformed-file fallbacks. Office-looking folders display the tree without a Save action or Office worker.
  • Closing previews leaves zero Office workers, iframes, and table cells.
  • Three browser trials on a 250,000-cell workbook measured median CPU time of 2.33 seconds and retained main-page heap of 38.59 MiB. The sampled main-renderer working set was 365.02 MiB. CPU includes browser overhead; heap is measured after diagnostic garbage collection and excludes workers. Working-set samples include caches/shared pages and are not peak-memory measurements.

Scope and limits

This draft provides read-only previews. Document editing, Excel charts and workbook styling, and formula recalculation are outside its scope. Documents exceeding preview budgets offer the original file for opening in another app.

Large worksheet XML and shared-string parts require bounded scans. Word DOM work runs on the main thread, with complexity limits and cancellation between rendering phases.

Runtime verification covers the local production web build. Native lifecycle tests pass, but live Android verification is blocked by Windows native dependency/build issues. Native-device behavior, Electron-specific downloads/performance, and relay/tunnel modes are unverified.

Evidence

Word beside chat Sparse Excel pagination
Word preview C9000 pagination

Pagination and sheet-selection recording · Chat preview recording

Model: GPT-6.1-Sol. Harness: Codex desktop.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Oct 13, 2026
Office preview validation trusted ZIP metadata, repeated workspace updates reparsed unchanged files, and closing Word previews left queued rendering work. Validate actual archive expansion in a cancellable worker, bound and cancel Word phases, refresh by file identity, stream remote saves, and route mobile workspace Office files to the native viewer fallback.

Keep spreadsheet payload and full-workbook parsing changes deferred for separate approval. Focused validation passed 167 tests across 12 files, scoped checks, and a production web build; browser fixtures and resource measurements are recorded in the PR evidence.

Model: GPT-6.1-Sol. Harness: Codex desktop.
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Oct 13, 2026
Excel previews retained every worksheet and could transfer 50 million characters into 25,000 table cells. Read workbook metadata first, inflate only the selected worksheet and required strings/styles, and bound the cell slice before SheetJS materializes it. Preserve sparse C9000 coordinates and formatting, cap retained/serialized text, and send 100-row pages from one selected-sheet cache.

Coalesce obsolete sheet requests, terminate stalled workers, and guard formatting amplification. Focused validation passed 185 tests across 14 files and scoped checks; production-app pagination, source coordinates, switching, cleanup, and resource samples are recorded in the PR evidence.

Model: GPT-6.1-Sol. Harness: Codex desktop.
@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Thanks for proposing Word and Excel previews. This exceeds our current 500-changed-line intake limit for unvouched contributors, with new renderers, archive workers, dependencies, and mobile viewer support across 44 files. As Read this first explains, review capacity is limited, and right now we are only taking focused bug fixes from outside contributors. Please bring the proposal to an Ideas discussion and agree on a smaller approved scope before requesting reconsideration.

@maria-rcks maria-rcks closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants