demo-concepts-1
cursed-spreadsheet
Work with CSV and Excel files in the browser — a virtualized grid, a formula engine, a boolean query builder, and a SQLite-backed server, in one MIT package with two runtime dependencies.
Use it three ways:
| A standalone app | bunx cursed-spreadsheet — a local workbench at localhost:3000 |
| A server you embed | import { createSpreadsheetServer } from "cursed-spreadsheet" |
| A React component | import { DataGrid } from "cursed-spreadsheet/ui" |
Install
bun add cursed-spreadsheet
Node 22.5+ works too, and the CLI sorts its own runtime out; see Running under Node.
Run the whole thing
import { startSpreadsheetServer } from "cursed-spreadsheet";
const server = await startSpreadsheetServer();
console.log(server.url); // http://127.0.0.1:3000
That opens (and creates) a SQLite database, runs migrations, serves the JSON API, and serves the compiled workbench UI. Nothing else to configure.
To stop it cleanly:
await server.stop();
server.close();
From the command line
bunx cursed-spreadsheet # serve on :3000
bunx cursed-spreadsheet --port 8080 --open # and open a browser
bunx cursed-spreadsheet import data/*.csv # import, then exit
bunx cursed-spreadsheet export "Q3 ledger" ./q3.xlsx
bunx cursed-spreadsheet seed 4000 # a demo dataset
bunx cursed-spreadsheet info # print the resolved config
--help lists everything.
Configuration
As the standalone app, everything is configured in the app itself — the gear icon opens a Settings page covering ports, paths, limits, security and logging. There is nothing to remember and no file to hand-edit.
Settings are saved to config.json in the data folder, which is the same
directory on every machine:
~/.cursed-data-excel/
config.json what the Settings page writes
data.db your workbooks
media/ image originals
Copy that one folder to move your library to another Mac, or to back it up.
CURSED_SPREADSHEET_HOME (or --home) relocates it.
Running it every day
cursed-spreadsheet service install # start at login, restart if it stops
cursed-spreadsheet service status # is it running, and on what address
cursed-spreadsheet service uninstall # stop it; your data folder is untouched
A launchd agent, so the app is a bookmark rather than a terminal window you have
to remember to open. macOS only; elsewhere run serve under your own supervisor.
Every server setting takes effect on restart, and the Settings page has a button that performs one — including when you change the port, which it will follow.
Images
Pictures live alongside your workbooks in the same library — their own records,
not attachments on a spreadsheet. They use the same folders and the same tags,
so a folder called "Q3" holds the ledger and the photographs of what it
describes, and a receipts tag means the same thing to both.
There is no Sheets/Images switch any more — the sidebar is one folder tree holding everything, and clicking a picture opens the gallery on it. Drag files anywhere onto the pane to add them, click a tile to view it full size, and step through with the arrow keys. Rename, move and tag from the viewer.
- Formats are read from the file, never from its name — PNG, JPEG, GIF, WebP, BMP, AVIF and SVG, plus film and sound. A renamed text file claiming to be a PNG is never filed as a picture.
- This pane takes whatever the file list takes. Drop a
.zip, a font or anything else nothing can read and it is kept whole, exactly as it arrived, with a viewer that says what it is and a Download that hands it back. Drop prose — Markdown, a.txt, a web page, a Word document — and it becomes a note you can go on editing, not an opaque blob; the pane says which file became which note and opens it for you. A spreadsheet is the one thing sent elsewhere, because it has a screen of its own. Whatever is not taken is named rather than dropped quietly. - The same picture twice is kept once. Images are deduplicated by content hash, which is the check importing a spreadsheet twice does not have.
- Originals stay as files under
media/in the data folder, so backing up that one directory backs up the pictures too.
Deleting is reversible: an image goes to the trash and its file stays on disk until it is deleted permanently.
Notes
Not everything worth keeping beside a spreadsheet is a spreadsheet. A note is its own kind of file in the same library — the same folders, the same drag, the same trash — and it comes in four types, chosen when you make it:
| what it is | what it exports as | |
|---|---|---|
| Note | plain text, nothing to format | .txt .md .html |
| Markdown note | markdown, with a live preview beside the source | .md .html .txt |
| Rich text note | formatted text, with a toolbar | .html .md .txt |
| Drawing | free-form ink from a mouse, trackpad or pen | .svg .html |
A plain note also remembers a language, which is what an imported source
file arrives with and what the picker in the status bar can correct — a .txt
full of SQL is a plain note until you say otherwise, and then it highlights.
A drawing is stored as its strokes, not as an image: eight inks, four nibs,
an eraser and an undo, and what comes out is an SVG that stays sharp at any
size. It is deliberately data rather than the SVG itself — see the header of
src/core/notes/drawing.ts — because rendering a stored SVG would mean
sanitising the one document type that is hardest to sanitise. Nothing a body
contains reaches the page: the document is written out of numbers that have been
range-checked, and a colour is matched against /^#[0-9a-f]{6}$/ exactly.
The sidebar's + is where all four are made — along with a workbook and a
folder — and whatever it makes lands in the folder that is selected, or at
the top level when none is. The new row arrives already in a rename with its
name selected, so it is named by typing rather than by answering a dialog;
Escape keeps the default name. The same in-place field is what Rename on any
row's … menu opens.
- Autosaved, on the same debounce and the same optimistic-concurrency check as a sheet: two tabs open on one note get a conflict rather than one silently overwriting the other.
- Sanitised on the way in and on the way out. A note is the only content
here that can execute, so a paste from Word or a browser is cleaned as it
lands, cleaned again before it is stored, and cleaned once more before it is
drawn. There is no
<script>, noon*handler and nojavascript:URL that survives any of the three. Formatting does survive — a Word paste keeps its bold, its alignment and its tables. - Exported as what they claim to be. A rich text note asked for as
.mdis converted to real markdown, not handed out as HTML with the wrong extension;.htmlis a whole styled document rather than a bare fragment. Each kind names the formats it can be, and the route refuses the rest — a drawing asked for as.txtwould be an empty file with a name on it. - Deleting is reversible, into the same trash as everything else.
No new dependencies: markdown, the HTML sanitiser and the rich text surface are
all in src/core/notes/ and src/ui/notes/, which is why they also run on the
server for the export route.
Pictures on a sheet
Images also live on sheets, floating above the cells the way they do in Excel — a logo over the totals, a screenshot beside the figures it explains. A workbook imported with pictures in it keeps them, anchored to the same cells, at the same size.
| To | Do |
|---|---|
| Add one | Picture in the toolbar, or drop an image file onto the grid, or paste one |
| Select it | Click it. Click the sheet to deselect |
| Move it | Drag it. Hold Alt to snap to the cell grid |
| Nudge it | Arrow keys, or Shift + arrows for a coarser step |
| Resize it | Drag any of the eight grips. Hold Shift on a corner to keep the proportions |
| Copy, cut, paste | ⌘/Ctrl + C, X, V — within a sheet, across sheets, and out to other apps |
| Restack or remove | Front, Back, Reset size and delete, in the toolbar while one is selected |
A few things follow from a picture being a drawing, not a cell value:
- It is anchored to a cell, not owned by a row. Sorting, filtering or searching leaves it exactly where it was — which is what makes "the logo above the totals" mean something. Widening a column to its left moves it along, as it does on the desktop.
- Delete deletes the picture, not the cells under it. A selected picture owns the keyboard while it is selected.
- The bytes are one library image. The same picture placed on twelve sheets is twelve placements and one file on disk, and deleting it from a sheet leaves it in your library.
- Exports keep them. An XLSX export writes the pictures back into the workbook, so a round trip through Excel loses nothing.
Embedding, and the environment
Used as a library the app has no data home, and the environment is the way in.
Every variable is optional; .env.example documents the full
list. Bun loads .env automatically, and Node needs --env-file=.env.
SPREADSHEET_PORT=3000
SPREADSHEET_HOST=127.0.0.1
SPREADSHEET_AUTH_TOKEN= # unset = open; set = bearer token required
SPREADSHEET_CORS_ORIGIN= # comma-separated; unset = same-origin only
SPREADSHEET_MAX_UPLOAD_MB=128
SPREADSHEET_SERVE_UI=true
Four layers, each beating the one before: built-in defaults, the environment,
the settings saved from the Settings page, and finally explicit options. Saved
settings sit above the environment on purpose — a value you can see in the
form must not be silently overridden by a stray .env. Explicit options still
win over everything, so a --port flag remains a real one-off override; the
Settings page shows any field a flag has pinned rather than accepting an edit
that would not apply.
Anything passed to createSpreadsheetServer() overrides the rest:
const server = await createSpreadsheetServer({
port: 8080,
dbPath: "./data/work.db",
authToken: process.env.MY_SECRET,
});
Bad values fail at startup, with a message that names the variable — and in the Settings page, beside the field that carries it:
Configuration problem
SPREADSHEET_PORT: expected a number, got "eighty".
Authentication
Open by default and bound to 127.0.0.1, which is right for a local tool. Set
SPREADSHEET_AUTH_TOKEN and every /api request needs
Authorization: Bearer <token>; /api/v1/health stays reachable so a load
balancer can still probe it.
For SSO or an existing session, supply your own check:
await createSpreadsheetServer({
authenticate: async (request) => {
const user = await mySession(request);
return user ? { userId: user.id } : false;
},
});
Returning { userId } also scopes per-user settings, so two people keep their
own column widths and filters.
Embed the server in an app you already have
createSpreadsheetServer returns a standard Fetch handler, so it mounts
anywhere:
const spreadsheet = await createSpreadsheetServer({ serveUi: false });
// Bun
export default { port: 8080, fetch: spreadsheet.fetch };
// Hono
app.route("/sheets", spreadsheet.app);
server.repository is the data layer, for seeding and scripts:
const { files } = server.repository.listFiles();
for (const row of server.repository.streamRows(files[0].id)) {
console.log(row.values);
}
Embed the UI
Two components, depending on how much you want.
The whole application
import { Workbench } from "cursed-spreadsheet/ui";
import "cursed-spreadsheet/ui/styles.css";
<div style={{ height: "100vh" }}>
<Workbench baseUrl="/api/v1" />
</div>;
Just the grid
DataGrid is backend-agnostic. It takes data and emits edits, and knows nothing
about this package's server:
import { DataGrid, type ColumnDef, type SheetRow } from "cursed-spreadsheet/ui";
import "cursed-spreadsheet/ui/styles.css";
const columns: ColumnDef[] = [
{ id: "c1", name: "product", type: "text", position: 0 },
{ id: "c2", name: "revenue", type: "number", position: 1,
format: { kind: "currency", currency: "USD", decimals: 2 } },
];
<div className="cs-root" style={{ height: 600 }}>
<DataGrid
columns={columns}
rows={rows}
totalRows={250_000}
windowOffset={offset}
pinnedRows={band} // the frozen heading rows, by view index
onRequestRange={(start, end) => loadRowsFromMyBackend(start, end)}
onEdit={(edits) => saveToMyBackend(edits)}
/>
</div>;
onEdit receives a batch, so a paste of 400 cells is one call, not 400.
pinnedRows matters the moment frozenRows and a window are used together. A
frozen row is drawn wherever the sheet has scrolled to, so row 0 is on screen
while rows starts at 620 — and rows[-620] is nothing, which draws the
heading as a blank placeholder. Hand it RowPage.band (below) and the grid
falls back to it for any index the window cannot reach. The window always wins
where it reaches, so an edit to the heading is never masked by an older copy of
it. Omit it when rows is the whole sheet.
Panes, the header row, text overflow and the marching-ants outline are props, because the grid holds no opinion about where any of them are stored:
<DataGrid
columns={columns}
rows={rows}
frozenRows={1} // rows kept on screen while the sheet scrolls
frozenColumns={1} // and columns, from the left
headerRow={1} // one-based; drawn as a heading. null for none
overflowText // long text runs into empty cells. On by default
marquee={marquee} // { rect, cut } — the dashed outline after a copy
onClipboard={setMarquee}
onContextMenu={(target, at) => openMyMenu(target, at)}
actionsRef={actions} // { copy, paste, clear, focus } for that menu
/>;
onContextMenu reports what was clicked — cells, column, row or sheet —
rather than deciding the menu, since only the application above knows what it is
willing to offer.
Theming
The stylesheet is hand-authored and every selector is namespaced under
.cs-root. There is no Tailwind, no preflight, and no global reset — dropping
this into your app cannot change a pixel of it.
Theming is entirely CSS custom properties:
.cs-root {
--cs-accent: #7c3aed;
--cs-radius: 4px;
--cs-font: "Inter", system-ui, sans-serif;
--cs-row-height: 28px;
}
Set data-theme="dark" for the dark palette, or leave it and the workbench
follows the system. data-density="compact" | "comfortable" adjusts metrics
without touching the type scale.
Use the codecs on their own
cursed-spreadsheet/core runs unchanged in a browser, in Bun and in Node — no
bun:*, no node:*, no DOM. It is the same code the server uses, so parsing on
the client and on upload cannot disagree.
import { parseCsvSheet, readXlsx, writeXlsx, evaluateExpression } from "cursed-spreadsheet/core";
const { sheets } = parseCsvSheet(csvText);
// columns, types and blank cells are worked out from the contents
const bytes = writeXlsx([{ name: "Report", columns, rows, styles }]);
// a real .xlsx with fonts, fills, borders and number formats
const total = evaluateExpression("=SUM([amount]:[amount]) * 1.2", { columns, rows });
What it does
Import
Drop a file anywhere on the window, or use the import dialog, which previews the first rows and the types it inferred before committing anything.
- CSV / TSV / DSV — delimiter sniffed from the payload, BOM handled, quoted fields with embedded newlines, and streaming so a 2 GB file never becomes one JavaScript string.
- XLSX — shared and inline strings, every cell type, shared and array formulas, theme and indexed colours, frozen panes, column widths, and number-format-driven date detection.
- Pictures come with the workbook. Drawings are read out of the archive and placed on the same cells at the same size, whether the file anchored them to two cells, to one, or to the canvas. Anything that is not a picture — a chart, a text box — is skipped rather than half-imported as an empty frame.
- Every sheet of a workbook is offered, not just the first: the dialog lists each tab with its size, previews any of them on the spot, and imports the ones you tick. Sheets the workbook marks hidden are listed but left unticked.
- Column types are inferred from a sample: number, text, boolean, date, datetime, time, JSON — with the format kept separate, so currency and percent are number columns wearing a format.
- A legacy
.xls, an.odsor a binary file is named and refused, not imported as garbage.
Sheets and workbooks
A file holds one sheet — that is what keeps a 500k-row sheet cheap to page — so
a five-tab workbook imports as five files sharing a workbookId. They are not
scattered: the workbench shows them as tabs under the grid, in the
workbook's own tab order, and groups them under one heading in the file list.
A sheet is never outside a workbook. A dropped report.csv is a one-tab
workbook called report.csv, and so is a file created through the API — which
is what gives every sheet in the app a strip, a + that adds a second tab, and
a workbook name that can be renamed. The rule is held in three places rather
than described in one: createFile does not compile without a workbook, a
database trigger refuses a null workbook_id from any writer at all, and a
migration put the files written before the rule into workbooks of their own.
Import the same file twice and the second is numbered — Budget.xlsx and
Budget.xlsx 2 — so the sidebar says which one arrived first.
- Click a tab, or step between them with ⌘⌥←/→ (
Ctrl+Alt+←/→elsewhere). - Drag a tab sideways to reorder it, with an insertion marker between the
tabs and auto-scroll at either end so a thirty-tab strip is reachable. Adding
Shift to the step chord — ⌘⌥⇧←/→ — moves the open sheet one place
instead, and the
…menu names the same move in words for touch. - The strip scrolls when the tabs outgrow it, and the
n/mbutton opens the full list — a thirty-tab workbook stays navigable. - Each sheet keeps its own filter, sort and column widths, because each is a file in its own right.
A workbook does not have to be imported. The + in the sidebar starts a blank
one, and everything after that is the desktop's own vocabulary:
| Do this | To |
|---|---|
+ in the sidebar |
start a blank workbook, open on an empty sheet, name selected |
+ at the end of the tab strip |
add a sheet |
| double-click a tab, or F2 | rename that sheet |
| double-click the workbook name | rename the workbook |
| drag a tab, or ⌘⌥⇧←/→ | move that sheet along the strip |
| … at the end of the strip | move this sheet left or right, delete it, or delete the whole workbook |
A new workbook arrives with its name already open and selected, the way a
new folder does on a desktop: type to name it, or press Escape to keep the
Workbook 3 it was given. Nobody has to know that double-clicking the name is
the way to rename it in order to get a name they chose.
The blank sheet arrives with no columns and no rows at all — what you see is the grid's lettered margin (see Room to grow), and the first thing you type is what creates the column and row to hold it. Nothing is stored until it is filled in.
Renaming is held to Excel's rules, because every sheet here is one export away
from being an .xlsx: sheet names may not contain [ ] : * ? / \, stop at 31
characters, and no two sheets of one workbook may share one. A name that breaks
a rule is refused with the reason rather than quietly rewritten. A workbook's
name lives on its sheets — it is the sourceName every member carries — so
renaming one is a single write across the group.
const { workbook, sheet } = await client.createWorkbook({ name: "Quarterly" });
await client.addSheet(workbook.id, { name: "Q3" });
await client.renameSheet(sheet.id, "Summary");
await client.renameWorkbook(workbook.id, "Year end");
const { workbookId, files } = await client.importSheets(file, { sheets: "all" });
const tabs = await client.listWorkbookSheets(workbookId); // in tab order
// The tab order, as the whole left-to-right list — a retry lands the same order.
await client.reorderSheets(workbookId, [tabs[2].id, tabs[0].id, tabs[1].id]);
// Into another workbook at a given tab; `null` gives the sheet one of its own.
await client.moveSheetToWorkbook(tabs[0].id, otherWorkbookId, 0);
In the workbench, tabs drag sideways with an insertion marker and auto-scroll at
the ends, and Ctrl/⌘+Alt+Shift+←/→ moves the open sheet one place without a
pointer — the same move the tab menu names in words, so touch has it too.
The trash
Every delete here is a soft one, and now there is a screen behind that promise. Trash is pinned under the folder tree in the sidebar, with a count beside it, and it holds everything that has been deleted — workbooks, single sheets and pictures — newest first.
- A deleted workbook is one row, not seven files called
Sheet 1…Sheet 7. Restoring it uses the workbook route, so the tab order comes back with it; expanding the row restores or erases one sheet at a time. - Restoring one sheet of a deleted workbook brings the workbook back holding
that tab. The
workbookIdnever left the row, so it goes back where it was. - Delete permanently and Empty the trash ask first, in a dialog that
names what goes. Nothing in this app uses a native
confirm(). - Items are removed 90 days after they are deleted —
trashDaysin Configuration, and 0 makes every delete immediate. The sweep runs at server start and once a day, so the promise is kept by something that fires on its own rather than by an endpoint somebody has to remember. A purged picture takes its file on disk with it.
The NULL rule
An empty cell is null, never "". Empty strings would silently poison SUM
and AVG in SQLite and make IS NULL filters lie. On the way out, null
becomes a bare empty field (a,,b) — never the literal text NULL.
Formulas
170 functions across maths, statistics, text, logic, dates, lookup, information
and finance — written in-house and MIT-licensed, including REGEXMATCH,
REGEXEXTRACT, REGEXREPLACE and SPLIT, which Excel lacks and anyone
cleaning a CSV reaches for immediately.
Reference a column by name, which is what makes a column formula readable:
=[amount] * 1.2 this row's amount
=IF([status] = "Paid", 0, [amount])
=REGEXEXTRACT([reference], "INV-(\d+)")
=SUM([amount]:[amount]) the whole column
=COUNTIF([status]:[status], "Paid")
[name] is this row; [name]:[name] is the whole column. The first is what
a computed column wants; the second is what an aggregate wants. SUM([amount])
sums one value and returns it, which is correct but rarely what was meant.
A1 references work too (=A1+B1, =SUM(A:A)), where row 1 is the first
data row — headers are a separate band, not row 1. Errors are values that
propagate, so =IFERROR(A1/B1, 0) catches a division three levels down, and
IF is lazy so =IF(B1=0, 0, A1/B1) never computes the division it guards.
Formulas run when the sheet changes, as part of the same save. Type
=[amount] * 1.2 into a cell and the answer is there; change the cell it reads
and the answer moves. There are two passes and they share one order: whole
columns first, in dependency order, then the formulas typed into individual
cells, ordered cell by cell — so =SUM(B1:B4) in B5 reads the four computed
cells above it rather than what they held before the pass began. A circular
reference resolves to #REF! rather than hanging.
The cost is kept off an ordinary edit. A sheet with no formulas is one indexed
lookup and stops; a sheet whose formulas each answer from their own row loads
only the rows carrying one, whatever its length. Past 20,000 rows a formula that
reads the whole sheet is no longer evaluated between keystrokes — the app says
so rather than going quietly stale, and Recalculate formulas in the ⌄ menu
runs the full pass on demand. That command is also how =TODAY() moves on a
sheet nobody has edited.
Filtering
Stack conditions into AND / OR groups, nested as deeply as you like:
{ "operator": "OR", "conditions": [
{ "operator": "AND", "rules": [
{ "field": "manager", "operator": "equals", "value": "Alice" },
{ "field": "amount", "operator": "gt", "value": 1000 } ] } ] }
19 operators, a * wildcard field that searches every column, per-rule case
sensitivity, and disable-without-delete.
The same tree runs two ways: in memory on the client, and compiled to SQL on the server. They must agree, because you filter a window and then export the whole result — so the test suite runs every tree through both and compares.
Find
Filtering narrows a sheet to the rows holding a word. Find is the other thing, and the two are named apart on the toolbar because they answer different questions: a find changes nothing on screen — it says where the text is, and walks you to each occurrence.
⌘F (Ctrl+F) opens it. One box, and one dial for how far it reaches:
| Scope | Looks in |
|---|---|
| Sheet | the sheet in front of you |
| Workbook | every tab of the open workbook |
| All | every workbook and every sheet there is |
- Enter / Shift+Enter, the ↑ ↓ arrows, or ⌘G / ⌘⇧G step to
the next and previous match. Stepping wraps, so nothing is unreachable from
wherever you happen to be, and the bar reads
3 of 128. - Aa matches case; = requires the whole cell to be the query rather than merely to contain it.
- While a find is on, the file list becomes the answer: only the workbooks holding the text, and inside each only the sheets that do, with a count on every row and the matching cells listed under them. Click one to go straight to it; the list and the arrows walk one order, so the ninth row and nine presses of Next land in the same place.
A match is found in the stored sheet and reported as a row index in file
order. The grid is showing whatever the sort and the filter left, so the jump
translates: with neither on, the two numbers are the same and nothing is asked;
with either, POST /files/:id/locate says where that row actually sits. If the
sheet's own filter is hiding the row, the find says so and offers to clear it,
rather than scrolling somewhere plausible and wrong.
Hidden columns are not searched — a jump has to land somewhere you can see.
Values are matched as stored, not as formatted: a currency column holding 1234
and showing £1,234.00 is found by 1234. A formula cell is matched on the
value it produced, not on its source text — searching SUM finds the word in a
cell that holds it, not every cell that adds something up.
const found = await client.searchCells({ query: "London", scope: "all" });
found.workbooks[0].sheets[0].cells; // { rowId, rowIndex, columnId, text, ... }
// Where that row is on screen, under this sheet's sort and filter.
const at = await client.locateRow(fileId, rowId, { sort, filter });
Editing
Everything a spreadsheet should do: range selection by drag or keyboard, copy and paste as TSV (round-tripping with Excel and Sheets) with the marching-ants outline while a range is held, column resize with double-click-to-fit, sort, freeze panes, and formatting.
The fill handle follows Excel's rules rather than repeating cells. Formulas
are translated onto their new address — relative references shift, anything
anchored with $ does not, so =B2*$F$1 filled down becomes =B3*$F$1 — and
values are read for a pattern: numbers extrapolate by least squares, dates step
by day, month or month-end, Mon runs to Tue and Dec wraps to Jan,
Item 1 counts to Item 2 and A09 to A10 with its padding intact. A lone
number is copied; Ctrl (Option on a Mac) inverts that
choice both ways. Formatting travels with the fill, double-clicking the handle
fills down to meet the column beside it, and dragging the handle back into the
block empties what it crossed.
Nothing has a save button. Edits coalesce — five keystrokes in one cell send one write — and are serialised, so two writes cannot race. A failure keeps the work and retries with backoff; a conflict is surfaced rather than retried, since retrying would overwrite whoever else wrote.
Undo and redo
Ctrl+Z steps back through the last hundred changes and Ctrl+Shift+Z (or
Ctrl+Y) forward again, over cell contents, formulas, formatting, freeze panes
and inserted or deleted rows. The ⌄ menu names what each one will reverse —
Undo formatting, Undo typing — so a chord pressed three times is not a guess.
It is a journal of inverse operations, not a stack of snapshots: every change here is already an operation on its way to the server, so undo is that protocol pointed backwards, and no copy of a 500k-row sheet is ever held. Undo is itself an ordinary edit — it saves, it reloads correctly, and it recomputes whatever formulas depended on what it put back.
Where an inverse cannot be built honestly the history is dropped rather than faked. Deleting a whole column is the case: putting it back means restoring cells from rows this browser has never loaded. The menu item then says there is nothing to undo, which is true, instead of offering an undo that would restore half a column.
Inside an open cell Ctrl+Z belongs to the text being typed, as it does in any
text box — taking it there would discard a half-finished entry.
Formatting
Bold, italic, underline, text colour, cell colour and alignment sit on the one
toolbar line, with the format painter beside them — each with its Excel chord,
so Ctrl+B, Ctrl+I and Ctrl+U do what the fingers pressing them expect.
They apply to whatever is selected — a block of cells, whole rows, or whole
columns.
The distinction matters more than it looks. A block of cells is written per cell; a whole column becomes the column's default, which is the only shape that can cover a 500k-row sheet the browser has paged eight hundred rows of. The same rule makes clearing a column's contents or its formatting one server operation instead of half a million writes.
The format painter picks up the formatting under the cursor and hands it to the next thing you click — a cell, a range you drag, a row number, or a heading, which formats the entire column. Escape puts it down. Picking it up from a plain cell is how you take formatting off something else.
A cell with a fill and no colour of its own gets black or white text, whichever its fill can carry. A fill is stored on the sheet and the theme is not, so a pale yellow chosen in the light theme is still pale yellow in the dark one.
Selecting
Click a heading to select the column, a row number to select the row, and the corner box above the row numbers to select the sheet. Sorting lives on its own control at the right of each heading — the arrow is its state, so one unmodified click selects and one sorts, and neither gesture is hidden behind a modifier. The status bar counts what is selected and, separately, how much of it holds anything.
Ctrl-click — or a right-click — opens the menu for whatever is under the pointer: cut, copy, paste and clear everywhere, plus insert and delete on a row or a column, and freeze, hide and sort on a heading. Cutting or copying a column and then choosing Insert copied column here on another moves the column and its entire contents, however many rows that is.
Text that runs past its column
A long entry spills across the empty cells to its right and stops dead at the first that holds something, exactly as it does in Excel — which is why a heading typed into a narrow column stays readable without anybody widening it. The direction follows the alignment: left-aligned text spills right, right-aligned spills left, centred spills both ways, and nothing crosses a frozen-pane seam.
The toolbar toggle turns it off, and then every entry is clipped to its own borders. On is the default, and the choice is saved with the sheet.
The header row, and frozen panes
Row 1 holds the headings in most sheets, so that is the default for a sheet you start from nothing. A sheet imported from a CSV or a workbook has none, because its headings were already lifted into the column names above the grid. Either way the row is set from ⧉ Header row and frozen panes on the toolbar, or from a row's own menu.
The header row is drawn as a heading, and it is exempt from the sort and the filter — server-side, so it stays at the top of every page of a sorted result rather than being filed under A along with the data. Freezing it keeps it and everything above it on screen while the sheet scrolls under it. Columns freeze the same way, from the left; no column is chosen to begin with.
Frozen panes live on the file itself, so they survive an export to .xlsx and
come back from one.
The keyboard is Excel's
Nobody learns a spreadsheet's shortcuts twice, so the grid answers the chords fingers already know. Enter commits and moves down; Tab moves right and Shift+Tab back. Tab across a row and press Enter and the cursor returns to the column the row was started in, which is what makes record-at-a-time entry work.
Enter / Shift+Enter |
down a cell, or up |
Tab / Shift+Tab |
right a cell, or left |
Ctrl+↑ ↓ ← → |
to the edge of the sheet |
Page Up / Page Down |
one screen up or down; with Alt, left or right |
Home / End |
first or last column of the row |
Ctrl+Home / Ctrl+End |
the first cell, or the last one holding anything |
Shift+Space / Ctrl+Space |
whole rows, whole columns |
Ctrl+A |
the whole sheet |
Ctrl+B / Ctrl+I / Ctrl+U |
bold, italic, underline |
Ctrl+Z |
undo |
Ctrl+Shift+Z / Ctrl+Y |
redo |
Ctrl+C / Ctrl+X |
copy, cut — the range keeps a dashed outline until Escape |
Ctrl+click |
the menu for the cell, row, column or sheet under the pointer |
F2 |
edit the cell as it stands, rather than typing over it |
Ctrl+Enter |
fill the whole selection with what you typed |
Ctrl+D / Ctrl+R |
fill down, fill right — formulas translated onto their new rows |
Ctrl+; / Ctrl+Shift+; |
today's date, the time now — stamped, not a formula |
Alt+= |
AutoSum the run of numbers above or to the left |
F4 |
cycle $ on the reference you are typing |
Ctrl+F |
find text — this sheet, this workbook, or every one |
Ctrl+G / Ctrl+Shift+G |
the next match, and the previous one |
Ctrl+Shift+F |
filter the rows to the ones holding a word |
Ctrl+S |
save now, without waiting for the autosave |
Ctrl+/ |
the same list, in the app |
⌘ stands in for Ctrl on a Mac, and the in-app list says so. Two behaviours are
deliberately not Excel's, both for the same reason — the grid holds a window
of the sheet rather than all of it. Ctrl+↑ ↓ ← → goes to the sheet's edge
rather than to the next populated cell, and an arrow key inside a half-written
formula is left to the caret instead of entering point mode.
Excel has two editing modes and so does this. Typing over a cell leaves the
arrow keys steering the sheet, so a column of numbers can be entered without
reaching for Enter; opening a cell with F2 or a double click gives the arrows
to the caret. F2 swaps between them.
Room to grow
A sheet you can only type into where data already exists is a sheet you cannot start, so the grid shows a margin of blank rows and columns past the data — 100 rows and 26 columns by default. A file with 10 columns offers 36; fill column 11 and it offers 37. Typing into the margin is how you add a row or a column.
Nothing is stored for the blank ones. The spare columns are headed by their
spreadsheet letter (D, E, F) and recessed, so the sheet's real extent
still reads at a glance; the moment a cell is filled, the column and every row
above it are created in the same write that carries the value.
The default lives in Settings → Appearance, and any sheet can override it
from Rows and columns — the Grid 104 × 29 button in the status bar, or the
same entry in the ⌄ menu. Spare rows stand down while a filter or a search is
on, since a row appended to the file need not be part of what you are looking
at; spare columns are unaffected.
Embedding DataGrid directly? The margin is not built in — pass whatever extra
rows and columns you want as ordinary entries in rows and columns, and tell
the grid how many of the trailing ones are blank room:
import { extraColumnDefs, extraRowStubs, materializeExtras } from "cursed-spreadsheet/ui";
<DataGrid
columns={[...columns, ...extraColumnDefs(columns.length, 26)]}
rows={[...rows, ...extraRowStubs(100)]}
totalRows={total + 100}
extraRows={100}
extraColumns={26}
onEdit={(edits) => {
// Turns edits that landed in the margin into the rows and columns they
// need, plus the same edits re-pointed at them.
const plan = materializeExtras(edits, { columns, visibleColumns: columns.length, rowCount: total });
saveToMyBackend(plan);
}}
/>;
Export
CSV, TSV, XLSX, JSON and NDJSON, streamed — a 500k-row download never becomes a 500k-row array first. Exports honour the filter and sort you have on screen, so what you download matches what you saw.
XLSX exports carry real formatting: fonts, fills, borders, alignment and number formats. Freely-licensed SheetJS cannot write styles; this codec can.
They carry the pictures too, written as oneCellAnchor drawings with an
explicit extent. That is deliberate rather than a shortcut: a two-cell anchor
makes the reading application re-derive the size from whatever its rows and
columns measure, which is exactly how an exported picture comes back stretched.
Pinning the extent means it is the size the user made it, here and in Excel
alike.
Downloaded CSVs neutralise formula injection by default — a cell starting =,
+, @ or a tab is prefixed, because the recipient's spreadsheet would
otherwise execute it.
Scale
Rows live in their own indexed table, filtered, sorted and paginated in SQLite rather than shipped to the client. Row positions are fractional, so inserting mid-sheet is one write rather than renumbering everything below it.
Measured on an M-series Mac at 200,000 rows — four times the design target:
| Import an 8.7 MB CSV | 0.96 s |
| First page of 200 rows | 6 ms |
| A page at offset 100,000 | 7 ms |
| Filter + sort + count over all 200k | 247 ms |
| Free-text search across every column | 346 ms |
| Edit one cell (the autosave path) | 9 ms |
| Stream the whole sheet to CSV | 1.1 s |
| Export the whole sheet to XLSX | 2.5 s |
| Database on disk | 27.4 MB, 3.1× the CSV |
Rows are keyed on an integer surrogate rather than the file's public UUID. The UUID is 36 bytes and would otherwise be repeated on every row across two indexes — at 200k rows that alone was 22.6 MB, 45% of the database. The public id is unchanged; the integer never leaves the storage layer.
WITHOUT ROWID was measured for the rows table and rejected: it saved a further
1.7 MB but took deep pagination from 7 ms to 54 ms and CSV export from 1.1 s to
5.6 s, because every ordered scan becomes a b-tree search rather than a seek.
Build it yourself
bun install
bun run build # every artifact
bun run verify # typecheck, then build, then 655 tests
One target at a time, with --only=:
bun run build --only=core # the isomorphic layer, ESM + CJS
bun run build --only=ui # the React plugin, ESM + CJS + styles.css
bun run build --only=app # the browser workbench, minified and hashed
bun run build --only=server # the server, for Bun and Node
bun run build --only=types # .d.ts for every entry
bun run build --only=binary # a single self-contained executable
Anything a target embeds is built with it: the server bundle, the CLI bundle and
the binary all compile in the UI, so asking for one of those also rebuilds the
app and the generated assets module rather than shipping whatever was there
before. Add --no-minify for readable output, or --watch to rebuild on change.
Developing
bun run app # use it while it is being worked on (recommended)
bun run dev # rebuild on every keystroke
bun run app is the one to use when somebody — you, or an agent — is editing
the code while you are using the app. See
Knowing which version you are on below;
bun run dev restarts on every save, which is right when you are the one
typing and wrong when you are not.
The workbench is rebuilt into .dev/app on every change to src/ and served
from there, so a UI edit is a browser refresh; the server restarts itself when
its own source changes. bun run dev --port 8080 and every other flag reaches
the server.
.dev/app, not dist/app: the dev build is unminified and fires on every
write under src/, including the src/generated/assets.ts that a production
build writes. When the two shared a directory, leaving bun run dev open in
another terminal silently rebuilt dist/app in the middle of bun run verify
— after the UI had been compiled into the server, the CLI and the binary, and
before anything checked it. The build now refuses to finish if the compiled-in
UI and dist/app have parted company, whatever the cause.
Knowing which version you are on
The most expensive bug in this repository was never in the app. Source is edited, the fix lands, and the running server keeps serving the code it was started with while the open tab keeps running the bundle it downloaded. Nothing fails and nothing logs, so the screen still shows the bug — and it gets reported again. One ⌘Z-after-paste report was chased through nine variations against a build that had already fixed it.
So the app now says which code it is made of, permanently, in the corner of the status bar:
| ● Current | the server and this tab are both running the newest code |
| ● Editing / Checking / Building | files changed; it is being taken live |
| ● Update ready · Reload | the workbench was rebuilt — this tab is behind |
| ● Restart needed · Restart | code on disk is newer than the running server |
| ● Build failing · Why | the new code does not compile, so you are still on the last good build |
Click the pill for the panel behind it: what changed, which build is running, which commit, and Copy for a report — one button that puts the version and build id on the clipboard, so a bug report says which code it was written against.
Restarting when the work is finished, not while it is going on
bun run app # in this terminal, Ctrl-C to stop
bun run app:start # in the background
bun run app:stop # stop the background app
bun run app:restart # force a restart onto the code on disk right now
bun run app:status # what is running, and whether it is current
bun run app:logs # what it has been doing (-f to follow)
bun run app watches the checkout and decides when new code deserves to go
live:
- A commit landed — the repository's own statement that a unit of work is finished. It restarts about four seconds later.
- Uncommitted edits — somebody is mid-task, so it waits for ninety seconds
of complete silence across
src/before touching anything.--quiet <seconds>changes that. - It does not typecheck — it does not restart at all. The last good build
keeps running and the status bar turns red with the compiler's own words in
it, because "you are not on the newest code" is exactly the thing that must
never be silent. Add
--testto requirebun testas well.
A workbench-only change never restarts anything: the app is rebuilt into
.dev/app, which the server is already serving, and the open tab reloads
itself. Only a change under src/server, src/cli or src/core replaces the
process.
The tab reloads itself only when there is nothing queued to save, and only after five seconds of not being touched, with a three-second countdown in the pill that any keystroke cancels. Restart automatically when work is finished in the panel turns the whole thing off; the pill then just goes red and waits for you to press Restart.
Everything above is also true without the supervisor — bun run start still
shows a red dot the moment the code on disk moves ahead of it. What it cannot
do is fix it, so the panel shows the command that starts one instead of a
button that does nothing.
The supervisor writes to .agent.noindex/ in the checkout: app.log, plus a
state file the status bar reads. Nothing there is tracked, and the app's own
data is untouched — this is entirely about which code is running.
The standalone binary
bun run build --only=binary
./dist/bin/cursed-spreadsheet --port 8080
Roughly 61 MB, because it embeds the Bun runtime, and it carries its own compiled UI — copy that one file to a machine with nothing installed and it runs. It is deliberately not in the npm tarball, which is 2.2 MB.
Running under Node
The server picks its SQLite binding at runtime: bun:sqlite under Bun,
node:sqlite under Node 22.5+. No native module, nothing to compile.
The CLI goes one step further, because its bin carries
#!/usr/bin/env node — the one interpreter npm and npx can rely on. That
hashbang is also what bunx and bun install -g honour, so on a Bun-only
machine bunx cursed-spreadsheet still starts under whatever node happens to
be on PATH. If that Node cannot load node:sqlite, the CLI re-executes
itself into one that can: the same Node with --experimental-sqlite, or the
bun it finds via BUN_INSTALL, ~/.bun/bin or PATH. You do not need to
remember bunx --bun, and nothing is left to configure.
As a library there is no process to replace, so the host has to start with
a binding available — bun, or node --experimental-sqlite on Node 22.x.
node --env-file=.env your-server.mjs
To have Node listen on a port you also need the optional peer:
npm install @hono/node-server
That is only for binding a socket. Mounting server.fetch inside a server you
already have needs nothing extra.
The API
Base path /api/v1.
GET /health |
status, driver, counts |
GET /files |
list, with folderId, tag, q, workbookId, limit, offset |
POST /files |
create — in a workbook of its own, named after the file |
GET /files/:id |
metadata, columns and styles — no rows |
POST /files/:id/query |
a page of rows, filtered and sorted |
POST /files/:id/locate |
where one row sits in a view — the other half of a find |
GET /search |
find text across one sheet, one workbook or every one |
POST /files/:id/ops |
the save path — incremental operations |
PATCH /files/:id |
whole-file replace (compatibility; O(file) per save) |
PATCH /files/:id/workbook |
move a sheet into another workbook — or, with null, into one of its own |
POST /files/:id/recalculate |
recompute every formula on demand — ops already does it per save |
POST /files/import |
multipart or raw-body upload; sheets takes a whole workbook |
POST /files/preview |
parse without committing — every sheet, with a sample of each |
GET /files/:id/export |
?format=csv|tsv|xlsx|json|ndjson |
POST /files/:id/duplicate |
Save As |
PUT /files/:id/metadata |
rename, re-file, re-tag; sheetName renames the tab |
POST /workbooks |
start a blank workbook with one empty sheet |
GET /workbooks/:id |
the workbook and its sheets, in tab order |
POST /workbooks/:id/sheets |
add a sheet at the end of the strip |
PATCH /workbooks/:id |
rename the workbook |
PATCH /workbooks/:id/order |
the tab order, as the complete list of sheet ids |
DELETE /workbooks/:id |
move every sheet to the trash — ?permanent=true erases |
POST /workbooks/:id/restore |
bring the whole workbook back |
GET /files/:id/images |
the pictures on a sheet |
POST /files/:id/images |
place one — JSON with a mediaId, or a multipart upload |
PATCH /files/:id/images/:imageId |
move, resize, rename, restack |
DELETE /files/:id/images/:imageId |
take it off the sheet |
GET /notes |
every note, without bodies — folderId, q, format |
POST /notes |
make one — format is plain, markdown, rich or drawing |
GET /notes/:id |
one note, body included |
PATCH /notes/:id |
rename, re-file, set a plain note's language, or write the body against a baseRevision |
GET /notes/:id/export |
?format=md|txt|html|svg — each kind names which it accepts |
DELETE /notes/:id |
to the trash — ?permanent=true erases |
POST /notes/:id/restore |
bring it back |
GET /notes/trash |
what is in the trash |
GET/PUT /settings/:scope[/:id] |
autosaved preferences |
Folders, tags, views and templates have the usual CRUD.
A picture is a placement: { mediaId, col, row, offsetX, offsetY, width, height, z }, where the offsets and the size are CSS pixels and the anchor is a
cell — Excel's own model, and one flat 9525 away from the EMUs the file format
stores. POST accepts either a mediaId for an image already in the library or
a multipart file, which stores and places it in one round trip; the bytes are
deduplicated by hash either way. Omit width and height and the picture is
sized from its own pixels, scaled down so a large photograph does not arrive
covering the sheet.
A picture placed on a sheet is embedded: it is in no folder, no gallery and
no list, so its bytes go when its last placement does. Add to library on the
selection bar — POST /media/:id/promote, optionally with a folderId — files
it instead, and from then on it is an ordinary library picture that survives
losing the placement it came from. Promoting one that is already filed is a
no-op that answers { promoted: false }, because the button cannot tell the two
apart any better than the route can.
A workbook has no table of its own: it is the files sharing one
workbookId, named by the sourceName each of them carries. POST /workbooks
and POST /workbooks/:id/sheets both answer with { workbook, sheet } — the
whole workbook in tab order, plus the sheet just created — and PATCH /workbooks/:id writes one name across every member in a single transaction,
bumping each sheet's revision as it goes. Sheet names are cleaned to what Excel
accepts and refused when nothing usable is left; a duplicate within one workbook
is a 400, as it is on the desktop.
Tab order is sheet_index, and PATCH /workbooks/:id/order is what changes it.
It takes { sheetIds } — the complete left-to-right order, never "move this
one to index 3": a whole permutation is idempotent, so a retried drag lands the
same order instead of moving the tab twice, and a partial, foreign or duplicated
list is a 400 that names the id at fault. PATCH /files/:id/workbook takes
{ workbookId, index? } and answers { workbook, from, sheet } — both strips
as they now stand, since a move changes two of them. workbookId: null does
not make a sheet loose: it gives it a new workbook of its own, because a sheet
is never outside one — and on a sheet that is already alone it does nothing at
all rather than minting a second workbook around it. Moving the last sheet into
another workbook is allowed and takes the old workbook with it: a workbook is
the id its sheets carry, so one nothing carries has not been emptied, it has
stopped being a name. A sheet name the destination already uses is numbered
rather than rejected. Neither route bumps a revision — where a sheet sits is not
what is in it, and bumping it would fail the baseRevision check on the next
save of the sheet just moved.
POST /files/:id/duplicate puts a sheet's copy in its workbook, immediately
to the right of its source, shifting the rest along in the same transaction.
Every file has a workbook, so every copy lands on a strip.
DELETE /workbooks/:id trashes every sheet in one transaction and answers
{ sheets: n }; POST /workbooks/:id/restore brings them all back with their
names and tab order intact. DELETE /files/:id is the single-sheet delete, and
it refuses the last sheet of a workbook with a 400 — a workbook must keep
one sheet, as it must on the desktop, and the message says to trash the workbook
instead. Since every file is a sheet of a workbook, that includes a plain
one-sheet file: DELETE /workbooks/:id is what trashes one of those, which is
also what the workbench's single menu item does for it. ?permanent=true is exempt: that is the trash-purge path, and a guard
there would make a trashed workbook impossible to empty.
GET /search takes q, a scope of sheet / workbook / all, the fileId
or workbookId that scope needs, and optional matchCase and wholeCell. It
answers with only what matched — workbooks holding the text, each holding only
the sheets that hold it — every cell carrying its rowId, its index in file
order, its column, and the text shortened around the match. Caps are stated
rather than silent: truncated is set when one bit. POST /files/:id/locate
takes a rowId plus the same filter and sort a query would, and answers
{ index } — or { index: null }, meaning the row is there and this view is
hiding it.
POST /files/import answers with the created file, which arrives in a workbook
of its own named after the upload. Send a sheets field —
"all", or a JSON array of sheet names or zero-based indices — and it imports a
whole workbook instead, answering with { workbookId, files }: one file per
sheet, in tab order, every one carrying that workbookId. Fetch them back with
GET /files?workbookId=….
Saving
Saving is explicit. ⌘S, or the save button on the document's own toolbar, is what writes — and a tab whose document owes the server something wears a dot where its × normally sits, exactly as VS Code does. Turn Settings ▸ Saving to Autosave and everything writes itself about half a second after you stop typing, which is what this application did before the switch existed.
Nothing about how work is written differs between the two. The queue, the coalescing of repeated edits, the serialising of writes and the conflict rule below are identical; the only thing the setting changes is whether a timer drains the queue or you do. Closing a tab that still owes something asks first.
The UI streams operations rather than re-posting the sheet — editing one cell of a 500k-row file writes one row:
await fetch(`/api/v1/files/${id}/ops`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
baseRevision: 42,
ops: [{ op: "setCells", rowId: "r17", values: { c3: 1200.5 } }],
}),
});
baseRevision is optimistic concurrency: a mismatch returns 409 rather than
silently overwriting another tab's edit. Every mutation bumps the revision
inside its own transaction, so this cannot be bypassed by adding a route.
The same file open in two panes is not two writers: the workbench keeps one live document per file and an editor is a view onto it, so both halves render from the same text and one queue writes it. A change in either shows in the other as you type, with no save and no reload in between, and each tab draws a small chain to say the two are linked.
insertRows and insertColumn honour an id you supply, so a batch can create
a row or column and write to it — which is one round-trip earlier than waiting
for createdRowIds. Reusing an id already in the file is a 400, never an
overwrite. For both, an omitted anchor (afterRowId / afterColumnId) appends
to the end and an explicit null puts the new rows or column first; the two are
deliberately different.
Two operations act on a whole column, because a browser cannot:
copyColumn |
{ fromColumnId, toColumnId, what? } — copies values, formulas and styles across every row |
clearColumn |
{ columnId, what? } — empties a column without deleting it |
what is "values", "styles" or "all". Both run in bounded chunks inside
the batch's transaction, so a 500k-row column paste is one request with a flat
working set rather than half a million setCells.
GET /files/:id/rows and POST /files/:id/query take a headerRows count: the
first n rows in file order are exempt from the sort and the filter, so a sheet
whose row 1 holds labels keeps them at the top of every page rather than filing
"Amount" under A. A frozen row counts as a heading too, and the larger of the
two wins — freezing a row is how a sheet whose column names came from its first
line says "this one is my heading".
Every page carries that band back with it: band holds those rows (band[i] is
view index i) and bandSize is how many the view actually pinned, which is 0
for a sheet too short to have them. They ride along rather than being fetched
separately so that a heading and the rows beneath it can never come from two
different revisions — and so a client holding page 3 of a sheet can still draw
the heading it froze. That is what DataGrid's pinnedRows wants.
Dependencies
Two, at runtime:
| hono | MIT | the HTTP layer |
| fflate | MIT, 0 deps, 8 kB | zip, for XLSX |
Everything else is in-house, which was a licensing decision as much as a technical one:
- HyperFormula is GPL-3.0-only. Publishing it inside this package would force GPL on anyone who embeds the UI, or require a commercial licence. The formula engine here is written from scratch and MIT.
- npm's
xlsx@0.18.5has unpatched CVEs — SheetJS moved its fixes off npm to its own CDN. The XLSX codec here is built on fflate, has no CVE surface, and unlike free SheetJS it can write cell styles. - The CSV codec, the virtualized grid and the stylesheet are in-house too, which
removes
papaparse,@tanstack/react-table,tailwindcss,postcss,autoprefixerandtsup— and, in the stylesheet's case, removes any chance of leaking styles into a host app.
14 packages installed, total, including every dev dependency.
Testing
bun test # 1,079 tests
bun test --coverage # the same, with a coverage table
bun run verify # typecheck, then build, then the tests
Beyond unit tests, three things are checked that unit tests cannot reach:
- XLSX interop is verified in both directions against openpyxl, an independent OOXML implementation. Its output is committed as a fixture, so the interop cannot regress without Python at test time.
- Filter semantics run every tree through the in-memory evaluator and
SQLite, asserting identical row sets. That is how a real divergence was
caught: SQL is three-valued, so
NOT (x)is NULL whenxcompares against a blank cell, and negated groups were silently dropping every blank row. - Build artefacts are imported and inspected — every named export must resolve, the compiled UI must be present in the server, CJS and CLI bundles, externals must have stayed external, and no stylesheet selector may be unnamespaced.
- The pointer gestures run in a real browser. Dragging a picture, dragging its corner to resize it, copying and pasting it, finding it in the same place after a reload, and the double-click that turns a sheet tab into a field you can rename it in are all driven through Chromium, because nothing outside a browser can tell whether a picture ends up where the pointer left it — or whether a control that renders perfectly does anything at all. Every browser file shares one Chromium, launched once and held for the run — launching and closing one per file made the suite intermittently take six times as long and time out in whichever file happened to go first.
- Formatting is asserted after a reload, not after a render. A bold column,
a cell colour, a frozen header row and the overflow toggle are all set through
the interface and then read back from a fresh page, because "close it and open
it again and it looks exactly as you left it" is a claim about the round trip.
The same file measures the spilled text against its own cell, which is the
kind of thing that keeps passing in a headless DOM long after it has stopped
working on screen — and it is how a
<label>that had been quietly forwarding every click to a tooltip button instead of its own switch was found. - A sheet name we accept is one the writer stores unchanged. Renaming is cleaned against Excel's rules in one place, and a test runs every accepted name back through the XLSX writer: without it, a tab could be renamed to something the export silently rewrote, and the two would only be seen to disagree in a file somebody had already sent on.
The grid's layout maths lives in pure functions, deliberately: a headless DOM computes no geometry, so a test that mounted the grid would pass while columns overlapped on screen.
Licence
MIT. See LICENSE.