Skip to content

Fix uncategorize undo save error#4528

Merged
raineorshine merged 2 commits into
cybersemics:mainfrom
Ruby95515:fix/4425-uncategorize-undo-save
Jul 8, 2026
Merged

Fix uncategorize undo save error#4528
raineorshine merged 2 commits into
cybersemics:mainfrom
Ruby95515:fix/4425-uncategorize-undo-save

Conversation

@Ruby95515

Copy link
Copy Markdown
Contributor

Summary

Fixes #4425.

This fixes a crash/save error when uncategorizing a duplicated uncle thought and then undoing the change.

Problem

For a tree like:

  • a
  • b
    • a
      • c

Uncategorizing b/a and then undoing could produce:

Cannot read properties of undefined (reading 'length')

The visible tree operation was mostly correct, but the undo persistence path could enqueue malformed lexeme updates.

Changes

  • Prevent uncategorize from merging a child back into the category being deleted when they have the same value.
  • Fix undo/redo push queue reconstruction to persist the full lexeme from state instead of forwarding nested JSON patch leaf values.
  • Add regression coverage for:
    • uncategorizing same-valued nested thoughts
    • undoing the duplicate-uncle uncategorize case
    • ensuring undo persistence sends complete lexeme updates
    • ensuring the initialized persistence path does not raise the save-error alert

Testing

Passed:

  • yarn test src/actions/__tests__/uncategorize.ts src/commands/__tests__/uncategorize.ts src/commands/__tests__/undo-redo.ts
  • yarn lint:tsc
  • yarn eslint src/redux-enhancers/undoRedoEnhancer.ts src/actions/uncategorize.ts src/actions/__tests__/uncategorize.ts src/commands/__tests__/uncategorize.ts

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Vercel preview: https://em-8oryh1yhu-cybersemics.vercel.app

@raineorshine raineorshine 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.

Fix looks good. Just some requests around test architecture.

Comment thread src/commands/__tests__/uncategorize.ts Outdated
Comment thread src/commands/__tests__/uncategorize.ts Outdated
@Ruby95515 Ruby95515 requested a review from raineorshine July 7, 2026 04:30
@raineorshine raineorshine requested a review from BayuAri July 7, 2026 20:11

@BayuAri BayuAri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Error is no longer prompted after Undo the Uncategorize with auto merged duplicate parent.

@raineorshine raineorshine merged commit a56f8e1 into cybersemics:main Jul 8, 2026
12 checks passed
@raineorshine

Copy link
Copy Markdown
Contributor

Thank you!

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.

Uncategorize duplicate of uncle breaks undo: Error: undefined is not an object (evaluating 'R.length')

3 participants