Skip to content

A downgraded no-op move displaces a removed entry from its original position #49546

Description

@anp0429

#49109 states that removed entries stay in the position the cell used to hold, so the list reads as a diff. A move that is later downgraded to unchanged (a no-op move) breaks this: the removed entry gets displaced below a cell that originally followed it.

Repro against current master (b9d22fa), vitest in apps/studio (added to data/content/notebooks/notebook-operations.test.ts, using the file's existing NOTEBOOK fixture):

const NOTEBOOK: NotebookWire = {
  schema_version: 1,
  cells: [
    { _tag: 'markdown_cell', _id: 'cell-1', text: '# Intro' },
    { _tag: 'database_cell', _id: 'cell-2', sql: 'select 1', row_limit: 100 },
    { _tag: 'markdown_cell', _id: 'cell-3', text: '# Outro' },
  ],
}
 
it('does not let a no-op move after a deletion reorder the removed entry', () => {
  const ops: NotebookOperation[] = [
    { _tag: 'delete_cell', cell_id: 'cell-2' },
    { _tag: 'move_cell', cell_id: 'cell-3', after_cell_id: 'cell-1' },
  ]
 
  const result = deriveNotebookDiff(NOTEBOOK, ops)
 
  expect(result.success).toBe(true)
  if (!result.success) return
 
  expect(result.entries).toHaveLength(3)
  expect(result.entries).toEqual([
    { _tag: 'unchanged', cell: NOTEBOOK.cells[0] },
    { _tag: 'removed', cell: NOTEBOOK.cells[1], operationIndex: 0 },
    { _tag: 'unchanged', cell: NOTEBOOK.cells[2] },
  ])
})

Moving cell-3 after cell-1 is a no-op once cell-2 is deleted (the surviving order is unchanged), and the move is correctly downgraded — but the removed entry no longer holds its original position:

- Expected                            + Received
  { "_tag": "removed",                  { "_tag": "unchanged",
    "cell": { "_id": "cell-2", … },       "cell": { "_id": "cell-3", … } },
    "operationIndex": 0 },              { "_tag": "removed",
  { "_tag": "unchanged",                  "cell": { "_id": "cell-2", … },
    "cell": { "_id": "cell-3", … } }      "operationIndex": 0 },

The final cell contents are unaffected, but the rendered preview shows the deletion happening in the wrong place — the entry order disagrees with what the reader is told to expect.

First found Aug 20 (master 5d3b849); re-verified today, Aug 25, on current master (b9d22fa) — fails identically throughout, across the id → _id refactor (#49272). The 29 existing tests in the file pass in the same run. Failing-test branch: https://github.com/anp0429/supabase/tree/edgeverdict/notebook-regressions-v2 — happy to open a PR with the test if useful.

Activity

  1. added
    bug
    on Aug 25, 2026
  2. added
    external-issue
    on Aug 25, 2026
  3. anp0429 commented on Aug 28, 2026

    @anp0429
    Author

    Re-verified on master 86c813e (after #49694): the test above still fails with the same shape, removed entry displaced below cell-3. Two more variants of the same class fail on master too (insert after a downgraded move; leading delete then move-to-start), both on the regression branch. If this was closed as design-intent, understood; if it was closed as fixed, it isn't yet.

  4. added a commit that references this issue on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexternal-issueto-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions