Skip to content

Conversation

@jaycnz
Copy link
Contributor

@jaycnz jaycnz commented Jan 19, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved undo/redo functionality for multiselect block creation with proper cleanup and removal of all associated elements when undoing operations.
    • Enhanced state restoration when redoing multiselect block operations.
  • Tests

    • Strengthened test validation for cache state management during block operations.
    • Added comprehensive checks for undo/redo workflows and state consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@jaycnz jaycnz requested a review from edmonday January 19, 2026 01:54
@jaycnz jaycnz self-assigned this Jan 19, 2026
@jaycnz jaycnz added type: fix Iterations on existing features or infrastructure. effort: 3 Bug Interns labels Jan 19, 2026
@linear
Copy link

linear bot commented Jan 19, 2026

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

The PR updates the NewMultiselectButton component and its tests to change GraphQL mock data from flat objects to array-based structures, enhance Apollo cache initialization, and extend undo/redo operations with comprehensive cache cleanup on deletion and block restoration on redo.

Changes

Cohort / File(s) Summary
Test Specifications
apps/journeys-admin/src/components/Editor/Slider/Settings/CanvasDetails/AddBlock/NewMultiselectButton/NewMultiselectButton.spec.tsx
GraphQL mock responses restructured from flat objects to single-entry arrays; Apollo cache initialization switched to empty blocks arrays; cache validation expectations updated to reflect array-based block references; MockedProvider now accepts pre-populated cache; additional async checks added for create/restore action verification; undo/redo flows assert new array-based cache state structure
Component Implementation
apps/journeys-admin/src/components/Editor/Slider/Settings/CanvasDetails/AddBlock/NewMultiselectButton/NewMultiselectButton.tsx
Added Reference type import from @apollo/client; undo path now tracks all created blocks in createdBlocks array and performs cache cleanup (removal and eviction) with garbage collection; optimistic response simplified to null values; update handler introduced for delete mutation cache cleanup; redo path enhanced with update handler to restore block references to Journey blocks list; optimistic response extended to include startIcon and endIcon fields

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Component as NewMultiselectButton<br/>Component
    participant Apollo as Apollo Cache
    participant Mutation as GraphQL Mutation

    User->>Component: Create multiselect
    Component->>Mutation: Create mutation (multiselect, options,<br/>button, icons)
    Mutation->>Apollo: Write optimistic response
    Mutation-->>Component: Return created blocks
    Apollo->>Apollo: Add block references to<br/>Journey blocks array

    User->>Component: Undo (delete created blocks)
    Component->>Mutation: Delete mutation
    Mutation->>Apollo: Set fields to null<br/>(optimisticResponse)
    Mutation-->>Component: Return mutation data
    Apollo->>Apollo: Iterate createdBlocks
    Apollo->>Apollo: Remove refs from<br/>Journey blocks list
    Apollo->>Apollo: Evict each block<br/>cache entry
    Apollo->>Apollo: Run garbage<br/>collection

    User->>Component: Redo (restore blocks)
    Component->>Mutation: Create mutation (restore)
    Mutation-->>Component: Return restored blocks
    Apollo->>Apollo: For each block,<br/>append ref to<br/>Journey blocks list
    Apollo->>Apollo: Update Journey<br/>query cache
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • edmonday
  • tanflem
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: fixing multiselect undo/redo functionality by updating Apollo cache handling and ensuring proper rendering.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jaychen/nes-1032-unable-to-undo-multiselect-block-right-after-creation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 050c941

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 32s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 11s View ↗
nx run-many --target=deploy --projects=journeys... ✅ Succeeded 2m 33s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 02:07:52 UTC

@github-actions github-actions bot requested a deployment to Preview - journeys-admin January 19, 2026 01:57 Pending
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin January 19, 2026 02:01 Inactive
@github-actions
Copy link
Contributor

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Mon Jan 19 15:04:49 NZDT 2026

const [multiselectWithButtonDelete] = useMutation(
MULTISELECT_WITH_BUTTON_DELETE
)
const [multiselectWithButtonRestore] = useMutation(
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea to provide some type safety when using this mutation.

Suggested change
const [multiselectWithButtonRestore] = useMutation<MultiselectWithButtonRestore, MultiselectWithButtonRestoreVariables>(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug effort: 3 Interns type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants