Skip to content

Add static pictures inside cells with XLSX roundtrip - #105

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
harrisonoconnorhover:codex/cell-pictures
Oct 10, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
harrisonoconnorhover:codex/cell-pictures

Conversation

@harrisonoconnorhover

@harrisonoconnorhover harrisonoconnorhover commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Pictures can currently only float over a worksheet. This adds Insert → Pictures → Place in Cell for PNG/JPEG files. Pictures fit their current cell rectangles, follow sorting and structural edits, survive internal copy/paste and undo, and render in PDF exports. Existing floating pictures retain Place over Cells.

The review revision stores pictures in a sparse Sheet::cell_pictures map with shared immutable payloads; ordinary Cell layout is unchanged. Content replacement removes the corresponding picture, while copy, cut, fill, sort, row/column edits and undo transport it explicitly. Cut uses the live source if it changes after the cut command.

Optional XLSX picture-data failures now warn and preserve scalar fallbacks instead of preventing the workbook from opening, including oversized metadata, excessive rich records and relationship read errors. XLSX export keeps picture value metadata and dynamic-array metadata independent in the same package. The UI cache preserves more than 128 visible small pictures across frames, with bounded texture memory and admission before decoding under pressure.

Rebased onto main c5bf34d. ODS/XLSB import changes are not merged there yet; Package::read_limited now matches the incoming XLSB implementation so the two features can share it.

Addresses #61 as an initial static-picture implementation. OS clipboard images, conversion between floating/cell pictures, IMAGE() and rich-value formula propagation remain follow-up work. Scalar references and text exports use #VALUE!; please keep the issue open for the remaining scope.

Validation:

  • All 164 model/calc/engine/XLSX/CLI regression tests, the 133-picture cache regression, and both picture UI tests pass. The new optional-metadata and cache regressions fail when their previous behavior is restored.
  • Native compilation, WASM, formatting, assets, dependency layers, parity, model Clippy and diff checks pass.
  • CLI insertion and independent reference-workbook save/reopen preserve original PNG/JPEG bytes and mixed dynamic-array/picture metadata. UI and PDF renders were inspected.
  • Required cargo xtask ci stops at the pre-existing core/src/date.rs:108 Clippy lint. Scoped checks report existing lints in engine/src/cmd/file.rs:51, xlsx/src/sheet_read.rs:146, and the UI formula bar/grid; no lint suppressions were added.
  • Runtime checks ran before the final rebase; the incoming main changes affect only release workflows/Linux packaging, and the tested Rust sources are byte-identical afterward.

Excel runtime and actual native/browser picker interaction are unverified. No external workbook or image asset is committed; tests generate original image data in code.

@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thank you — this is a substantial, well-hardened piece of work (read limits, pixel caps, decode limits, bounded texture cache). Two things before we can merge: (1) richdata failures are fatal: richdata::read errors (>100K records, oversized rdrichvalue.xml, rels errors) propagate with ?, so a workbook that opens today with scalar fallbacks would fail to open at all — these should warn and fall back to Ok(vec![]). (2) Adding picture: Option<Arc<CellPicture>> to every Cell costs memory on every cell and touches every Cell {..} literal; we'd prefer pictures stored in a sheet-level side map keyed by cell (like notes/links) so Cell stays small. It will also need a rebase (ODS/XLSB import are landing and add their own Package::read_limited). Also worth noting: with >128 distinct on-screen pictures the LRU will re-decode every frame.

If you haven't already, please come join us on Discord: https://discord.gg/artcraft — happy to talk any of this through there.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit f75ded3 into storytold:main Oct 10, 2026
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Landed — thank you, Harrison! Both review points are addressed nicely: pictures live in a sheet-level side map, and unreadable rich-data now warns and keeps the scalar fallbacks. I rebased it onto main myself (it conflicted with #83, #98 and main's restructured ROADMAP, where I kept main's version). Two small follow-up ideas if you're interested: the UI texture cache is keyed by Arc pointer, so a freed picture's reused address could briefly show a stale texture; and formula-generated pictures import as static (already warned about).

If you haven't already, please come join us on Discord: https://discord.gg/artcraft

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants