Repository navigation
fix(office): stop the layout destroying the URL on every deep link - #607
Conversation
Navigating to /office/applications landed on /office. Measured, not inferred — polling location.pathname through the load gives: before: ["/office/applications", "/office"] body still "Loading..." after: ["/office/applications"] board renders office/_layout.tsx returned early three times before its navigator: a Spinner while the role check resolved, and null when unauthorized or on a narrow viewport. Each unmounts the navigator, and expo-router responds by rewriting the URL to the nearest mounted segment. So every shareable office URL silently degraded to /office — including the per-application detail route added in #537, whose entire purpose is being linkable. Same failure class as the OAuth callback-hash loss fixed in #519, which is why (admin)/_layout.tsx already renders <Slot /> plus an overlay rather than returning around its navigator. This does the same: the navigator always mounts, the loading state is layered over it, and the hooks keep doing their own redirects. It only stops the URL being destroyed while they decide. Also registers applications/[applicationId]/index as a Stack.Screen. Only its /inquiry sibling was listed, so the #537 route had no entry at all — the same class of omission the comment above that list already describes. And the super-admin auth setup now writes its session the way the admin and user setups do: navigate, then page.evaluate. It used addInitScript, which runs on every origin — the session landed in the Stripe iframes (js.stripe.com, m.stripe.network) and never on localhost, so the saved state had no sb-*-auth-token for the app's own origin. It also wrote a wrapped { currentSession, expiresAt } payload where supabase-js stores the session flat. All three storage states now carry a valid token on http://localhost:8081. Verified against a running app: /office/applications keeps its URL and renders all seven kanban columns with the testIDs the helpers look for — kanban-column-new/screen/inquired/interview/offer/hired/rejected. That also settles #577: the selectors were never missing, the board had simply never rendered.
GET /v1/employer/applications authorised the caller against the organisation and then read the rows through RLS, which decides on a different axis. core.applications' policies recognise the organisation *owner*; a user holding an org `admin` role assignment — exactly who PIPELINE_ROLES exists to admit — passed authorisation and then read zero rows. Measured on the same 12 applications in one organisation: clay (owner) 12 visible zach (org admin) 0 visible GET /v1/employer/applications, as zach: total=0 The office kanban board rendered "0 total applications" for them. The board was not broken; the list was returning an empty set to an authorised user. The read now uses the service-role client, after the existing authorisation, exactly as attachStageHistory in this file and the EEO and scheduling routes already do for the same reason (#544). Verified after the change: clay (owner) total=12 zach (org admin) total=12 <- was 0 brian (admin of another org) total=3, only his own org's Cross-organisation isolation is unchanged: the authorisation step still bounds every query to listAccessibleOrganizationIds, and an admin of one organisation sees exactly that organisation's applications and no others. This is the fourth place the org-vs-team RLS mismatch has forced a service-role read. #544 remains the real fix.
|
Added a second commit, and it is the bigger of the two: The board was not broken — the API was returning an empty list to an authorised user
Measured on the same 12 applications in one organisation:
That is why the kanban board rendered "0 total applications". I found it because the board finally rendered (first commit) and was still empty. The read now uses the service-role client after the existing authorisation — the same escape hatch, for the same reason, that Cross-organisation isolation is unchanged: authorisation still bounds every query to This is the fourth place the org-vs-team RLS mismatch has forced a service-role read. #544 is the real fix; this is the fourth patch over it. Where the kanban spec got toIt now runs. Before this branch, all 20 tests died in the same I could not get a clean full run: the Expo dev server dies partway through, and 11 of the 20 failures in the last attempt were So the spec still does not go into |
A real product bug, found while finally getting the office e2e suite to run.
Every shareable office URL silently degraded to
/officeMeasured by polling
location.pathnamethrough the load:office/_layout.tsxreturned early three times before its navigator — aSpinnerwhile the role check resolved, andnullwhen unauthorized or on a narrow viewport. Each of those unmounts the navigator, and expo-router responds by rewriting the URL to the nearest mounted segment.So deep-linking to any office child lost its path. That includes the per-application detail route added in #537, whose entire purpose is being linkable — a recruiter sending a colleague a candidate URL would have landed them on
/office.Same failure class as the OAuth callback-hash loss fixed in #519, which is why
(admin)/_layout.tsxalready renders<Slot />plus an overlay instead of returning around its navigator. This does the same: navigator always mounted, loading state layered on top, hooks keep doing their own redirects.Two smaller fixes
applications/[applicationId]/indexhad noStack.Screenentry — only its/inquirysibling was registered, so the #537 route was missing from the list entirely. The comment above that list already documents this exact class of omission.The super-admin auth setup wrote its session where the app could not read it. It used
addInitScript, which runs on every origin — the session landed in the Stripe iframes (js.stripe.com,m.stripe.network) and never onlocalhost, so the saved state had nosb-*-auth-tokenfor the app's own origin. It also wrote a wrapped{ currentSession, expiresAt }payload where supabase-js stores the session flat. It now navigates thenpage.evaluates, matching the admin and user setups. All three storage states now carry a valid token onhttp://localhost:8081.This settles #577
With the URL surviving,
/office/applicationsrenders all seven kanban columns with exactly the testIDs the helpers look for:The selectors were never missing.
@scaffald/uihas emitted them all along; the board had simply never rendered in a test. My original #577 diagnosis was wrong and I have corrected it there.What is not verified here
I could not run the kanban spec to completion. Partway through this work the local
supabase_db_scaffaldcontainer disappeared andpnpm supa startnow fails at schema initialisation, so the app has no database. The evidence above was captured while the stack was still healthy — the URL sequences and the column list are real observations, not inferences — but the spec itself still needs a green run before any office spec goes intotestMatch(#553).CI has been unable to start jobs since ~00:28 UTC, so this carries local verification only:
tsc --noEmitclean for both files, and the browser observations above.