fix(1301): move ref access out of render in staff user edit route - #1314
Merged
Conversation
Collaborator
Author
|
Adversarial review r1 (tencent/hy3:free via Nous, high): APPROVED_WITH_FOLLOW_UPS, but the MAJOR is a user-facing regression — after a successful both-dirty save, the nav blocker can read a stale |
Characterization tests for the two during-render ref reads that #1301 will remove: knownProfileNamesRef (off-page label memory after deselection) and hasLoadedProfilesRef (no loading flash once profiles loaded). Green on the pre-fix implementation by design; the next commit flips the rule and fixes.
Enable oxlint react/refs as error for $userId-edit.tsx via a scoped override and remove every during-render ref access: - hasLoadedProfilesRef -> hasLoadedProfiles state - knownProfileNamesRef -> knownProfileNamesById state absorbed through React's documented adjust-state-during-render pattern with content-key guards so the store converges without effects or refs - hasSavedRef -> hasSaved state written in the submit event handler hydratedUserIdRef stays: it is only touched inside an effect. Zero behaviour change; the characterization tests from the previous commit pin the two ref-driven behaviours.
Round-1 review MAJOR: shouldBlockFn answered from render-frozen state (hasSaved flag + formState.isDirty). TanStack Router stacks every history.block closure and consults them all at navigation time, so a stale snapshot could show "Leave without saving?" right after a successful save redirected. Replace with module-level per-userId maps holding pristine hydration and last-saved snapshots, written only outside render (hydration effect, submit success before navigate) and read only inside the guard callback. Re-hydration invalidates the saved snapshot; staffUserEditValuesMatch() compares strictly field-by-field against saved-or-pristine baseline. Also harden catalogueSeenKey against render-time throws: derive it from stable row identities instead of JSON.stringify on the raw query payload (cyclic rows would throw during render). Add real-router regression test: mounts the actual route object under a real createRouter/createMemoryHistory so useBlocker registers into the genuine stacked-blockers pipeline. RED proof captured pre-fix in .dump/red-blocker.txt: redirect stuck behind confirm dialog until timeout while the still-blocks test passed on both versions.
radandevist
force-pushed
the
lane/wt-1301
branch
from
August 24, 2026 22:20
a2144ff to
78e1f88
Compare
radandevist
added a commit
that referenced
this pull request
Aug 24, 2026
- generate-route-tree.mjs: take develop's retired shim (#1300); the pinned-store generator path from this branch is obsolete under the new scripts/route-tree-generator.mjs layout. routeTree.gen.ts regenerated with develop's generator. - staff-users/$userId-edit.tsx: keep this branch's react-doctor component split, port develop's three file-level deltas onto it: * #1314 live-snapshot nav guard (module-level pristine/lastSaved maps, strict per-field equality) replacing the earlier render-frozen formState.isDirty && !hasSavedRef.current decision; hasSavedRef is dropped and hydration now writes the pristine snapshot in lockstep with reset() (develop parity) * #1314/#1301 adjust-state-during-render pattern for remembered profile labels and hasLoadedProfiles, replacing render-time ref reads * #1305 hoisted pending/error locals in the page gates * #1310 getUnsavedChangesStatus named extraction (publy/no-iife) - pnpm-lock.yaml: regenerated against merged manifests; srvx stays 0.12.7 for apps/front (this branch's fix), 0.11.16 unchanged for the API Proof on the merged tree: typecheck, just check-write, just react-doctor (files scope, --blocking warning), front vitest 220 files / 2393 tests — all green.
radandevist
added a commit
that referenced
this pull request
Aug 24, 2026
- $userId-edit.blocker.test.tsx (#1314 moved the edit route): adopt the branch's canonical widening helpers (widenOptions/addChildrenOf) and type the history.block shim straight off the bound method so it needs no assertion at all; QueryState.refetch returns Promise<void> like the real hook surface it stubs. - publy/no-iife (#1310) carried its own chained assertion inside unwrapCallee; one intersection assert names the missing ESTree member. - anti-slop/shared/lexical-type-parameters: the visitor-key record cast no longer compiles against the updated @oxlint/plugins typings; Reflect.get needs no cast and isNode narrows the result.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Merge keep-ours resolution would have silently dropped two real develop-side changes; re-apply them to the split modules: - staff user edit: #1314-r1 MAJOR nav-guard fix — blocker decides from module-level pristine/last-saved snapshots read LIVE at navigation time, replacing the render-frozen isDirty + hasSavedRef pair; the profiles-loaded gate becomes render-safe state (react/refs override) - tenant user row actions: extract dialog-copy IIFE for publy/no-iife Validated: tsc clean, oxlint clean (incl. react/refs override file), just check-write, just react-doctor, full front suite 2523 tests green.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
…hained-type-assertions, fix 73+126 violations (#1329) Closes #1330. Part of #1160. Anti-slop ladder rungs 4 and 5: `anti-slop/no-unknown-returns` and `anti-slop/no-chained-type-assertions` are enabled at `error` repo-wide and every baseline violation is genuinely fixed rather than hidden — 73 + 126 sites (plus the ones added to develop after the baseline: no-iife.ts, the #1314 blocker test): named return types instead of leaked `unknown`; assertion chains replaced by real narrowing (route-object widening removed, 41 faithful `createFileRoute` mocks, `Object.assign(new Error(…))` fake API errors, ts-morph `Node.isX` guards). No suppressions, no allowlist, no rule downgraded; `.oxlintrc.json` diff = the two rules flipped from off to error. Proof: rule-only config-copy scan → 0 at tip, baseline counts at base, probe offender flagged; `pnpm lint` 0 errors repo-wide; full front test + typecheck + shared-ts green; CI green at the reviewed tip including front-e2e 4/4 (the first push was red on develop-side violations and a missing linked issue — fixed in-PR after a rebase). Adversarial review (round 1): APPROVED_WITH_FOLLOW_UPS at ce483ea — nvidia/nemotron-3-ultra-550b-a55b:free (OpenRouter, effort max, jcode), cross-family; 15+ sampled sites verified as genuine narrowing. Follow-up tracked separately: two single `as never` casts added in tests fall outside both rules' scope. Implementer: Ox Alpha (stealth/ox-alpha via Nous Portal, effort max, jcode). Unverified: local e2e not run (CI front-e2e is the evidence).
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Merge keep-ours resolution would have silently dropped two real develop-side changes; re-apply them to the split modules: - staff user edit: #1314-r1 MAJOR nav-guard fix — blocker decides from module-level pristine/last-saved snapshots read LIVE at navigation time, replacing the render-frozen isDirty + hasSavedRef pair; the profiles-loaded gate becomes render-safe state (react/refs override) - tenant user row actions: extract dialog-copy IIFE for publy/no-iife Validated: tsc clean, oxlint clean (incl. react/refs override file), just check-write, just react-doctor, full front suite 2523 tests green.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
# react-doctor rung 1: re-enable `no-giant-component` Part of #1291 · Closes #1313 Model: Ox Alpha (stealth/ox-alpha via Nous Portal, max effort, jcode) ## What `apps/front/doctor.config.json` has carried three global rule kill-switches since #1247. This rung removes **exactly one line** — `"react-doctor/no-giant-component": "off"` — re-enabling the rule tree-wide at its default severity. No other config change (verified minimal diff). ## Why the config change is justified (per the guard-config review rule) The rule was turned off globally as a shortcut in #1247 because the `--scope files` gate inherits pre-existing debt in every touched file. Every offender is now split below the 300-line budget, so flipping the rule back on produces **zero findings tree-wide**: nothing pre-existing gets inherited by later PRs, which is what made the kill-switch necessary in the first place. ## Before / after | Measurement | Count | |---|---| | `no-giant-component` findings, rung-0 baseline (2026-08-24, react-doctor@0.9.12, full tree, default severity) | **16 / 16 files** | | Findings after this branch | **0** | | Local CI replica: `--scope files --base origin/develop --blocking warning --verbose` | green | ## Proof the rule actually runs Before the flip, a 315-line canary (`src/routes/authed/staff/_giant-canary.tsx`) was planted on the tree: the pinned 0.9.12 scanner flagged it immediately (`no-giant-component`, components must stay ≤300 lines). The canary was removed right after; nothing of it remains in this branch. ## The splits (11 commits, rebased onto current develop) - `data-table.tsx` → toolbar/pagination/empty-state parts - staff details trio (`profiles/$profileId`, `staff-users/$userId`, tenant `users/$userId`) → shared detail shells/views/lifecycle helpers - `tenants-new.tsx` / `$tenantId-edit.tsx` / `$tenantId.tsx` → form sections, stat rows, danger zone - `invitations.tsx` → route-search module (+test), filter-state, table wrapper, drawer hosts; **re-split after #1306 rewrote the page wholesale** (447 → 286 lines), dropping `_invitation-status-label.ts` as a byte-identical duplicate of the helper `_invitation-columns.tsx` already exports - `profiles.tsx` / `profiles/$profileId` tab pages → permission matrix, members card, identity header - `_assign-members-drawer.tsx`, `_profile-permissions-tab.tsx` → selection/list parts - `tenant/settings/general.tsx` → form field groups During conflict resolution, develop's parallel refactors (#1306, #1295, #1292) were preferred wherever they superseded ours; our extractions were re-applied only where develop's version still exceeded the budget. Bulk-action logic in `tenants/$tenantId/users.tsx` verified identical to develop's inline version before extraction. ## Round 1 fixes — what failed in e2e and why (d315142) An earlier DONE claim on `db5f815e2` was wrong: `front-e2e` shards 2–4 were RED with five failing specs: | Spec | Symptom | |---|---| | `parity-happy-path.spec.ts:221` | after clearing the staff-users search, only the filtered row remained; URL no longer had `q=` | | `staff-profiles.spec.ts:122` | same symptom — "Staff Owner" row not restored after clear | | `staff-tenants.spec.ts:201` | resetting the status filter did not restore "Acme Corporation" | | `staff-tenant-details.spec.ts:867` | level filter expected `disabled` during row selection, received `enabled` | | `table.spec.ts:150` | pager "Previous" did not return to page 1's row | **Root cause — one class for all five:** the DataTable split extracted grid/header children that read the TanStack table instance during render. That instance is mutable and identity-stable across renders, so under the React Compiler (active in production builds via `viteReact({ compiler: true })`, which is how e2e serves the app) `DataTable`'s JSX children were memoized: a parent-only re-render no longer re-executed their bodies. After a search clear, filter reset, or pagination move the page state and toolbar were fresh while the rows stayed frozen on the previous query's data. Plain vitest never reproduces this because unit transforms do not run the compiler pass — the repro required a compiler-enabled vitest config over the real components (fails exactly like CI without the directive, passes 43/43 with it). **Fix:** `'use no memo'` on `DataTable`, `DataTableGrid` and `DataTableHeaderRow`, each with a justification comment pointing at the full rationale in `data-table.tsx`. No test edits, no skips/retries/timeout changes; every component stays ≤300 lines. ## Resume/rebase (2026-08-25, merge commit 1ab3f51) The previous session died on a provider error mid-flight, leaving ~110 files staged from an **unfinished `git merge origin/develop`**. Resumed from disk instead of restarting: - Re-read every staged hunk: the staged tree was exactly the in-flight merge resolution porting develop's anti-slop rungs 4+5 (#1329), the `no-iife` conditional/logical callee peeling (#1332) and the real-route `<Trans>` render guard coverage (#1312) into this lane's split modules. Completed the merge commit `1ab3f5145` keeping BOTH parents (85e6037 × 301f2b8); the two loose files still in the worktree belonged to the same port and were folded in. Nothing half-finished was kept. - `.oxlintrc.json`: **tightening only** — `anti-slop/no-chained-type-assertions` and `anti-slop/no-unknown-returns` go `off` → `error`. No rule disabled or loosened anywhere. - The tightened rules surfaced 11 leftovers in modules only this lane has (split files with no develop counterpart). All fixed at root cause, no suppressions: mutation contracts retyped to named domain results (`GetStaffUserByIdResult`, the suspend/reactivate/remove result union) instead of `Promise<unknown>`; chained `as unknown as` casts replaced by single named widening points (`widenFake`, `componentOf`) or fully typed literals; the matchMedia test mock now builds a real `MediaQueryList` shape without an assertion chain. Verification, all re-run on the merge result: - `pnpm lint`: 0 errors with rungs 4+5 at error - `pnpm --filter front typecheck`: green - Full front unit/component suite: **235 files / 2530 tests green** (includes the design-system, z-index and React Compiler artifact guards) - `just react-doctor`: no findings tree-wide, `no-giant-component` blocking - `pnpm format`: clean; `just ci-drift`: green - e2e intentionally not run locally (verification policy); CI runs front-e2e 4/4 on this PR and that is the acceptance evidence ## Verification - `pnpm --filter front typecheck`: green - Full front unit/component suite (`pnpm --filter front test` under `heavy.sh` serialization): green - Full-tree react-doctor scan + local CI replica gate (`--scope files --base origin/develop --blocking warning`): green, exit 0 - Compiler-parity repro (temporary uncommitted vitest config with `compiler: true`): A/B proves the directive is load-bearing — 1 stale-row failure without it, 43/43 green with it - e2e intentionally not run locally (verification policy); CI runs front-e2e 4/4 on this PR and that is the acceptance evidence - develop moved repeatedly mid-flight (#1298, #1307, then #1305/#1306/#1310/#1314/#1328): merged forward each time. The last round did overlap (QueryDisplay contract, profiles dialog props, the `react/refs` override file, `no-iife`) and was absorbed by migrating our split pages to develop's patterns and re-porting develop's fixes into the split modules (`a36e04d4a`, `d9ed413ce`), keeping every component ≤300 lines - 2026-08-25: merged forward again over #1312/#1329/#1331/#1332 (see Resume/rebase above); all gates re-run green on `1ab3f5145` Two findings the scoped gate raised against our own extracted modules were fixed at root cause in this branch (no suppressions): the staff-user submit handler returned an explicit outcome instead of calling an injected `navigate()` outside a component, and `EditAccessSection`'s six boolean props collapsed into grouped query/pagination objects. ## Round 2 review fixes — suppression debt eliminated at root cause (2026-08-25) Round-1 review required: rebase onto current develop, zero net-added disable directives vs origin/develop, root-cause fixes only. Three gaps were real and are fixed: 1. **Five lane-introduced `eslint-disable` lines.** The earlier splits had *relocated* suppressions from develop files into the new modules (2× `exhaustive-deps` from `data-table.tsx` → `use-matched-breakpoints.ts`, 1× `no-unused-vars` from `data-table.tsx` → `column-display-meta.ts`, 1× `exhaustive-deps` from `tenants-new.tsx` → `_tenants-new-form.tsx`, 1× from the old giant `users.tsx` → `_assign-members-state-hook.ts`, 1× from `_profile-permissions-tab.tsx` → `_profile-permissions-save-hook.ts`). All five removed without any suppression: - `use-matched-breakpoints.ts`: both callbacks re-derive the breakpoint array from `key` (`key.split(',').map(Number)`), so `[key]` is a complete dep array. - `_tenants-new-form.tsx`: resolver memo deps completed to `[t, i18n.language]`. - `_assign-members-state-hook.ts` / `_profile-permissions-save-hook.ts`: effects already guard on their own bookkeeping refs, so deriving the id/key sets from the stable key string inside the effect (`rowAccountIdsKey.split(',')`, `grantedSignature.split(',')`) makes the arrays complete with identical behavior. 2. **Five navigate-in-render disables** (from round 1): URL writers wrapped in `useCallback`, which is exactly the lexical contract the rule checks; directives deleted. 3. **Stale base**: rebased again onto `d26a1f17b` (#1358, lint-ts/docs only, no overlap), 26 commits replayed cleanly. ### Directive parity proof (A/B vs origin/develop, `git diff origin/develop...HEAD -- apps/front/src`) | Direction | Lines matching `eslint-disable|react-doctor-disable` | |---|---| | Added | **0** | | Removed | **9** | ### Full-tree react-doctor A/B (pinned 0.9.12, dedicated pristine-develop worktree `/tmp/wt-develop`, both under `heavy.sh`) | Measurement | origin/develop | this branch | |---|---|---| | Files scanned | 655 | 749 | | Score | 66 / 100 | 73 / 100 | | Findings total | 48 | 41 | | Finding families | 20 | 17 | | `no-giant-component` | n/a (rule off in develop's config) | **0** (rule enabled by this PR) | Every family count on the branch is ≤ develop's; six families that exist on develop (boolean-prop-combos, pure-function-per-render, loading-flag-outside-finally, prop-callback-in-effect ×2, second parent-sync family, one unused-file/export pair) are gone on the branch. Remaining 41 findings across 17 families are pre-existing develop debt in files this PR does not touch (e.g. `_invite-user-drawer.tsx`, `_change-email-dialog.tsx`, `app-shell.tsx`, `marketing-header.tsx`, `use-hydrated.ts`, `broadcast-sync.ts`, `confirm-dialog.tsx`, `login.tsx`, `floating-selection-bar.tsx`, `offset-pagination.ts`, `field-checkbox-group.tsx`) plus the known untouched `tenants-new-helpers.ts` iterations family and `_profile-edit-details-drawer.tsx` (#1335, exists identically on develop). ### Gates, all re-run at the pushed tip - `just ci-front` under `heavy.sh`: **green** — 238 test files / 2563 tests, design-system/z-index/compiler-artifact guards included - Local CI replica `pnpm dlx react-doctor@0.9.12 --scope files --base origin/develop --blocking warning` under `heavy.sh`: **Scanned 126 files · Score 100/100 · No issues found**, exit 0 - `pnpm --filter front typecheck`: green - Targeted suites for every touched area during development: 168/168 (data-table, tenants-new, assign-members trio, permission matrix, profile details) - e2e intentionally not run locally (verification policy); CI runs front-e2e 4/4 on this PR and that is the acceptance evidence ### Post-push CI status (honest transcript, 2026-08-25 ~06:00Z) The `front e2e` **build job** fails on this PR's tip with an infrastructure error, not a diff error: after all four images build successfully, the step "Push stack images to GHCR" is denied with verbatim `denied: permission_denied: The requested installation does not exist.` — the runner's credential no longer has access to the personal namespace `ghcr.io/radandevist/publyapp-e2e`. A `--failed` re-run reproduced the identical denial. Two neighboring PRs hit the same step failure in the same window (05:32Z and 05:40Z), while one run at 05:34Z succeeded — the breakage started between 05:34Z and 05:46Z today and is shared across PRs. Nothing in this branch touches `.github/workflows` or image definitions; the fix belongs to the registry credential owner (restore the GitHub App/PAT installation for `ghcr.io/radandevist/publyapp-e2e`). Everything else is green: `just ci-front` (238 files / 2563 tests) re-run locally under `heavy.sh` at the pushed tip, `just ci-drift` green, typecheck green, scoped react-doctor CI replica 100/100. --- Implementer: Ox Alpha (Nous Portal, jcode, max effort). Reviews: r1 CHANGES_REQUIRED (suppression debt, false tree-wide claim), r2 APPROVED by hy3 (Go, last rung after the free chain) at ebbe48d: 0 suppressions added / 9 removed, react-doctor 0 no-giant-component tree-wide; tip 32d98c9 = ebbe48d + develop merge (update-branch after #1396); full CI green incl. front-e2e 4/4.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
Rebased onto develop carrying #1305/#1310/#1314. Fresh production build: 13 diagnostics across 9 files (was 12/8), 97 compiled client modules (was 96). Records both directions honestly: three try/finally handlers regressed under #1305 and are re-queued; $userId-edit.tsx, $tenantId-edit.tsx and half of _assign-members-drawer now compile or skip-free under the same restructures. Drops the erroneous __root row (its ref write was already effect-wrapped) and lists _profile-edit-details-drawer's suppression that the earlier inventory omitted.
radandevist
added a commit
that referenced
this pull request
Aug 25, 2026
…ventory (#1264) (#1326) Closes #1264 ## Summary Resolves every React Compiler compatibility follow-up queued in the #1234 skip inventory, then rebases onto a develop that advanced three times mid-flight (#1305, #1310, #1314, #1323/#1325 on the front side, plus API/scripts-only lanes). Regenerated against the final tree: **13 diagnostics across 9 files** (down from 36 across 20 when this branch started); **compiled client modules rise from 90 to 97** against the pinned floor of 72. Per item (one commit each, red/green evidence under `.dump/` by name): 1. **`useWatch()` in `_create-post-drawer.tsx`** — replaces the render-time `watch('body')` read (IncompatibleLibrary). 2. **Shared `useLanguageKeyedZodResolver` hook** — replaces the `[i18n.language]`-memoised resolver + eslint-disable pattern in 7 files (Suppression family). 3. **`profiles.tsx` / `profiles-new.tsx`** — latest-callback ref indirection collapsed to plain functions; ref writes moved out of handlers into an open-transition effect (probe-verified: ref writes inside a handler passed to the column factory taint it); `lastEditedProfileRef` became state. 4. **Big forms render-time ref reads** — `invitations/new.tsx`: known-profile-names map → state with idempotent effect folds plus synchronous per-render union of fresh rows; redirect timer → state-armed deadline owned by an effect; saved-flag re-baseline via synchronous form reset before navigate. (`staff-users/$userId-edit.tsx`, originally covered here too, was later superseded by develop's #1314 — see Rebase record.) 5. **Preserve-memo drops** — `$tenantId/users.tsx` + `invitations.tsx`: manual useCallback/useMemo wrappers deleted; the compiler caches per value. Plus an inventory refresh in `docs/guides/front/react-compiler.md` (every row dispositioned) and a gate commit clearing all react-doctor findings in touched files (HARD gate: findings must be fixed or suppressed with per-line rationale). ## Rebase record Three rebases onto a moving origin/develop. Each resolution kept both intents where they coexisted and preferred develop's implementation where it already superseded ours: 1. **Rebase 1 — `_profile-form-drawer.tsx`:** resolved to develop's side entirely. Develop's rewrite moved form ownership to the host page and deleted the very effects/suppressions our commit targeted; our hunk had nothing left to preserve. 2. **Rebase 2 (+#1310 no-iife, #1314 refs-out-of-render, #1323/#1325 DataTable exemption) — `staff-users/$userId-edit.tsx`:** took develop's side everywhere. #1314 implements our item 4 better (module-level snapshots written outside render, adjust-state-during-render absorption, snapshot-based nav blocker), and it untaints the submit closure our version left flagged. Our parallel item-4 work in `invitations/new.tsx` survives unchanged. 3. **Rebase 3 (+#1315 uploads, #1328 launcher — API/scripts only, zero front overlap):** completed clean after discarding a locally regenerated `routeTree.gen.ts` Register block (local toolchain artifact; committed versions intentionally lack it). Net effect on the skip inventory, recorded honestly in the refreshed doc: - **Fixed elsewhere:** `$userId-edit.tsx` now compiles outright (#1314); `$tenantId-edit.tsx`'s Refs diagnostic stopped firing after #1305's QueryDisplay restructure; one `_assign-members-drawer` suppression went quiet; the erroneous `__root.tsx` row (its ref write was already effect-wrapped) was dropped. - **Regressions owned:** #1305 reinstated try/finally in three handlers #1234 had fixed — `staff-users/$userId.tsx` (×2), tenant `users.tsx`, tenant `users/$userId.tsx`. They are re-queued in the inventory rather than papered over. - **Omission corrected:** `_profile-edit-details-drawer.tsx`'s exhaustive-deps suppression predates this refresh but was missing from the earlier inventory; it is now listed as an acceptable skip. ## Gates - Artifact guard on the final tree: **97 ≥ 72** compiled modules, runtime chunk present (`compiler-runtime-CNG2r3iR.js`), exit 0 (`check-react-compiler.mjs`) - Full front suite under the heavy lock, post-rebase: **220 files / 2393 tests passed**, exit 0 (evidence tail `.dump/rebase2-final-suite.log`); typecheck clean - Root lint gate (oxlint + disable-comment audit + frontend barrels) exit 0 · oxfmt check exit 0 · `just ci-drift` exit 0 - `react-doctor@0.9.12 --scope files --base origin/develop --blocking warning` exit 0 - Skip-inventory parser suite (`packages/scripts-ts`): 7/7 green - Design-system guard (611 files, 0 violations) and z-index guard (16311 candidates) green inside the suite run Implementer: Ox Alpha (stealth/ox-alpha via Nous Portal, max effort, jcode). Reviewer: pending adversarial review. ## Round 1 fix Review r1 (APPROVED_WITH_FOLLOW_UPS) flagged the added `react-doctor-disable-next-line` comments as guard-loosening residue of the clearing commit. Disposition, per the repo rule that added suppression comments are themselves a finding: - **Audited against origin/develop, not assumed.** A scratch worktree of origin/develop (@301f2b835) scanned with the pinned `react-doctor@0.9.12` shows the annotated effect patterns (open-transition resets, dirty-flag uplinks, click-handler navigate) ARE flagged on develop itself — genuinely pre-existing findings, not introduced by this diff. - **Kept only under the sanctioned exemption**, each now carrying an explicit per-line rationale (deliberate pattern + pre-existing on develop); `profiles.tsx` restores develop's own rationale block verbatim. No code changes: the fix commit is a comment-only diff. - **react-doctor before/after:** with the suppressions stripped entirely, `just react-doctor` (`--scope files --base origin/develop --blocking warning`) fails on those pre-existing findings surfaced in the touched files; with the rationales in place it exits 0 with zero new findings. Whole-repo score: develop 66 → this branch 68 (this PR's real fixes raise it; no regression). - **Re-validated after the fix:** production build + artifact guard (97 ≥ 72 compiled modules, runtime chunk present), full front suite under the heavy lock (exit 0), front typecheck, root lint, oxfmt check, `just ci-drift` — all exit 0. **Mid-flight develop advances handled:** the first fix push went red because origin/develop moved (#1329 anti-slop rungs 4+5 enabling `anti-slop/no-chained-type-assertions` at error, plus #1312/#1331/#1332); the merge-ref CI therefore flagged four chained-assertion sites in files this PR touches. Rebased onto origin/develop (clean, one overlapping file) and fixed them per #1329's own recipe — no suppressions, no config change: the resolver hook's `as unknown as` chain became a single cast seam, and the three `ROUTE_COMPONENTS` entries of `trans-render.guard.test.tsx` (pre-existing on develop) were narrowed via a local helper. That state went **fully green** in CI (`48a0d8c0a`: quality, react-doctor-gate, supply-chain, all four front-e2e shards). Develop then advanced again before merge: #1335 (staff profile edit surface) touched the same guard-test file with its own equivalent `routeComponentThunk` helper, and #1336 moved jobs code, leaving the PR CONFLICTING. Rebased once more; the sole conflict (`trans-render.guard.test.tsx`) was resolved to **develop's version verbatim** rather than keeping a second competing helper, so the top commit now reduces to the resolver-hook fix alone. That state went fully green locally and was pushed (`a7161537a`): CI came back green everywhere except one shard — `front-e2e (4/4)` died at 43 s inside the **Pull stack** step on a GHCR network timeout pulling the third-party `shopify/toxiproxy` image (`context deadline exceeded`), before a single test executed; the other three shards passed, so this was an infrastructure flake, not a diff regression. Meanwhile develop advanced yet again (#1343 adds the `publy/no-never-any-casts` rule, #1338 the NuGet-audit record — no file overlap with this PR). Final rebase onto that tip and full re-validation: root lint (both anti-slop rules active), front typecheck, oxfmt, `just react-doctor`, `just ci-drift` — all exit 0; targeted trans-render suite (27/27), production build with the artifact guard (97 ≥ 72 compiled modules), and the full front suite under the heavy lock — all green. Round 1 fix implementer: Ox Alpha (via Nous Portal, max effort, jcode). ## Round 2 fix Review r2 returned APPROVED_WITH_FOLLOW_UPS for exactly one reason: the round-1 fix had kept suppression comments where it could not immediately root-cause the finding. This round removes every added suppression by fixing the underlying pattern instead — zero suppression-type lines added vs origin/develop: - **`_change-email-dialog.tsx`** — the open-transition reset effect is gone, replaced by a keyed wrapper: an outer shell increments `sessionKey` on every closed→open transition and remounts a pure `Inner` form through `key`. A fresh mount initialises from `defaultValues` by construction, so no imperative reset exists at all. - **`_invite-user-drawer.tsx` / `_profile-edit-details-drawer.tsx`** — the dirty-flag uplink no longer compares watch-stream snapshots against a component-captured pristine baseline (the root of the `no-ref-initializer-runs-on-every-render`, `no-pass-live-state-to-parent` and `exhaustive-deps` findings). Dirtiness now comes from react-hook-form's own synchronous dirty computation (`control._getDirty`), which always answers "differs from the pristine session seed". The partial-failure reseed pins its baseline with `keepDefaultValues: true`, so retried failed rows still count as unsaved user data. The profile drawer keys sessions on `${sessionKey}:${profile.id}` so switching profiles remounts while a same-id refetch does not. - **`use-language-keyed-zod-resolver.ts`** — doc comment reworded so it no longer contains the literal text `eslint-disable-next-line react-hooks/exhaustive-deps -- [i18n.language]` (grep-proof pollution only, no behaviour change). **Suppression proof:** `git diff origin/develop --unified=0 | grep '^+' | grep -E 'react-doctor-disable|eslint-disable|@ts-expect-error'` returns **no matches** across the whole diff (transcript: `.dump/round2-suppression-proof.txt`; full-suite log tail: `.dump/round2-full-suite.log`). `react-doctor@0.9.12 --scope files --base origin/develop --blocking warning` exits 0 with **zero findings**. **Gates after round 2:** front typecheck clean; production build + artifact guard **97 ≥ 72** compiled modules with runtime chunk present; full front suite under the heavy lock **224 files / 2436 tests passed**; three targeted suites **35/35**; root lint gate (oxlint + disable-comment audit + barrels) exit 0; oxfmt check exit 0; `just ci-drift` exit 0. Round 2 implementer: ox-alpha (max effort, jcode). ## Unverified / blocked-by-infra - All non-e2e checks are green on ad6116f (17 pass). CI-side front-e2e (4 specs) has not run locally by design; on CI it is currently **blocked by an owner-level GitHub Packages problem, not by this diff**: the `Push stack images to GHCR` step fails deterministically (`permission_denied: The requested installation does not exist`) before any test executes — reproduced across 5 runs (initial + 3 reruns + 1 fresh run), while image-content-neutral lanes succeeded in the same window with the same actor. The `publyapp-e2e-*` container packages resolve with `"repository": null` (unlinked from this repo), so token-authenticated uploads of new layers are refused. Full transcript: `.dump/round2-front-e2e-infra-failure.txt`; tracked in #1397 for the owner. - API suites were not re-run: this branch touches no API code (front-only diff, verified via merge-base file list). ## Rebase after #1396 Develop merged #1396 (GHCR namespace + repo path repoint after the move to the PublyApp org) plus nine more commits (#1382/#1349, #1402, #1380, #1399/#1391 EF Core 10.0.11, #1351, #1358, #1355 specs, #1353), leaving this branch CONFLICTING again. Rebased onto `origin/develop` @ `f2811483a`; reviewed round-3 tip was `ad6116f97`, new tip is **`d7139e212`** (pushed with `--force-with-lease`). Exactly one conflict across the 14 rebased commits, in `docs/guides/front/react-compiler.md`: develop's side of the decision-vocabulary paragraph still pointed “follow-up” at #1264 as an open queue, while this lane's regenerated inventory (which auto-merged everywhere else in the same file) uses the post-#1264 vocabulary. Resolution keeps this lane's updated paragraph, verified against both sides in full before editing; no `--ours`/`--theirs` anywhere. #1396's workflow/package changes applied cleanly with no overlap. Lockfile untouched by develop, so no reinstall was needed. Full local re-validation on the new tip, all green: front typecheck exit 0; root lint gate (`just check-write`) exit 0; full front suite **224 files / 2263 tests passed** (exit 0); design-system guard 0 violations across 620 files; z-index guard OK; React Compiler artifact guard **97 ≥ 72** compiled modules with runtime chunk present. Full record: `.dump/rebase-report.md`. ## Rebase after #1396 again (#1385/#1381/#1360/#1403/#1318), tip 1b3abb1 Develop advanced again while the PR sat reviewed (#1385, #1381, #1360, #1403, #1318), leaving it CONFLICTING a third time. Rebased all 14 commits onto `origin/develop` @ `933319f3f`; reviewed tip `ad6116f97` → first-rebase tip `d7139e212` → **new tip `1b3abb19e`** (pushed with `--force-with-lease`). Five replay stops conflicted, all from develop's #1318 no-giant-component extraction of the giant staff forms; every resolution keeps both intents by taking develop's extracted structure and porting this PR's compiler work into its new home — no `--ours`/`--theirs` anywhere: - **Item 2 (language-keyed resolver):** `tenants-new.tsx` keeps develop's thin wrapper; the resolver-hook change moved into `_tenants-new-form.tsx` (manual `useMemo(zodResolver(...), [t, i18n.language])` → `useLanguageKeyedZodResolver`, max-seats ref-getter preserved). `$tenantId-edit.tsx` and `$tenantId/users/$userId-edit.tsx` keep develop's extracted-section bodies; import-level conflicts resolved to exactly what the merged bodies use (the hook import in, retired-inline-layout imports out). - **Item 3 (latest-callback collapse):** `profiles.tsx` keeps develop's thin page over `_use-profiles-list-state.ts`; the item-3 mechanics were ported into that hook — `lastEditedProfileRef` became render-read-safe **state**, the bypass re-arm + PUSH bookkeeping moved into an effect on the open transition, and the `openEditDrawerRef` indirection + columns `useMemo` were dropped for a plain handler handed straight to `makeTenantProfileColumns`. - **Items 4–5:** auto-merges verified intent-preserving (`profiles-new.tsx` hasSavedRef removal; plain handlers + unwrapped columns in `invitations.tsx`/`users.tsx`). - **Gate + review-r1 comment commits:** `profiles.tsx` conflicts resolved to develop's side — the one carried suppression targeted inline `openEditDrawer` calling `navigate()` directly, a pattern that no longer exists under the hook architecture (`openEditDrawer` now calls `pushSearch`), so there was nothing to suppress; the drawer files' “Pre-existing on develop” rationales merged cleanly. Full local re-validation on `1b3abb19e`: `pnpm install --frozen-lockfile` (develop had moved the lockfile), front typecheck exit 0, **full front suite green** (design-system guard 0 violations / 718 files, z-index guard OK, React Compiler artifact guard **97 ≥ 72** compiled modules with runtime chunk present — the ported work survives develop's refactor), `just check-write` exit 0, `just react-doctor` zero findings. Full record: `.dump/rebase-report.md`. Pushed CI on `1b3abb19e`: **all checks green** — 27 pass, spec-drift skipping as designed for a front-only diff (front-e2e 4/4 under the org namespace), zero failures. ## Rebase after #1396, final take (#1384/#1411), tip 6372398 — all green Develop moved again while take 1 was green in CI: #1384 (pristine-save guard + shared `resolveProfileSaveFailure`) rewrote exactly the tenant profile-edit drawer this PR refactors, plus #1411 (DLQ backend, no overlap). Rebased once more onto that tip; **new tip `6372398b3`** (`--force-with-lease`). Three replay stops conflicted, all in `_profile-edit-details-drawer.tsx`, all resolved keeping both intents: the gate/r1 comment conflicts keep develop's already-justified suppressions with r1's "pre-existing on develop" wording merged in; the round-2 conflict keeps #1384's new save/failure handling while restoring r2's render-phase `seededFor` reseed and event-driven `methods.watch` dirty uplink (zero suppressions introduced — net removal vs pre-#1384 develop). Local gates on `6372398b3`: typecheck exit 0; full front suite green (React Compiler artifact guard 97 ≥ 72 compiled modules); `just check-write` exit 0; `just react-doctor` zero findings. Lockfile untouched this time, no reinstall needed. Full record: `.dump/rebase-report.md`. Pushed CI on `6372398b3`: **all checks green** — 27 pass, spec-drift skipping as designed for a front-only diff (front-e2e 4/4 under the org namespace), zero failures; GitHub reports the branch **MERGEABLE**. --- Implementer: Ox Alpha (Nous Portal, jcode, max effort). Reviews: r1/r2 (free chain), r3 APPROVED at ad6116f, r4 APPROVED by tencent/hy3:free at 6372398 after three rebases onto develop (deltas attributable to #1318/#1385/#1384; 14-commit intent intact; 0 suppressions added); CI 27/27 green incl. front-e2e 4/4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1301
Summary
apps/front/src/routes/authed/staff/staff-users/$userId-edit.tsxemitted oxlintreact(refs)during-render warnings. This PR removes every during-render ref access with zero behaviour change:knownProfileNamesRef(read during render) →knownProfileNamesByIdstate, seeded lazily on first render and absorbed through React's documented adjust-state-during-render pattern with content-key guards, so the store converges without effects or refs.hasLoadedProfilesRef(read during render in the profiles-loading early return) →hasLoadedProfilesstate.hydratedUserIdRefis kept unchanged: it is only accessed inside an effect, which is allowed.Components remain function declarations; no class methods involved.
Round-1 review fixes (this update)
Round-1 verdict:
APPROVED_WITH_FOLLOW_UPS, one MAJOR blocking finding plus one NOTE. Both are fixed here:MAJOR — nav guard read render-frozen state across the save→redirect seam
shouldBlockFn: () => formState.isDirty && !hasSaveddecided from React render snapshots. TanStack Router'shistory.blockstacks every registered closure and consults them ALL at navigation time, so a closure registered on an earlier render kept answering with stale data exactly during the post-save redirect: a successful save could still show "Leave without saving?" (flushSynccannot help either — older stacked closures stay frozen regardless).Fix: the guard now decides from values readable LIVE at navigation time. Two module-level maps keyed by
userIdhold the pristine hydration snapshot and the last successfully saved snapshot:navigate());staffUserEditValuesMatch()does strict per-field equality against the saved-or-pristine baseline;NOTE —
catalogueSeenKeycould throw during renderThe seen-payload key was
JSON.stringify([isSuccess, profilesQuery.data?.data ?? null]). Serialising the raw query payload throws DURING RENDER if a catalogue row ever carries a cyclic value. It now derives from stable row identities (id+name), the same content the assigned-side key already uses — same loop-safety guarantee, no throw path.Regression test — real router, not a mocked blocker
New
apps/front/src/routes/authed/staff/staff-users/$userId-edit.blocker.test.tsxmounts the REAL$userId-editroute object (same module identity,.update()-mounted likerouteTree.gendoes) onto a throwaway tree with a realcreateRouter+createMemoryHistory, souseBlockerregisters into the genuine stacked-blockers pipeline. Only network-facing hooks/toasts/i18n are faked. Two tests:Paired red/green proof
Original ref-removal proof (excerpts from
.dump/red-green-proof.md, gitignored directory):$userId-edit.test.tsx= 29 passed (27 pre-existing + 2 new tests pinning the ref-driven behaviours: off-page label memory after deselection; no loading flash once profiles have loaded).react/refsenabled as error for the file,oxlint '$userId-edit.tsx'exits 1 with 5react(refs)findings.Round-1 blocker red-proof (captured in
.dump/red-blocker.txt, gitignored directory):$userId-edit.tsxonly), the real-router MAJOR test FAILS exactly as reviewed: the redirect never lands, the page stays behind the unsaved-changes confirm dialog until timeout; the companion still-blocks test keeps passing on both versions (the old code blocked correctly for the non-save case — proving the failure is specific to the save→redirect seam, not a harness artefact).Rule enforcement
react/refsis enabled as error for this exact file through a scoped.oxlintrc.jsonoverridesentry. No rule loosening anywhere: every other rule in the shared config is untouched, and no inline disable directive was added.Commits:
4a0ab35c7— test(1301): pin ref-driven profile-label memory and no-reload behaviourse63d5df08— fix(1301): move ref access out of render in staff user edit route78e1f88f7— fix(1301): decide nav guard from live values across save->redirect (round-1 review fixes)Gates run locally
$userId-edit.test.tsx+$userId-edit.blocker.test.tsx= 31/31 (re-run on the rebased tip)pnpm --filter front test) — exit 0 on the rebased tippnpm --filter front typecheck— cleanpnpm lint(oxlint quiet repo-wide + disables guard + barrels guard) — exit 0;npx oxlint '$userId-edit.tsx'exits 0 with the scoped override activepnpm format(oxfmt --check) — exit 0just ci-drift— exit 0Rebase after #1305
Rebased onto
origin/developata33ed361a(rebase chosen over merge: linear, small history). Conflicts touched exactly two files:apps/front/src/routes/authed/staff/staff-users/$userId-edit.tsx— one hunk, the pending gate. Resolution keeps BOTH intents: develop's QueryDisplay PR 2 hoisting of query flags into plain locals (detailsIsPending/assignedProfilesIsPending/profilesIsPending) AND this PR's replacement of the during-renderhasLoadedProfilesRef.currentread with thehasLoadedProfilesstate..oxlintrc.json— auto-merged cleanly (additive-merge file); this PR's scopedreact/refs: "error"override for the exact route file is intact, nothing else in the shared config changed.Post-rebase conformance with develop's new
publy/prefer-query-displayenforcement (#1305): the round-1 NOTE fix's catalogue seen-key readprofilesQuery.isSuccessdirectly inside a conditional, which the new rule flags. Re-expressed with develop's own hoisted-local idiom from the same file (const profilesIsSuccess = profilesQuery.isSuccess): identical values and behaviour, no disable directive, no rule loosening.npx oxlinton the route file is clean with the scoped override active.The resulting route file was re-read top to bottom: hooks single and ordered, one ladder only, no duplicate hooks, no leftover ladder, no ref read in render (
hydratedUserIdRefremains effect-only).Gates on the rebased tip: targeted suites 31/31 — including the r1 regression (both-dirty save → redirect lands with no "Leave without saving?") and both ref-behaviour pins — plus the full front suite, typecheck,
pnpm lint,pnpm format, andjust ci-drift; all green.Model line: Ox Alpha (stealth/ox-alpha via Nous Portal, max, jcode).
Unverified
just ci-e2e-front, docker compose test stack) were NOT run. CI runs front-e2e on the PR and that is the evidence for end-to-end behaviour.Model line: Ox Alpha (stealth/ox-alpha via Nous Portal, max, jcode).