Skip to content

The README links to the grid's cookbook - #97

Merged
matthewjones372 merged 15 commits into
mainfrom
claude/stoic-pascal-v0q6pz
Nov 16, 2026
Merged

matthewjones372 merged 15 commits into
mainfrom
claude/stoic-pascal-v0q6pz

Conversation

@matthewjones372

Copy link
Copy Markdown
Collaborator

The README now points to the grid's cookbook, which is live on surefold.dev:

  • "Live tables in the browser" (What you can build): adds that the cookbook shows the grid in an app.
  • "Browser" (getting started): says what the cookbook has (rows from an API, loading as you scroll, saving edits back, WebSocket and SSE streams, charts and a table in a worker) and links it in Solid and React.

This changes only the README. Both cookbook URLs return 200.


Generated by Claude Code

The grid pages gain a cookbook (grid/cookbook/ and grid/react/cookbook/):
four recipes, each running on the page with its source under it. The
source shown is the recipe's own file, imported with ?raw, so what is read
is what runs, and npm run check type-checks it.

- A first grid: a table, a grid, a total outside it, edits from code.
- Rows from an API: fetch DummyJSON's products and putMany them, with
  loading and error states, fetching again, and aborting on unmount.
- Load pages as you scroll: loadMore over a paged API, starting the next
  page at table.size, so a page asked for twice is harmless, and retrying
  a page that failed.
- Charts from the table: GroupChart, and a chart of your own drawn from
  groups(), both following edits.

Both pages share the words (web/grid/src/cookbook/text.ts) and styles.
The grid pages and the three package READMEs link to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Bun reads the same .npmrc, so the setup shows bun add beside npm install,
and the bunfig.toml scope for projects that keep their settings there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
"A large table in a worker", in Solid and React: start a WorkerTable,
load 300,000 rows into it in blocks with putMany while the page stays
free, and move a thousand prices in one batch, with the total and the
last recalculation's cost shown as they come. It disposes the worker when
the component goes, including while the worker is still starting.

The notes say which reads answer at once from the snapshot and which ask
the worker, that a write's promise resolves before the totals it changes
arrive, and what Vite needs for the worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Two recipes, in Solid and React, that write a stream to the table the
same way: gather messages as they come, and write them once a frame
inside batch, so a burst costs one recalculation and one redraw.

- Prices over a WebSocket: Coinbase's public ticker sets the price of a
  few coins, keeping only each coin's latest price between frames; each
  row is added with its first price, and the price column draws its trend.
- Events over SSE: Wikimedia's stream of recent changes, through
  EventSource, puts a row an edit and drops the oldest in the same batch,
  keeping the latest 2,000, grouped by wiki.

Each connects when asked and closes its connection when the component goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
"Edit and save back to an API", in Solid and React. The table keeps what
the server last had; after each recalculation that changed an input, the
rows are compared with it, so whatever a person did in the grid (typing,
pasting, filling a block, undoing) shows as unsaved changes, and undoing
back to the saved value makes a row clean again. Save sends one PATCH a
changed row with only its changed fields; a row that fails stays unsaved
to retry, and only what was sent is marked saved. Discard puts the saved
values back in one batch. Recent requests are listed under the grid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Prism highlights each recipe's source (TSX) and the setup's snippets
(.npmrc, bash, bunfig.toml, TypeScript), with token colours for the light
and dark page in cookbook.css. Both pages share web/grid/src/cookbook/highlight.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
drawGrid (and the Solid and React <Grid>) take onEdit, called with
{ cause, cells, removed } whenever a person changes the grid: each cell's
key, column, and value before and after, for typing, pasting, filling a
block, undoing and doing again, and the keys of rows they delete. Changes
made from code (put, set, drop) are not reported, so an app can save
exactly what people did.

The engine notes the cells that set_cell, undo and redo change between
record_edits and take_edits (Grid::record_edits, Grid::take_edits). The
view runs each of a person's edits between the two; with a WorkerTable
the three go as one message (RemoteEngine.sequence), so nothing else is
set in between and the same edits are reported as with a Table. Pasting
goes the same way, and RemoteEngine.setCells, which it replaces, is gone.

The cookbook's edit-and-save recipe now uses onEdit instead of comparing
every row after each recalculation, so it costs only what was edited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
@surefold/grid, grid-solid and grid-react at 0.4.0, for the tag that
publishes them: the grid's onEdit says what a person edited (cells with
their values before and after, and deleted rows), and RemoteEngine.setCells
gives way to RemoteEngine.sequence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Each cookbook page's header (its one h1, the intro and the Solid/React
switch) is now in the page's HTML rather than drawn by its script, which
renders the recipes under it. So the heading shows before the script runs,
and the page passes surefold.dev's site checker, which reads the HTML for
one h1, a title, a language and a description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Prism nests the JavaScript in a JSX attribute ({…}) inside the tag's token,
so names there that have no colour of their own (orders in onClick, title
and decimals in keyColumn) took the tag's red. They now take the code's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
Its code background is --code-bg, the name surefold.dev's watershed theme
sets, so on the site code blocks have the site's code colour rather than
the cookbook's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
"Live tables in the browser" says the cookbook shows the grid in an app,
and the Browser part of getting started says what it has and links it in
Solid and React.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdzBXcxXfE7iKtPMVoTTfr
@matthewjones372
matthewjones372 merged commit b6b7054 into main Nov 16, 2026
9 checks passed
@matthewjones372
matthewjones372 deleted the claude/stoic-pascal-v0q6pz branch November 16, 2026 12:11
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.

2 participants