Skip to content

Port upstream Muya history identity op guard#61

Open
Renakoni wants to merge 3 commits into
mainfrom
sync/upstream-4838-history-identity-ops
Open

Port upstream Muya history identity op guard#61
Renakoni wants to merge 3 commits into
mainfrom
sync/upstream-4838-history-identity-ops

Conversation

@Renakoni

@Renakoni Renakoni commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Ports upstream marktext/marktext PR #4838 into the Android Muya copy.

Upstream source: marktext/marktext#4838

This is a follow-up hardening PR for upstream #4815, so this Android PR is stacked on Android PR #60 (sync/upstream-4815-identity-flush). json-change can still carry the identity operation (null) through non-deferred paths such as Editor.updateContents(null). History reads op.length, so it must treat null as a no-op rather than recording or transforming it.

Changes

  • Changes History's json-change listener to accept Nullable<JSONOpList>.
  • Ignores null identity ops before _record() / _transform().
  • Adds regression coverage for updateContents(null) and the compose-to-null deferred flush path.

Verification

  • pnpm test -- src/history/__tests__/identityOpJsonChange.spec.ts src/state/__tests__/flushPendingOps.spec.ts from third_party/muya passed: 7 tests.
  • pnpm exec eslint src/history/index.ts src/history/__tests__/identityOpJsonChange.spec.ts --no-ignore --max-warnings 0 from third_party/muya passed.
  • pnpm typecheck from repo root passed.

Audit Decision

This upstream PR is Android-relevant because it hardens Muya's state/history path for identity operations, including IME-like edit cancellation cases. Android heavily depends on IME behavior in the WebView editor, and this PR closes the consumer-side crash even if another emitter forwards null in the future.

Base automatically changed from sync/upstream-4815-identity-flush to main July 9, 2026 01:13
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