Skip to content

Sheets: leaving the formula bar sends only the edit the person made, and a tap on another cell keeps the tap - #6

Merged
jamescalam merged 9 commits into
mainfrom
sheets-225
Nov 15, 2026
Merged

jamescalam merged 9 commits into
mainfrom
sheets-225

Conversation

@jamescalam

Copy link
Copy Markdown
Contributor

After Enter in a date column, the selection moves down and the formula bar shows the next cell's date as it was typed (2026-10-13). The bar's change handler compared that text with the cell's serial (String(inp.value)), so the next tap or click anywhere sent the next cell as an edit nobody made. Others then saw it marked "Edited by", it overrode the agent's later changes to that cell, and it counted toward the 32 KB a person can keep.

Leaving the bar by tapping another cell also lost the tap. The save redrew the grid between press and release, so the tapped cell was never selected.

What changed

  • barText(tab, a) gives the text the bar shows for a cell (a date as typed). renderBar and the change handler both use it, so leaving the bar sends nothing unless its text was changed.
  • A typed change is saved just after the tap or click that left the bar, in the cell and tab it was typed in. A mouse leaves the bar on press, so the save waits for pointerup. A finger leaves it after lifting, so the save goes in a setTimeout(0) after the click. write() now takes the tab name and can keep the selection where the person moved it.
  • A test that no two of a script's top-level functions share a name. The first version of this change named its helper send(), which silently replaced the calc's own send() and broke working the sheet out. The page threw on load. The test fails on that version.

Testing

In Chromium, on a saved job tracker, before (#5's head) → after:

Case Edits sent Selected after
Date, Enter, click another cell 2 (C3 and a phantom C4) → 1 C4 → B6 (the one clicked)
Number / text / formula, Enter, click 1 → 1 B6 → B6
Date or text, tap another cell, no Enter 1 → 1 the typed cell → B6 (the one tapped)
Date, Enter, tap C5 2 → 1 C4 → C5
Text, Esc 0 → 0 A3 → A3
Text, tap the Summary tab, no Enter 1 → 1 (Applications!A3) — → Summary

No page errors after. node tests/run.js: 81 passed (Node 22 and 26). npx spacesheep skills lint: well-formed, hash 36168641a830.

Worth a close look

  • The edit is now sent a tick later than before when the bar is left by a click. Anything that reads state.mine between the blur and that tick sees the old value.

jamescalam and others added 9 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>
…rs' row, and a drop-down's text stops short of its arrow

On a phone the chip sat on the column letters' row, which never scrolls
away, so it hid the letter of the last column in view for good. It now
sits at the grid box's bottom-right. A sheet wider than its box gets 38
px of room under its last row (class "wide", which doesn't change while
scrolling across, so nothing jumps), so scrolling down always clears
whatever the chip covers.

A drop-down drew the browser's own arrow over the end of its text
("Proposal sent" ran into it in a 130 px column). It now draws its own
arrow in the theme's grey, and keeps 22 px clear for it; longer text
ends in "…" before the arrow.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
The row-number column was 40 px with 8 px of padding a side, so any
three-digit number with wide digits (200, 888) and every four-digit one
ended in "…". A tab can draw up to 10,000 rows. The column is now 40 px
up to row 999 and 8 px wider for each digit after (the page sets --rn
from the rows it draws), with 6 px padding and even-width digits. The
first column's sticky edge follows it.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
At the grid's bottom-right it no longer hid a column letter, but it hid
a cell's words. It now sits at the right end of the tabs row: above the
grid, on the first screen, covering nothing. When the tabs leave no room
beside it, it takes a line of its own below them (class "below", set
when the tabs would scroll with the chip beside them). It shows while
the sheet is wider than its box, and hides once scrolled to the last
column, keeping its room so nothing moves. The 38 px under the last row
goes.

Co-authored-by: Pointman <noreply@pointman.ai>
Co-authored-by: Claude <noreply@anthropic.com>
…and a tap on another cell keeps the tap

After Enter in a date column, the selection moved down and the bar
showed the next cell's date as typed (2026-10-13). Its change handler
compared the bar with the cell's serial, so the next tap or click
anywhere sent that cell as an edit nobody made: marked "Edited by" for
others, overriding the agent's later changes to it, and counted toward
the 32 KB a person can keep.

- barText() gives the text the bar shows for a cell; the bar and the
  change handler both use it.
- Leaving the bar with a typed change still saves it, in the cell and
  tab it was typed in, but just after the tap or click that left it
  (a mouse leaves on press, so it waits for the release; a finger
  leaves after lifting, with the click). Before, the save redrew the
  grid between press and release, so the tapped cell was never
  selected. write() takes the tab and can keep the selection.
- A test that no two of a script's top-level functions share a name:
  the first version of this named its helper send(), which replaced
  the calc's own send() and broke working the sheet out.

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-207 to main November 15, 2026 04:35
@jamescalam
jamescalam merged commit 81e5e7a 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