toga-ai 1.0.404 → 1.0.405
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: session
|
|
3
|
+
slug: deployment-logout-guard
|
|
4
|
+
title: Force-logout-on-deployment guard for toga25-supply
|
|
5
|
+
author: apeterson
|
|
6
|
+
repos: [toga25-supply]
|
|
7
|
+
framework: "2.0"
|
|
8
|
+
client: shared
|
|
9
|
+
status: active
|
|
10
|
+
created: 2026-07-21
|
|
11
|
+
updated: 2026-07-21
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Session: deployment-logout-guard
|
|
15
|
+
**Date:** 2026-07-21
|
|
16
|
+
**Project/Repo:** toga25-supply (2.0)
|
|
17
|
+
**Task:** Port toga2-commerce's force-logout-on-core-parameter-change mechanism into toga25-supply so a large deployment forces all users to sign out and fully reset session/localStorage/React Query cache — with a smooth UX.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## What WORKED
|
|
22
|
+
<!-- Include specific file paths and evidence -->
|
|
23
|
+
- Reviewed the reference mechanism in `toga2-commerce/src/contexts/AuthContext.tsx`: polls Core parameter `META_LAST_REFRESH_DATETIME` via `/core-parameters`, stores the login-time value as a baseline, and on any later differing fetch calls `logout()` + hard-redirects to `/`.
|
|
24
|
+
- Created `toga25-supply/src/hooks/useDeploymentGuard.tsx` — a `useQuery` (enabled while authenticated, `staleTime:0`, `refetchOnWindowFocus:true`, `refetchInterval` 5min) reading `apiGet("/core-parameters", { fields:["value"], key:"META_LAST_REFRESH_DATETIME" })` → `response.data.coreParameters` (array-or-object tolerant). Baseline stored in localStorage key `deployment-version`; first observation sets it (no logout), a later mismatch triggers reset. Exports render-nothing `<DeploymentGuard />`.
|
|
25
|
+
- Smooth UX: on mismatch shows a non-dismissing info toast ("A new version is available — signing you out briefly…") and waits 2.5s before calling `logout()`.
|
|
26
|
+
- Wired `<DeploymentGuard />` into `toga25-supply/src/App.tsx` inside the `AuthProvider`/`ToasterProvider`/`ThemeProvider` tree (both `useAuth` and `useToaster` resolve).
|
|
27
|
+
- Confirmed the existing `AuthContext.logout()` (lines 80–90) already does `performLogout()` + `clearUser()` + `localStorage.clear()` + `queryClient.clear()` — so the entire localStorage (tokens, `zu-user`, `zu-hostname`, persisted `supply-chain-query-cache`, and the `deployment-version` baseline) is wiped. User confirmed this full-clear behavior is what they want.
|
|
28
|
+
- `npx tsc --noEmit` — no errors in the changed files (`useDeploymentGuard.tsx`, `App.tsx`).
|
|
29
|
+
- Captured to team KB: new doc `knowledge/2.0/apps/toga25-supply/features/force-logout-on-deployment.md`, PUSHED to `_main`.
|
|
30
|
+
|
|
31
|
+
## What did NOT work — DO NOT RETRY THESE
|
|
32
|
+
<!-- Exact failure reasons — do not vague-ify -->
|
|
33
|
+
- (none — no failed approaches this session.)
|
|
34
|
+
|
|
35
|
+
## Not tried yet (candidates for next session)
|
|
36
|
+
- Live verification against a real API response that `response.data.coreParameters[0].value` is populated for this client, and that the `key` shorthand option (vs a `where` clause) is honored by this environment's `/core-parameters` endpoint. If `key` is not supported, switch the fetch to `where: { and: [{ "CoreParameters.key": { "=": "META_LAST_REFRESH_DATETIME" } }] }`.
|
|
37
|
+
- End-to-end manual test: log in, bump `META_LAST_REFRESH_DATETIME` server-side, confirm the toast appears and the user is signed out + everything reset, and that re-login re-establishes the baseline without a logout loop.
|
|
38
|
+
|
|
39
|
+
## Current file state
|
|
40
|
+
| File | Status | Notes |
|
|
41
|
+
|------|--------|-------|
|
|
42
|
+
| `toga25-supply/src/hooks/useDeploymentGuard.tsx` | Created | Deployment watch hook + `DeploymentGuard` component. Complete, type-checks clean. |
|
|
43
|
+
| `toga25-supply/src/App.tsx` | Modified | Added import of `DeploymentGuard` and rendered `<DeploymentGuard />` above `<AppRouter />` inside the provider tree. |
|
|
44
|
+
| `toga-tech/knowledge/2.0/apps/toga25-supply/features/force-logout-on-deployment.md` | Created (pushed) | Feature doc, owner `apeterson`, pushed to `_main`. |
|
|
45
|
+
|
|
46
|
+
## Decisions made
|
|
47
|
+
- **Reuse the centralized `logout()` rather than a bespoke reset path.** It already clears all localStorage + React Query cache + redirects, matching the "reset everything" intent. Rejected: writing a separate partial cache-clear (wouldn't reset session as required).
|
|
48
|
+
- **Do NOT preserve the baseline across logout (simpler than commerce).** Because `logout()` clears the baseline and hard-reloads, the next login's first fetch re-establishes it and the mismatch check is skipped when no baseline exists → no logout loop. Rejected commerce's write-new-value-before-logout dance as unnecessary here.
|
|
49
|
+
- **2.5s toast delay before logout** for a smooth, explained sign-out instead of an abrupt kick. Rejected instant logout (jarring) and history-patching navigation refetch from commerce (fragile) in favor of `refetchOnWindowFocus` + 5min interval.
|
|
50
|
+
|
|
51
|
+
## Blockers
|
|
52
|
+
none
|
|
53
|
+
|
|
54
|
+
## Exact next step
|
|
55
|
+
> Manually verify against a live/beta API: log in to toga25-supply, confirm the first `/core-parameters` fetch populates `response.data.coreParameters[].value`; if the `key` shorthand returns nothing, change the `fetchDeploymentVersion` options in `src/hooks/useDeploymentGuard.tsx` to a `where` clause on `CoreParameters.key`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
_Saved by /session-save on 2026-07-21_
|
package/package.json
CHANGED