Skip to content

fix(sheets): undo, view duplicates, draft uploads and the multiline editor - #65

Merged
yyyyaaa merged 6 commits into
mainfrom
fix/sheets-tenki-review
Nov 16, 2026
Merged

yyyyaaa merged 6 commits into
mainfrom
fix/sheets-tenki-review

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the Sheets problems a review of constructive-io/dashboard#324 found in the grid it copies from here. Each fix has a test that fails without it.

  • Refused undo kept: the cell undo and redo steps were () => void commit(...), so the history never saw a refusal and a refused undo was lost. They now wait for the commit and throw when any row was not saved (CommitCellsResult.unsaved), so the step stays for another try. The writes are values, so a retry also suits the rows that saved.
  • Undo steps one at a time: useUndoRedo runs each step after the one before it ends. A held Mod+Z against a slow server no longer sends undos of one cell in parallel, where they could land out of order.
  • Duplicate view: a view name of 76 to 80 characters made every " copy N" too long, so the loop looking for a free name never ended and the page froze. copyViewName (grid/views/view-names.ts) shortens the name so the copy fits.
  • File editor on a new row: when the row still lacks required values, the editor says "Fill in Title to save this row." It no longer says the row was created, or tells the host so.
  • Multiline cell editor: the field and its error notice are portalled at a fixed place; they now measure the cell again on scroll and resize, so they stay on the cell.

Before and after

The multiline cell editor after the grid scrolls by one row (Storybook, Stress/10k Rows):

Before After
Before: after a one-row scroll the editor stays one row below its cell After: the editor stays on its cell

🤖 Generated with Claude Code

https://claude.ai/code/session_017WbsG7HDw7AL26N4UZGgrM

…ne at a time

- The cell undo and redo steps waited for nothing (`() => void commit(...)`), so a step
  the server refused still left the history, and Mod+Z after it did nothing.
  They now wait for the commit and throw when any row was not saved; the history keeps
  the step for another try.
- Steps run one at a time: a held Mod+Z against a slow server no longer sends the
  undos of one cell in parallel, where they could land out of order.
…e page

A name of 76 to 80 characters made every "<name> copy N" too long, so the search for a free name never ended. The copy now shortens the name to fit.
A new row that still lacked required values said "The row was created, but its key could not be read" and told the host a row was created. It now says which fields to fill, and the row stays a draft.
@luxor-code-review

luxor-code-review Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high · 🟡 1 medium

💬 Inline comments (2)

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Unthrottled scroll measure re-renders every scroll event (inline-cell-editor.tsx:101) — The capture-phase window scroll listener stores a brand-new DOMRect on every scroll event of any scrollable descendant (packages/sheets/src/grid-dom/inline-cell-editor.tsx:101), since each getBoundingClientRect() returns a fresh object React re-renders even when left/top/width/height are unchanged.

The change serializes undo/redo through a promise chain so held Mod+Z against a slow server runs writes in order, and keeps refused steps on the undo stack for retry while surfacing an unsaved count. A new view-names.ts helper trims long copy names so the "copy N" suffix fits the 80-character limit, and the inline cell editor re-measures its anchor on scroll/resize. The file editor now surfaces a "fill in required fields" error when draft submission is refused.

Files Change
packages/sheets/src/grid/hooks/use-undo-redo.ts, use-batch-commit.ts (+ tests) Promise-queued undo/redo with refused-step retry and unsaved count in CommitCellsResult
packages/sheets/src/grid-dom/inline-cell-editor.tsx (+ anchor test) Portal re-measures the anchor cell on scroll/resize events
packages/sheets/src/grid/views/view-names.ts, use-saved-views.ts (+ test) Truncating copyViewName helper respecting MAX_VIEW_NAME_LENGTH
packages/sheets/src/uploads/editor/use-file-editor.ts, image-editor-draft.test.tsx Reject draft submission with missing required fields before row creation/upload
packages/sheets/registry.json Register the new view-names lib in the @constructive registry
packages/sheets/src/grid/render/use-grid-editing.ts Wire editing state to the updated undo/redo and editor contracts

Reviewed commit: 8cab575

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR hardens Sheets undo/redo, inline editor anchoring, saved-view naming, and draft submission failure paths.

Key findings

…ry right

- A refused step goes back to its place, under any edit recorded while it waited,
  so the next undo is that edit and not a replay of old values over it.
- A refused step whose stack was cleared, or whose redo stack an edit forked, is
  dropped: Undo no longer turns back on after a clear.
- An edit or a clear cancels the undo and redo steps asked for before it that
  have not started, so a held Mod+Z never undoes the newer edit.
@yyyyaaa

yyyyaaa commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Tenki nitpick (unthrottled scroll measure): valid and fixed in 8d6e659. The multiline editor keeps its previous rect while the cell has not moved, so a scroll elsewhere renders nothing.

@yyyyaaa
yyyyaaa merged commit 6b8f9ae into main Nov 16, 2026
6 checks 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