Skip to content

[TW-6425] fix(@ownmail/app): restore mailbox rendering and draft isolation - #267

Merged
AaronDDM merged 1 commit into
mainfrom
agent/tw-6425-ownmail-ssr-router-context
Aug 13, 2026
Merged

[TW-6425] fix(@ownmail/app): restore mailbox rendering and draft isolation#267
AaronDDM merged 1 commit into
mainfrom
agent/tw-6425-ownmail-ssr-router-context

Conversation

@nylas-it-ops

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

Copy link
Copy Markdown
Contributor

Summary

  • restore authenticated mailbox SSR by placing the React Query provider inside TanStack Router context
  • remount the composer by requested draft identity so draft-owned recipients, subject, body, refs, attachments, and autosave state cannot leak between backdrop drafts
  • await a fresh draft when mail-version synchronization has invalidated an inactive cached detail
  • add an authenticated built-artifact SSR smoke test to CI
  • add real router-boundary, same-route draft-switch, and invalidated-cache regression tests
  • add an @ownmail/app patch changeset

Root cause

PR #265 moved OwnmailQueryProvider from the root route into TanStack Router's outer Wrap. The provider renders ServerStateSync, which calls useRouterState. Outer Wrap is above RouterContextProvider, so SSR received a null router and failed while reading router.stores.

The change passed because the provider unit tests mocked useRouterState, the router test did not render the provider boundary, and the release smoke test covered packaging rather than a built authenticated SSR request.

The compose backdrop had a separate same-route identity issue: selecting another draft reused the existing Compose instance, leaving draft-owned state and refs initialized from the previous loader result.

Previously opened drafts had a cache freshness issue as well: mail-version sync invalidated inactive draft details, but ensureQueryData returned the cached value without awaiting a refetch. Because compose did not subscribe to that query afterward, stale content could initialize the editor and overwrite a newer server version.

Impact

Authenticated mailbox pages render again instead of returning HTTP 500. Switching between backdrop drafts cannot mix draft identity or metadata, and reopening an externally changed draft initializes from the current server version.

Validation

  • pnpm --filter @ownmail/app test — 1,897 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

Jira: TW-6425

@AaronDDM
AaronDDM marked this pull request as ready for review August 13, 2026 17:06
@AaronDDM
AaronDDM requested a review from radenkovic as a code owner August 13, 2026 17:06
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@AaronDDM
AaronDDM merged commit 71cbac7 into main Aug 13, 2026
9 checks passed
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