Skip to content

[lexical-history] Feature: Add maxDepth option to HistoryExtension#8537

Merged
etrepum merged 2 commits into
facebook:mainfrom
etrepum:claude/tender-knuth-pjzaQ
May 22, 2026
Merged

[lexical-history] Feature: Add maxDepth option to HistoryExtension#8537
etrepum merged 2 commits into
facebook:mainfrom
etrepum:claude/tender-knuth-pjzaQ

Conversation

@etrepum

@etrepum etrepum commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds a maxDepth: number | null config option (and matching output Signal) to HistoryExtension. When non-null, the undo stack is FIFO-evicted to that length on each push. Defaults to null, preserving the historical unbounded behavior — existing consumers are unchanged.

This is intentionally a per-event check rather than a periodic prune so the cap is enforced exactly when entries are appended; the trim does shape the array referenced by historyState.undoStack (in place via splice) so peer extensions such as SharedHistoryExtension that hold a reference to it continue to see the trimmed stack.

Test plan

New unit tests cover three cases: the unbounded default, a finite cap evicting older entries, and reactive lowering of the cap via the output Signal.

Adds a maxDepth: number | null config option (and matching output Signal)
to HistoryExtension. When non-null, the undo stack is FIFO-evicted to
that length on each push. Defaults to null, preserving the historical
unbounded behavior — existing consumers are unchanged.

This is intentionally a per-event check rather than a periodic prune so
the cap is enforced exactly when entries are appended; the trim does
shape the array referenced by `historyState.undoStack` (in place via
splice) so peer extensions such as SharedHistoryExtension that hold a
reference to it continue to see the trimmed stack.

Tests cover three cases: the unbounded default, a finite cap evicting
older entries, and reactive lowering of the cap via the output Signal.
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 21, 2026 10:11pm
lexical-playground Ready Ready Preview, Comment May 21, 2026 10:11pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 21, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label May 21, 2026
@etrepum etrepum added this pull request to the merge queue May 22, 2026
Merged via the queue into facebook:main with commit 3828391 May 22, 2026
42 checks passed
@etrepum etrepum mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants