Skip to content

[TW-6425] fix(@ownmail/app): refresh mutable draft and mailbox state - #269

Merged
AaronDDM merged 2 commits into
mainfrom
agent/tw-6425-refresh-stale-drafts
Aug 13, 2026
Merged

[TW-6425] fix(@ownmail/app): refresh mutable draft and mailbox state#269
AaronDDM merged 2 commits into
mainfrom
agent/tw-6425-refresh-stale-drafts

Conversation

@nylas-it-ops

@nylas-it-ops nylas-it-ops commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • await a refetch when compose opens an invalidated cached draft
  • observe mailbox information independently from the infinitely cached Mail shell
  • update mailbox-info cache immediately with the server-confirmed Settings display name
  • restore a 30-second mailbox-info freshness window for external changes
  • add regressions for invalidated draft loading and stale mailbox identity
  • add an @ownmail/app patch changeset

Root cause

Mail-version synchronization correctly invalidates inactive draft-detail queries after external changes. The compose loader used ensureQueryData, which returns any cached entry without awaiting a refetch, including an invalidated entry. Compose then initialized local editor state from that stale value and did not subscribe to the draft query, so reopening and saving could overwrite newer server content.

Mailbox information was also mutable but modeled as immutable. The Mail parent route and its mailbox-info query both used infinite staleness, while Mail rendered the loader snapshot directly. Settings saved the display name to the server and browser preferences without updating that query, so AppRailNav continued receiving the old nonempty server name and never reached its browser-preference fallback.

The compose loader now uses fetchQuery, which reuses fresh entries but awaits stale or invalidated ones. Mail now observes a shared mailbox-info query with a 30-second freshness window, and Settings writes the authoritative save result into that cache immediately.

Impact

Drafts changed in another tab or device reopen with current server content. Display-name changes appear in Mail immediately after saving Settings and remain revalidatable for external account changes.

Validation

  • pnpm --filter @ownmail/app test — 1,898 tests passed, 100% coverage
  • pnpm --filter @ownmail/app typecheck
  • pnpm --filter @ownmail/app build:node
  • pnpm --filter @ownmail/app smoke:ssr
  • pnpm lint — 0 warnings
  • pnpm commit:check -- .git/COMMIT_EDITMSG

Follow-up to #267.

Jira: TW-6425

@nylas-it-ops nylas-it-ops changed the title [TW-6425] fix(@ownmail/app): refresh stale drafts before compose [TW-6425] fix(@ownmail/app): refresh mutable draft and mailbox state Aug 13, 2026
@AaronDDM
AaronDDM marked this pull request as ready for review August 13, 2026 22:12
@AaronDDM
AaronDDM merged commit 1a689ef into main Aug 13, 2026
9 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b04b70a551

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +137 to +140
queryClient.setQueryData(mailboxInfoQueryOptions().queryKey, {
...info,
displayName: account.displayName,
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid refreshing the cache from stale Settings data

When the user changes only a browser preference, account is built from persistedDisplayName without contacting the server, but this unconditional write marks the loader's mailbox snapshot fresh. If the display name changed on another device after Settings loaded, navigating to Mail now reuses the old name instead of fetching the current mailbox info; update this cache only after a display-name mutation, or invalidate/refetch it for preference-only saves.

Useful? React with 👍 / 👎.

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