Skip to content

mo.ui.matrix: type-to-edit cells and modifier-key scrubbing - #10520

Merged
akshayka merged 8 commits into
mainfrom
koaning/pull-ui-matrix-input
Aug 19, 2026
Merged

akshayka merged 8 commits into
mainfrom
koaning/pull-ui-matrix-input

Conversation

@koaning

@koaning koaning commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

This pull request was authored by a coding agent.

Summary

Two interaction upgrades for mo.ui.matrix, plus a correctness fix for symmetric matrices with per-cell bounds.

Type-to-edit cells

  • Double-click a cell (or press Enter/F2 while focused, or just start typing a digit/sign) to open an inline editor prefilled with the exact value.
  • Enter or blur commits; Escape cancels; invalid input is discarded.
  • Typed values are clamped to bounds but not snapped to step, so exact values like 2.32e7 survive the round trip.
  • A ref-mirrored editing state prevents the blur fired during commit-refocus from committing twice.

Modifier-key scrubbing

  • Shift+drag (or shift+arrow) steps 10× coarser; alt/option 10× finer; PageUp/PageDown step 10×.
  • Toggling a modifier mid-drag rebases the drag origin so the value rescales future movement instead of jumping.
  • Clicking a cell focuses it, so keyboard stepping works immediately; ArrowRight/ArrowLeft step alongside ArrowUp/ArrowDown (matching the horizontal drag direction and native slider convention).

Symmetric bounds fix

withCellValue is now the single mutation chokepoint for bounds enforcement. In symmetric mode the shared value is clamped to the intersection of both cells' ranges — previously the mirrored cell received a value clamped only to the edited cell's bounds, so editing [0][1] could push [1][0] outside its own range. It also returns null when the clamped value is already in place, so no edit path emits setValue with an identical matrix.

Also updates the mo.ui.matrix docstring.

Tests

35 frontend tests in MatrixPlugin.test.tsx covering the editor lifecycle (open/commit/cancel/invalid), clamping (typed, dragged, symmetric intersection), the redundant-update and double-commit guards, debounced drags, modifier scrubbing including mid-drag rebase, and schema validation incl. a negative case.

Verification

  • pnpm vitest run src/plugins/impl/__tests__/MatrixPlugin.test.tsx — 35 passed
  • make fe-check — clean
  • make py-check — ruff lint/format clean; the typecheck step could not run locally (network cert issue downloading optional deps), relying on CI
  • Verified live against examples/ui/matrix.py: typed 2.5e-3 into the identity matrix, value rendered as 2.500e-3 and matrix.value round-tripped 0.0025 un-snapped

🤖 Generated with Claude Code

akshayka and others added 3 commits August 6, 2026 08:41
Double-click a cell, press Enter, or start typing to edit its value as
text, so exact values like 2.32e7 can be entered directly. Typed values
are clamped to bounds but not snapped to step. Hold shift while dragging
or pressing arrow keys for 10x coarser steps, alt/option for 10x finer
steps; PageUp/PageDown also step by 10x. Frontend-only; the Python API
is unchanged.
…t updates

withCellValue is now the single chokepoint for bounds enforcement: in
symmetric mode the shared value is clamped to the intersection of both
cells' ranges, and it returns null when the clamped value is already in
place so no edit path emits setValue with an identical matrix (previously
every pointermove past a transpose-capped bound fired a redundant kernel
update).

Also removes a stray numpy entry from marimo's core dependencies, and
adds tests for the redundant-update guard, debounced drags, the
double-commit guard, and schema rejection of invalid payloads.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 12, 2026 12:27pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 78.76% 81881 / 103959
🔵 Statements 78.76% 81881 / 103959
🔵 Functions 71.44% 698 / 977
🔵 Branches 79.42% 4921 / 6196
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/plugins/impl/MatrixPlugin.tsx 99.71% 97.7% 87.5% 99.71% 371
Generated in workflow #20384 for commit 5539248 by the Vitest Coverage Report Action

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread frontend/src/plugins/impl/MatrixPlugin.tsx Outdated
cleanFloat's noise tolerance was floored at ~2.2e-14 regardless of step
size, so steps below that threshold were silently snapped to zero. Scale
the tolerance with max(|x|, |step|) instead: legitimately tiny results
survive, while noise from arithmetic on ordinary magnitudes (e.g. the
5.55e-17 residue of 0.3 - 3 * 0.1) still rounds away.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@koaning
koaning marked this pull request as ready for review August 12, 2026 12:14
Copilot AI lite review requested due to automatic review settings August 12, 2026 12:14
@koaning
koaning marked this pull request as draft August 12, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances mo.ui.matrix’s frontend interaction model by adding an inline “type-to-edit” mode for exact numeric entry, improving modifier-key scrubbing behavior for drag/keyboard adjustments, and tightening symmetric-mode bounds enforcement so mirrored cells always respect both cells’ constraints.

Changes:

  • Added an inline cell editor (double-click / Enter / F2 / type-to-edit) that commits on Enter/blur, cancels on Escape, and clamps to bounds without snapping to step.
  • Implemented modifier-key scrubbing (shift=coarse, alt= fine, PageUp/PageDown coarse) with mid-drag modifier rebasing to avoid value jumps.
  • Centralized mutation via withCellValue and fixed symmetric-mode bounds clamping to the intersection of transpose-cell ranges; added extensive frontend test coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
marimo/_plugins/ui/_impl/matrix.py Updates mo.ui.matrix docstring to describe new editor + modifier scrubbing behavior.
frontend/src/plugins/impl/MatrixPlugin.tsx Implements inline editing, modifier scrubbing, float-noise cleanup, and symmetric bounds enforcement via a shared mutation helper.
frontend/src/plugins/impl/tests/MatrixPlugin.test.tsx Adds comprehensive tests for editing lifecycle, clamping, debounce behavior, symmetric intersection clamping, and modifier scrubbing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

koaning and others added 2 commits August 12, 2026 14:24
pointerdown's preventDefault (needed for drag-scrubbing) also suppressed
the browser's click-to-focus, so keyboard stepping was only reachable via
Tab or by opening and closing the cell editor. Focus the cell explicitly
on pointerdown.

ArrowRight/ArrowLeft now step the value alongside ArrowUp/ArrowDown with
the same modifier scaling, matching the horizontal drag direction and the
native slider convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@koaning
koaning requested a review from akshayka August 14, 2026 08:29
@koaning
koaning marked this pull request as ready for review August 14, 2026 08:29
@Light2Dark Light2Dark added the release-highlight A feature or change to call out in upcoming release notes label Aug 17, 2026
@akshayka akshayka added the bash-focus Area to focus on during release bug bash label Aug 19, 2026
@akshayka
akshayka merged commit 5c3646a into main Aug 19, 2026
64 of 66 checks passed
@akshayka
akshayka deleted the koaning/pull-ui-matrix-input branch August 19, 2026 15:29
williambdean pushed a commit to williambdean/marimo that referenced this pull request Sep 6, 2026
…eam#10520)

**This pull request was authored by a coding agent.**

## Summary

Two interaction upgrades for `mo.ui.matrix`, plus a correctness fix for
symmetric matrices with per-cell bounds.

### Type-to-edit cells

- Double-click a cell (or press Enter/F2 while focused, or just start
typing a digit/sign) to open an inline editor prefilled with the exact
value.
- Enter or blur commits; Escape cancels; invalid input is discarded.
- Typed values are clamped to bounds but **not** snapped to `step`, so
exact values like `2.32e7` survive the round trip.
- A ref-mirrored editing state prevents the blur fired during
commit-refocus from committing twice.

### Modifier-key scrubbing

- Shift+drag (or shift+arrow) steps 10× coarser; alt/option 10× finer;
PageUp/PageDown step 10×.
- Toggling a modifier mid-drag rebases the drag origin so the value
rescales future movement instead of jumping.
- Clicking a cell focuses it, so keyboard stepping works immediately;
ArrowRight/ArrowLeft step alongside ArrowUp/ArrowDown (matching the
horizontal drag direction and native slider convention).

### Symmetric bounds fix

`withCellValue` is now the single mutation chokepoint for bounds
enforcement. In symmetric mode the shared value is clamped to the
**intersection** of both cells' ranges — previously the mirrored cell
received a value clamped only to the edited cell's bounds, so editing
`[0][1]` could push `[1][0]` outside its own range. It also returns
`null` when the clamped value is already in place, so no edit path emits
`setValue` with an identical matrix.

Also updates the `mo.ui.matrix` docstring.

## Tests

35 frontend tests in `MatrixPlugin.test.tsx` covering the editor
lifecycle (open/commit/cancel/invalid), clamping (typed, dragged,
symmetric intersection), the redundant-update and double-commit guards,
debounced drags, modifier scrubbing including mid-drag rebase, and
schema validation incl. a negative case.

## Verification

- `pnpm vitest run src/plugins/impl/__tests__/MatrixPlugin.test.tsx` —
35 passed
- `make fe-check` — clean
- `make py-check` — ruff lint/format clean; the typecheck step could not
run locally (network cert issue downloading optional deps), relying on
CI
- Verified live against `examples/ui/matrix.py`: typed `2.5e-3` into the
identity matrix, value rendered as `2.500e-3` and `matrix.value`
round-tripped `0.0025` un-snapped

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Akshay Agrawal <akshay@marimo.io>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 55392486 Deployed Aug 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash enhancement New feature or request release-highlight A feature or change to call out in upcoming release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants