Skip to content

fix(messages): keep the folder list stable on focused-message archive - #311

Merged
hieunc229 merged 4 commits into
hieunc229:mainfrom
antonio-ivanovski:fix/focused-archive-list-refresh
Nov 18, 2026
Merged

hieunc229 merged 4 commits into
hieunc229:mainfrom
antonio-ivanovski:fix/focused-archive-list-refresh

Conversation

@antonio-ivanovski

@antonio-ivanovski antonio-ivanovski commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Draft — stacked on #310.

This PR is based on feat/mail-action-undo, not main. GitHub cannot use a branch that only exists in a fork as the base of an upstream PR, so this PR targets main and therefore also contains all of #310's commits. That is why the diff is large. The change in this PR is only the last three commits:

  • ae384cc fix(messages): keep the folder list mounted across the reader
  • 6443127 fix(messages): drop moved rows from the list immediately
  • 5dc93ec feat(messages): make moves optimistic with instant undo

Once #310 lands, rebase this branch onto main and the diff will reduce to those three commits. Keep it in draft until then.

Goal

Archiving the focused message must not remount, blank, or visibly refresh the folder list.

What changed

  • One list for the folder. The list now lives in the shared folder layout instead of each route page. Opening a message hides it without unmounting it; archiving the open message returns to the same DOM node, not a freshly mounted list.
  • The row leaves before the request. A committed move prunes the row in place using membership that mirrors the server query: Inbox drops it, Starred keeps it, custom folders ignore snooze, and same-status moves are no-ops.
  • Optimistic through undo. Moves get a tombstone keyed by list identity and page. Undo restores the row from that tombstone before the undo response, and repeated peeks, remounts, and refetches replay the same overlay instead of consuming it once.
  • Narrow rollback. Undo overlays only the fields the action changed and falls back to the membership captured before the click. Read/star settlements never clear or restore move tombstones.

Proof

The before/after recording is below. The list request is delayed by 4 seconds in both clips:

focused-archive-before-after.mp4
  • Before: archiving the open message returns to a freshly mounted list showing 0 - 0 of 0 until the request resolves.
  • After: the same list element stays painted, the row is gone immediately, and the count stays 1 - 4 of 4 while the request is held.

Testing

  • node --test tests/*.test.mjs — 798 tests, 789 pass, same 7 pre-existing failures as main.
  • tsc --noEmit — clean.
  • Production build — passes.
  • New/updated coverage: tests/message-membership-overlay.test.mjs, tests/message-list-optimistic-removal.test.mjs, tests/message-list-membership.test.mjs, and the list-DOM identity cases in tests/message-selection-navigation.test.mjs.

@hieunc229

Copy link
Copy Markdown
Owner

I see this is still a draft, should we merge it?

@antonio-ivanovski

Copy link
Copy Markdown
Contributor Author

Yes, made it draft because it was stacked pr on top of another. Let me get it rebased and will ping you

Opening a message unmounted the folder list and let MessageSplitLayout
render a separate compact copy beside the reader. Archiving then cleared
the list cache and navigated back to the folder, where a freshly mounted
list painted an empty first frame until its request returned.

Move list ownership into the shared folder layout so it survives the
index <-> message route change. The layout now renders one list that
expands to full width when no message is open and hides (without
unmounting) while reading. Message details remain owned by the route.

The index pages now render nothing; their layout supplies the list.
Add reconciliation tests asserting the same list DOM node survives
opening and closing a message, including single-column reading.
A successful move cleared the list cache and waited for the debounced
refetch, so the moved row lingered until the response landed.

Emit the committed per-message state from the shared action executor and
prune the mounted list in place. Membership mirrors the server query:
Starred ignores status changes, custom folders ignore snooze, and
same-status moves are no-ops. Direction-dependent optimistic decisions
wait for the committed state on grouped rows, whose members may mix
directions. Conversation rows keep their representative until the
refetch and disappear only after their last scoped member.

An optimistically emptied intermediate page now waits for backfill
instead of skipping it. Permanent delete reports the same removal event.

Covered by delayed-response, stale-response, thread, Starred,
custom-folder, Snoozed, duplicate-event, and grouped-member tests.
Moves now disappear before the refetch and return before the undo
response, while the server remains the authority for reconciliation.

The executor computes the target membership before the request. A
membership store carries compact known rows, a pending overlay, and
tombstones keyed by list identity and page. Grouped rows defer
direction-dependent actions (spam, snooze) until the committed response
carries per-member state, because a representative's direction says
nothing about its peers.

Undo overlays only the fields the action changed and restores tombstones
from the same page. Skipped or failed records roll back to the membership
captured on screen before the click, never to a historical applied
snapshot. A failed undo keeps its tombstone so a retry still restores
instantly after navigating away and back.

Read/star settlements no longer touch move tombstones. Optimistic events
stay in the originating tab; other tabs receive the committed state and
refetch. List ingress derives rows and totals from the raw cached
response, so repeated peeks and remounts cannot consume restoration once.

Covered by real-hook and real-executor tests for delayed requests,
in-flight list ingress, failure rollback, undo before the server answer,
repeated ingress, remounts, partial undo, sequential conversation
removals, StrictMode, and read/star settlements.
…ter rebase

- Sync the list ref in an effect instead of during render (lint).
- Let list refreshes reject again so the refresh button can announce
  failures; the list is already preserved by only applying successful
  loads. This also fixes the pre-existing refresh-failure test on main.
- Include ok/status in mocked list responses so fetchMessageList no
  longer treats them as errors.
@antonio-ivanovski
antonio-ivanovski force-pushed the fix/focused-archive-list-refresh branch from dec1fa8 to c1c4bd3 Compare November 18, 2026 17:52
@antonio-ivanovski
antonio-ivanovski marked this pull request as ready for review November 18, 2026 17:53
@antonio-ivanovski

Copy link
Copy Markdown
Contributor Author

done @hieunc229

@hieunc229

Copy link
Copy Markdown
Owner

Thank you!

@hieunc229
hieunc229 merged commit 06799fd into hieunc229:main Nov 18, 2026
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.

2 participants