Repository navigation
docs(plans): site offline mode with opening countdown - #925
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f150134ed9
ℹ️ 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".
| throw new HTTPException(400, { | ||
| message: "The opening time must be in the future.", | ||
| }); |
There was a problem hiding this comment.
Return translation keys for site-status validation errors
When server-side validation rejects a save, these English messages reach the user unchanged: runAdminApiMutation reads the response text, and SiteStatusContent displays result.error.message directly in its toast. For example, an opening time that expires between client validation and the API request produces an English error even in the Polish AdminCP. Return stable error keys and translate them in the form instead, as required by AGENTS.md for API output shown in the UI.
AGENTS.md reference: AGENTS.md:L115-L115
Useful? React with 👍 / 👎.
| if (isSiteClosedTo({ pathname, status })) { | ||
| markSiteOfflineResponse(status.opensAt); |
There was a problem hiding this comment.
Apply the offline screen to the existing docs layout
While the site is offline, a guest requesting /docs still receives the documentation rather than the offline screen. The existing apps/web/src/routes/_docs.tsx calls loadMainShell, so this code marks its response as 503, but that route renders DocsShellContent, which uses neither ThemeLayoutContent nor SiteOfflineGate. A repository-wide search confirms there is no other offline gate around the docs shell. Wire the gate into that custom layout so public documentation is actually hidden and does not remain fully readable with an erroneous failure status.
Useful? React with 👍 / 👎.
| const serverNowMs = Date.parse(serverNow); | ||
| const offsetMs = fetchedAt ? serverNowMs - fetchedAt : 0; | ||
| const now = useServerClock(serverNowMs, offsetMs); |
There was a problem hiding this comment.
Account for client clock skew after hydrating SSR data
For an SSR-rendered offline page, fetchedAt is TanStack Query's server-generated dataUpdatedAt, so both operands here use the server clock and the calculated offset is approximately zero. After hydration, useServerClock switches to the browser's Date.now(), making the countdown jump by any client clock skew and potentially show “Opening soon” prematurely. The initial query remains fresh for a minute, so this persists until a browser refetch supplies a client-side receipt timestamp. Establish a client/server clock offset during hydration rather than treating the server's query-update timestamp as the browser's receipt time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b6ff885ad
ℹ️ 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".
| if (!allowWhenOffline && !adminStaffPermission) { | ||
| middleware.push(siteOfflineGuard()); |
There was a problem hiding this comment.
Exempt password-reset completion from the offline guard
When the site is offline, a signed-out user can request a password-reset email, but cannot complete the reset: changePasswordRoute in packages/api/src/modules/users/routes/change-password.route.ts has neither allowWhenOffline nor adminStaffPermission, so this newly installed guard returns 503 before validating the reset token. The recovery form calls that exact /users/change-password endpoint through changePasswordFromReset. This also prevents an administrator who forgot their password from recovering access during maintenance. Set allowWhenOffline: true on the completion route as well as the email-request route.
Useful? React with 👍 / 👎.
| return ( | ||
| <SiteStatusContent | ||
| canManage={canManage} | ||
| data={query.data} |
There was a problem hiding this comment.
Show a warning when the site-status refetch fails
After the initial status loads, a failed background refetch leaves query.data populated, so this branch silently renders the old settings without indicating that refresh failed or offering a retry. This is particularly misleading after a successful save whose invalidation refetch fails: the mutation reports success while the screen still presents the previous online/offline state. Keep the existing content, but render a warning alert with an in-place retry when query.isError is true, as required by the refetch-error guidance in AGENTS.md.
AGENTS.md reference: AGENTS.md:L80-L80
Useful? React with 👍 / 👎.
5b6ff88 to
065452a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 065452a2a3
ℹ️ 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".
| if (!allowWhenOffline && !adminStaffPermission) { | ||
| middleware.push(siteOfflineGuard()); |
There was a problem hiding this comment.
Exempt deletion-cancellation sign-in from the offline guard
When a signed-out user with a pending account deletion signs in during maintenance, the exempted sign-in endpoint returns an account_deletion_pending token, but completing that flow through /users/sign_in/cancel-deletion now returns 503: cancelDeletionSignInRoute declares neither allowWhenOffline nor an admin permission. This prevents the user from cancelling their scheduled deletion or completing sign-in, even though the login pages remain available. Add allowWhenOffline: true to that completion route so its existing token validation and releaseAccountDeletionHold handler can run.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7113cd1b5
ℹ️ 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".
| if (!allowWhenOffline && !adminStaffPermission) { | ||
| middleware.push(siteOfflineGuard()); |
There was a problem hiding this comment.
Exempt the SSO account-linking step from the offline guard
When a signed-out visitor uses an SSO identity whose email matches an existing account, the exempted callback returns a linkToken, but completing sign-in fails during maintenance. linkRoute in packages/api/src/modules/users/sso/routes/link.route.ts has neither allowWhenOffline nor an admin permission, so this guard returns 503 before its password/token validation can run. Both the browser transport's linkSso and the server auth transport call that endpoint. Add allowWhenOffline: true to the linking route so the SSO flow remains completable, including for administrators linking an identity.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d390eb667a
ℹ️ 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".
| await invalidatePageCacheTags([SITE_STATUS_PAGE_CACHE_TAG], { | ||
| mode: "hard", | ||
| }); |
There was a problem hiding this comment.
Invalidate page caches outside the API process
When the frontend runs separately from the API, or web replicas use the default per-process memory page cache, switching the site offline leaves other processes serving cached online HTML with HTTP 200. In the inspected packages/api/src/page-cache/store.server.ts, invalidatePageCacheTags only accesses a store registered on that process's globalThis and returns not-configured when none exists; deleting the domain-cache entry does not invalidate those HTML responses. Propagate the hard invalidation to the frontend cache owners rather than relying solely on this local call. This is the cross-process cache limitation documented in AGENTS.md.
AGENTS.md reference: AGENTS.md:L103-L103
Useful? React with 👍 / 👎.
- Site offline mode: the public site shows a status notice card with an optional opening countdown while admins and moderators with the new permission keep using it, marked by a staff chip in the header. - AdminCP: edit the site status inline with a live preview and see the offline state in the debug panel. - API: site offline middleware gates public routes; auth, session and passkey routes stay reachable so staff can still sign in. - Settings: grouped side nav (Account / Preferences / Privacy & safety), privacy switches moved to /settings/privacy, settings breadcrumb removed. - Plan: plans/site-offline-mode.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0a6b037 to
07c67be
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07c67bed2c
ℹ️ 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".
| return; | ||
| } | ||
|
|
||
| formApi.reset(formApi.state.values); |
There was a problem hiding this comment.
Preserve edits made while the site-status save is pending
If an administrator changes a field while onSave is pending, this reset marks the newer, unsent values as saved. The fields remain enabled during submission, while the request contains the earlier values snapshot. For example, changing the maintenance message during a slow save can leave that message displayed with the save footer hidden even though visitors receive the previous message. Disable editing during submission, or reconcile against the submitted values while preserving subsequent edits as dirty.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01CnAiFaUoKTFF6q9AB82BVD