Skip to content

Sheets: a value its format can't show is shown as it is, and can't stop the grid drawing or lose the edit - #4

Merged
jamescalam merged 5 commits into
mainfrom
sheets-219
Nov 15, 2026
Merged

jamescalam merged 5 commits into
mainfrom
sheets-219

Conversation

@jamescalam

@jamescalam jamescalam commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Typing 1000000000 into a date or month cell built a Date past what JS holds. Intl threw "Invalid time value", the grid stopped drawing (the cell's row was gone), the edit was never sent, and the status line still said "No error cells". A month cell that a chart labels with did the same.

What changed

  • E.show(v, fmt, data) gives a value's text and never throws. When the format can't take the value, it gives the value as it is with bad: true. That covers a date past the dates a Date holds, and a currency code Intl refuses. It calls the exported fmtValue, so a test can make the formatter throw.
  • fmtValue says plainly "not a date" for such a serial, rather than leaving it to Intl, whose refusal varies by engine.
  • The page shows values only through show(), and draws each grid cell and each chart under its own try. Anything a cell can't draw shows its value as it is, marked, and the rest of the grid goes on. A chart that can't be drawn says so in its place.
  • Status: such a cell is marked with the error style and starts at the cell's left, as typed text does. The status line names it in plain words: "⚠ C3 isn't a date, so it shows what you typed." For a month column it says "isn't a month", and for several cells "aren't dates". Where the value isn't the person's own edit, it says "its value as it is". Warnings (this one, formula errors, a chart that can't be drawn) are red on a line of their own. "Edits save for everyone…" stays grey. Before, the whole line turned red.
  • The edit is sent before the page draws it, so what was typed is kept even if something on the page can't show it.
  • CSV gives the number, not NaN-aN-aN. "What changed in this version" and chart labels show it too. In .xlsx the number keeps its date format, which Excel shows as ####.

Testing

  • tests/hostile.js, 2 new tests. In one, 1e9, −1e9 and 1e300 as date and month all come out as the value, marked. A real date still formats, and so does the far end of the range (1e8). A bad currency code is marked. CSV, .xlsx, what-changed and chart labels don't throw. In the other, with fmtValue replaced by one that throws, show() still gives every kind of value's text. The page script has no E.fmtValue( call, each cell and chart is drawn under a guard, and an edit is sent before it's drawn.
  • node tests/run.js: 79 passed (Node 22 and 26). npx spacesheep skills lint: well-formed, hash 4fb7dceb9204.
  • In Chromium, on two saved sheets: 1000000000 typed into Applications!C3 (date) and Forecast!A3 (month, chart labels). Before: two page errors, grid gone, nothing sent. After: no page errors. The cell shows 1000000000, marked, and every row draws. The edit is sent, the chart draws, both downloads work, and the status line names the cell.

Worth a close look

  • The cell guard wraps the existing cell body; on a throw it draws a fresh plain td, with the same click handler, rather than reusing a half-built one.
  • The status line is now a red .warn span (formula errors, then cells that can't be shown, then charts) followed by the usual grey text, built with DOM nodes rather than one textContent.

jamescalam and others added 5 commits November 15, 2026 11:35
… reads a cell

=SUMPRODUCT(A1:T10000, ...) with 16 ranges of 200,000 cells read each
range before SUMPRODUCT ran. The budget charged each read, so it ended
in #CALC! only at the 16th range, after 3 million cell reads: about
2 s on a laptop, and over 3 s on CI's runners, where the hostile test
timed out. A person's sheet with such a formula froze for as long.

Now, before a formula is worked out, the engine adds up the cells of
every range it is sure to read (all of them, except the parts of IF,
IFERROR, IFNA and IFS past the first, which may never be worked out).
Each of those reads would be charged its cells anyway, so a total past
the budget ends in #CALC! at once, with no cell read. A highlight's test
gets the same check. refRange's span moves into refSpan, which both use.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
…ay 12 px on a phone

The chart was a 760-unit drawing scaled to its box, so at 390 px its text
drew at about 6 px and the month labels ran together; at 1280 it scaled
up and "May 2026" touched "Jun 2026".

Now the drawing is as wide as its box (at most 860 px) and is drawn
again when that width changes. Its axes come from the engine's new
chartAxes, which the tests call:
- value steps are round (£0, £500, £1,000, £1,500), not quarters of the
  biggest bar;
- month labels drop the year when the title names their one year;
- labels sit in a row while they fit; months and dates then thin to every
  2nd, 3rd... one, and names are cut to 12 characters and angled, thinned
  only when even angled ones can't all fit;
- one series has no key when the title names it.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
…on folds to two lines, and one Download button

At 390 px the title, six lines of description, two rows of buttons and
the status came before the grid, which started at 438-460 px. Now, at
phone width only:

- The description shows two lines. "more" at the end of the second line,
  or a tap on the description, opens the rest; "less" folds it again.
  "more" shows only when there is more: checked after each draw, on
  resize, and when a push changes the description.
- "Download CSV (this tab)" and "Download .xlsx (all tabs)" sit under
  one Download button, as "CSV (this tab)" and ".xlsx (all tabs)". It
  opens from the keyboard onto the first choice; Esc, a choice, or a tap
  outside closes it.

The grid now starts at 321 px on both test sheets, with 10 rows whole on
an 844 px screen (was 7-8). Every control stays at least 44 px. Wider
screens draw the header exactly as before.

The open states are a class and attributes the page never writes, so a
save that morphs the page in place keeps them when it has the page
before, and closes both cleanly when it doesn't.

Also: Enter on a focused button now presses it. The grid's key handler
took Enter to the formula bar from anywhere but a field, so Enter on
"Show formulas" (or Download) did nothing.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
…op the grid drawing or lose the edit

Typing 1000000000 into a date or month cell made the formatter build a
Date past what JS holds; Intl threw "Invalid time value", the grid
stopped drawing (the cell's row was gone), the edit was never sent,
and the status line still said "No error cells".

- The engine's new show(v, fmt, data) gives a value's text and never
  throws: when the format can't take the value (a date past the dates
  a Date holds, a currency code Intl refuses), it gives the value as it
  is, marked bad. fmtValue says plainly "not a date" for such a serial,
  rather than leaving it to Intl.
- The page shows values only through it. Each grid cell is drawn under
  its own guard, and each chart too: anything a cell can't draw shows
  its value as it is, marked, and the rest goes on.
- Such a cell is marked as an error, and the status line names it:
  "C3 can't be shown in its format, so it shows the value as it is."
- An edit is sent before the page draws it, so what was typed is kept
  even if something on the page can't show it.
- CSV gives the number, not "NaN-aN-aN"; "What changed in this version"
  and chart labels show it too. In .xlsx it keeps its date format, which
  Excel shows as ####.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
… person's words; the usual sentence stays grey

"⚠ C3 isn't a date, so it shows what you typed." ("isn't a month" for a
month column; "aren't dates" for several; "its value as it is" where the
value isn't the person's own edit; a format other than date or month
says "can't be shown in its column's format".) Formula errors and charts
that can't be drawn go on the same red line. "Edits save for everyone…"
and the other notes stay in the status line's grey, as when nothing is
wrong. Before, the whole line turned red.

A value shown as it is starts at the cell's left, as typed text does,
rather than right-aligned as a number.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
@jamescalam jamescalam mentioned this pull request Nov 15, 2026
@jamescalam
jamescalam changed the base branch from sheets-206 to main November 15, 2026 04:35
@jamescalam
jamescalam merged commit 87c5585 into main Nov 15, 2026
1 check passed
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