Skip to content

feat(html): mark the formula cells an edit left out of date - #887

Merged
andiwand merged 1 commit into
mainfrom
feat/stale-formulas
Sep 12, 2026
Merged

feat(html): mark the formula cells an edit left out of date#887
andiwand merged 1 commit into
mainfrom
feat/stale-formulas

Conversation

@andiwand

@andiwand andiwand commented Sep 11, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Rebased on main, now that #884, #885 and #886 have landed. One commit.

Step 3.3 of docs/design/spreadsheet-editing.md.

What the markup gains

Per formula cell, in an editable render only:

<td data-odr-lock="formula"
    data-odr-formula="of:=SUM([.A1:.A2])"
    data-odr-reads="2,0,0,0,1">7</td>

data-odr-reads is sheet,first column,last column,first row,last row per
rectangle, space separated, with * for an axis a reference leaves open
(A:A). The renderer parses the cell's formula and resolves each sheet name to
the ordinal an op names it by.

What the page does with it

A commit marks the cells reading what it wrote — and the cells reading those —
with odr-sheet-stale, and raises the new odr.onCellsStale callback
({sheet, cells}). The cell still shows the result its producer cached;
nothing here recomputes one, that is step 4.

The marks follow the log, not the last write. repaintStale recomputes
them off the coalesced log after every commit, undo and redo, so an undo takes
back what it made stale and a save clears them with the log. The host hears
only when the set actually moves.

The style is a wavy underline in --odr-sheet-stale, which layers over the pin
and hover wash instead of fighting them and moves no geometry.

Why the page carries the graph

A mark has to keep up with typing, so a host round trip is the wrong shape
here. The engine's own graph (#886) is what the file side will use in step 3.4.
odr.sheet.formulaAt(column, row) hands a formula bar the expression.

formula::syntax_of(FileType) is now the one mapping from a file type to a
formula syntax; the renderer and SheetDependencies both read it.

Test

  • test/src/html_test.cpp: six cases — the expression, the rectangles, a
    reference into another sheet resolving to its ordinal, the attribute
    escaping, a read-only render carrying neither, and a formula reading nothing
    stating no rectangle.
  • test/browser/sheet/editing.html: 61 checks now (was 51), headless-green
    together with the other four sheet pages. The fixture gained a second formula
    cell reading the first, so the chain is checked.
  • The wasm example wires onCellsStale, as the host-wiring reference.

Reference output: this changes the emitted html for every sheet holding a
formula, so compare-html stays red until the output repos get their commit
and the pins advance.

https://claude.ai/code/session_01VVmjmddv2Ui17Nptc1ggue

@andiwand
andiwand force-pushed the feat/sheet-dependencies branch from de13e68 to 8f6aaa9 Compare September 11, 2026 22:15
@andiwand
andiwand force-pushed the feat/stale-formulas branch 2 times, most recently from 0eeb6b3 to f8b6951 Compare September 12, 2026 06:50
@andiwand
andiwand force-pushed the feat/sheet-dependencies branch 2 times, most recently from 08dc7d0 to d9144fd Compare September 12, 2026 07:27
@andiwand
andiwand force-pushed the feat/stale-formulas branch 2 times, most recently from 4d42c3b to eadb004 Compare September 12, 2026 07:31
@andiwand
andiwand force-pushed the feat/sheet-dependencies branch from d9144fd to 84a500e Compare September 12, 2026 07:31
@andiwand
andiwand force-pushed the feat/sheet-dependencies branch 2 times, most recently from bb51ea6 to 79cedf7 Compare September 12, 2026 07:51
@andiwand
andiwand force-pushed the feat/sheet-dependencies branch from 79cedf7 to be80cc7 Compare September 12, 2026 08:41
Base automatically changed from feat/sheet-dependencies to main September 12, 2026 15:07
A sheet view states, per formula cell, the expression it computes
(`data-odr-formula`) and the rectangles it reads (`data-odr-reads`: sheet,
columns, rows, with `*` for an axis a reference leaves open). Both are editing
scaffolding, so a read-only render carries neither.

A commit marks the cells reading what it wrote, and the cells reading those,
with `odr-sheet-stale`, and raises `odr.onCellsStale`. The marks follow the
log, not the last write: `repaintStale` recomputes them after every commit,
undo and redo, and the host hears only when the set moves. Nothing here
recomputes a value; that is step 4.

The page carries the graph rather than asking the host for it, because a mark
has to keep up with typing. `odr.sheet.formulaAt` hands a formula bar the
expression, and `formula::syntax_of` is now the one mapping from a file type
to a formula syntax.

Step 3.3 of `docs/design/spreadsheet-editing.md`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVmjmddv2Ui17Nptc1ggue
@andiwand
andiwand merged commit 73f4020 into main Sep 12, 2026
32 checks passed
@andiwand
andiwand deleted the feat/stale-formulas branch September 12, 2026 15:42
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.

1 participant