Skip to content

fix: preserve message edits across timeline windows#458

Merged
mubarakcoded merged 2 commits into
masterfrom
pip/whitenoise-mac-419
Jul 13, 2026
Merged

fix: preserve message edits across timeline windows#458
mubarakcoded merged 2 commits into
masterfrom
pip/whitenoise-mac-419

Conversation

@agent-p1p

@agent-p1p agent-p1p commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #419

Summary

  • Moves kind-1009 edit folding from batch-local mapping into MessageTimelineStore, so standalone edit deltas can update an existing row and pending edits survive timeline-window replacement/pagination.
  • Keeps unedited base rows plus bounded edit candidates keyed by edit event, validates target kind/author before rendering, and restores the next valid edit or original body on removal/invalidation/deletion.
  • Preserves normal chat-body normalization and Markdown fallback behavior for edited plaintext.

Regression coverage

  • standalone edit-only projection delta
  • target and edit arriving in different windows
  • newest edit ordering and fallback after retraction
  • invalidated/deleted edit retraction
  • forged-sender rejection, including a 200-edit pending flood
  • trim, clear, target removal, replacement, and body normalization

Verification

  • git diff --check — pass
  • added-line security/debug scan — pass
  • conflict-marker scan — pass
  • added Swift lines over 120 columns — none
  • signed commit verified with git verify-commit
  • bash scripts/ci/macos-sanity-checks.sh — not runnable on this Linux host (xcodebuild: command not found); macOS CI is the authoritative compile/test run

Sensitive paths

None.


Open in Stage

Summary by CodeRabbit

  • New Features

    • Added support for message edits in timeline updates and live projections.
    • Edited messages now display updated text while preserving reactions, replies, and other message details.
    • Edit overlays are validated by author and can fall back to earlier edits or the original message.
  • Bug Fixes

    • Fixed edit-only timeline updates not appearing immediately.
    • Correctly handles invalidated, deleted, retracted, and whitespace-only edits.
  • Tests

    • Added comprehensive coverage for edit application, reversion, validation, and window changes.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Message edit records are now decoded into persistent mutations and applied by MessageTimelineStore. Timeline windows and live projections pass these mutations through the store, allowing edits to affect targets across pagination, replacements, removals, and standalone edit updates.

Changes

Timeline edit overlay projection

Layer / File(s) Summary
Decode edit overlays and apply edited content
whitenoise-mac/Core/MarmotMapping.swift, whitenoise-mac/Models/MessengerModels.swift
Adds edit mutation and overlay types, removes batch-local edit folding from timeline mapping, and adds MessageItem.applyingEdit(plaintext:).
Rebuild rendered timeline state
whitenoise-mac/Core/WorkspaceState.swift
Separates base messages from edit candidates, applies validity and preference rules, and recomputes rendered messages within the window limit.
Thread mutations through timeline updates
whitenoise-mac/Core/WorkspaceState+Timeline.swift
Passes edit mutations through authoritative window replacement and live projection updates, including edit-only deltas.
Validate overlay lifecycle
whitenoise-macTests/PureValueTests.swift
Tests overlay application, sender validation, persistence, retraction, clearing, retention, and plaintext normalization.
Validate timeline integration
whitenoise-macTests/whitenoise_macTests.swift
Tests store-based folding, invalidation and deletion behavior, and standalone edit projections against existing targets.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement cross-window and standalone edit folding as required by #419, with regression tests covering the described cases.
Out of Scope Changes check ✅ Passed The added types, store refactor, model helper, and tests all support edit preservation; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving message edits across timeline windows.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pip/whitenoise-mac-419

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.

@stage-review

stage-review Bot commented Jul 10, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Define message edit mutation models
2 Implement edit state management in MessageTimelineStore
3 Wire edit mutations through WorkspaceState
4 Verify edit persistence and security
Open in Stage

Chapters generated by Stage for commit d7bfca5 on Jul 13, 2026 12:41pm UTC.

@agent-p1p
agent-p1p force-pushed the pip/whitenoise-mac-419 branch from 84e3052 to 84b0470 Compare July 10, 2026 15:44
@agent-p1p
agent-p1p force-pushed the pip/whitenoise-mac-419 branch from 84b0470 to b6e9453 Compare July 10, 2026 15:47
@agent-p1p

Copy link
Copy Markdown
Contributor Author

CI blocker: master is red on messageMediaDiskCacheReadDeletionMaintainsTrackedFootprint() after #444; tracked as #457. The same failure reproduces on base SHA 0454dbf (run 29100021269) and twice on this branch after all #419 tests passed. This PR has therefore been red and is not merge-eligible under Pip policy. After #457 lands, rebase the final tree and open a fresh replacement PR; close this one once the replacement is green.

@mubarakcoded
mubarakcoded marked this pull request as ready for review July 13, 2026 14:28
@mubarakcoded
mubarakcoded merged commit 8375db2 into master Jul 13, 2026
4 of 5 checks passed
@mubarakcoded
mubarakcoded deleted the pip/whitenoise-mac-419 branch July 13, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants