Skip to content

fix(console, auth): one me/localization and a parse-time cookie session check on a cold load - #35575

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-35455-console-boot-chain
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-35455-console-boot-chain

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Refs #35455

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:首次在新设备打开控制台(尤其托管环境)时,少等一次服务器往返,"语言与地区"信息只向服务器要一次;页面内容和登录行为不变。
  • 为什么做:托管环境打开页面要 9–10 秒,云端的提速工作在等这一步;这是首屏串行请求专题的第一片。
  • 出错会怎样:最坏情况是首次打开时货币/时区格式晚一点出现,或登录状态需要多问一次服务器;直接撤回本次合并即可恢复原样。
  • 要你做什么:无。

What changes

Slice 1 of the card, under claim 7010912290 as amended by 7012236805: item 4, and item 2's get-session edge in the cold posture. Items 1 and 3 and the bundle -> packages -> ai/agents chain are out of this slice. Delay probes showed that chain is not a dependency (os-dev-report 7012178512).

  1. One me/localization per cold load (item 4). On a device's first visit, seedTenantLanguage() asks the endpoint before React mounts, and the request usually settles inside its 500 ms race. LocalizationFetchProvider mounts later, inside the app route. sharedGetJson shares only in-flight requests, so the provider asked a second time. The seed now holds its settled answer in a one-shot slot (takeSettledSeedAnswer in languageSeed.ts), keyed by the request (inflightGetKey) and the session-owner count. The provider's boot read takes it on its first attempt. The slot never holds an unauthenticated answer. An owner change answers null. The first take spends the slot whatever it finds, so a later mount and the re-read after a write to the user's own row ask the server. The seed rungs, the user's choice over the seed, stale-while-revalidate and the 500 ms race (ruling 6915665005, console: the tenant's server-side locale (/auth/me/localization) is fetched but never seeds the UI language — first login is always browser-or-en #5419 point 3) are untouched. On boots that already hold a seed, nothing changes: the seed does not fetch, and the provider revalidates as before.
  2. get-session no longer waits on the seed race when no Bearer is stored (item 2, cold posture). index.html's parse-time startEarlySessionCheck used to run only when a Bearer was stored. Without one, AuthProvider asked only after the mount, and the mount waits on main.tsx's gate, which includes the seed race. The script now also asks the cookie session's question: the same URL and credentials: 'include', with no Authorization header. preflightAuth() hands the answer on through the existing objectui.authPreflightSession slot with token: null. takePreflightSession takes a null-token slot only while no token is stored. A signed-out answer is handed on too, so AuthProvider settles signed out without asking again: a body naming no user, or the server's 401 UNAUTHENTICATED. That 401 is what this server actually answers an anonymous get-session with (measured). A handed-on signed-out answer runs the same signed-out purge loadSession runs. The Bearer path is unchanged: a stale Bearer's 401 is still purged, and nothing is handed on. The main.tsx boot order is unchanged (no edit there).
Layer table, before and after (showcase, built console, 3 loads x 2 pages x 2 postures)

Method, the same before and after: pnpm turbo build of the showcase closure and @object-ui/console in this tree, then packages/console/build-dist.sh, served by objectstack dev --fresh from examples/app-showcase on a private port. Headless Chromium 1440x900, a new context per load, Resource Timing from navigation to network idle plus 3 s. Layer = 1 + the deepest layer of any request that ended before it started. That is chain depth, so it counts client render gaps too. cold = session cookie only: no Bearer, no stored language, no seed (the card's posture). warm = cookie + the sign-in Bearer. Before: origin/main 9212119. Its boot files are byte-identical to this branch's base d76d57a; the commits between them touch only ApprovalsInboxPage. After: this branch at 58cd311. Shared 4-core box, so times are shared-box ms.

page / posture chain depth before after me/localization before after get-session before after
list cold 13 / 13 / 13 10 / 11 / 12 2 / 2 / 2 1 / 1 / 1 L3 (after me/localization) L1 (parse time)
record cold 13 / 14 / 14 13 / 13 / 14 2 / 2 / 2 1 / 1 / 1 L3 L1
list warm 13 / 12 / 13 12 / 8 / 11 2 / 2 / 2 1 / 1 / 1 L1 L1
record warm 12 / 14 / 13 11 / 12 / 11 2 / 2 / 2 1 / 1 / 1 L1 L1

Dependency chain to the first list data, cold: before, the hops were parse-time reads -> seed localization -> get-session -> meta/app -> bundle -> meta/view -> data (7). After, they are parse-time reads + get-session -> seed localization -> meta/app -> bundle -> meta/view -> data (6). The permission/app group now waits on the seed race (the mount gate), as it already did in the warm posture, and no longer waits on get-session.

Signed-out visitor, after: 3 loads of the list URL with no cookie each sent get-session x1 (parse time, cookie) and landed on /login with the password field drawn. Before, the code also sent x1 (AuthProvider alone; no token meant no parse-time request). An intermediate build of this branch that handed on only a 200 no-user body measured x3 here, which is why the 401 is handed on as signed out.

Tests

  • ui/apps/console/src/__tests__/localizationBootDedup.test.tsx: the old pin does not share once the request has settled pinned exactly the branch this removes (two requests), so it is replaced. One request when the seed settled before the mount, with a CONTROL that the seed is cached before any render (the locale before first paint). CONTROL: the hand-off is spent once, so a later mount asks. CONTROL: an unauthenticated seed answer is not handed over. CONTROL: an answer asked for the previous owner is not handed over.
  • ui/apps/console/src/LocalizationFetchProvider.test.tsx: a boot read answered by the hand-off still reads again after a write to the user's own row.
  • ui/apps/console/src/__tests__/sessionCheckBootDedup.test.tsx, new describe no stored token: the cookie session is asked at parse time and handed on. It covers six things:
    • The cookie question goes out in the same parse pass, with no Authorization header.
    • It is byte-equal to the preflight's own ask.
    • End to end: one get-session, signed in, the protected route renders, and the token is synced.
    • A 200 null answer is handed on as signed out: one get-session and the sign-in fallback.
    • A 401 UNAUTHENTICATED is handed on the same way.
    • CONTROLs: a non-OK answer hands nothing on and the protected route waits for AuthProvider's own read; a token stored since the question is not answered by it; with a Bearer, a 401 is still purged and nothing is handed on.
  • authPreflightCredentials-12892.test.ts: the no-token CONTROL now pins the cookie question (no Authorization header, nothing purged, slot token null).
Runs
  • Affected files under the verify lock on 58cd311 (the product code and tests as pushed; the last commit adds only the changeset): pnpm exec vitest run --maxWorkers=2 over the 13 console tests that import the boot modules, plus languageSeed.test.ts, LocalizationFetchProvider.test.tsx, all of packages/auth/src, http-inflight.test.ts and anonSeedScope-5746. Test Files 65 passed (65), Tests 641 passed (641), VERDICT command-exit 0.
  • pnpm --filter @object-ui/auth --filter @object-ui/console run type-check: both Done, VERDICT command-exit 0.
  • eslint over the 9 touched ts/tsx files: exit 0. The 24 warnings are pre-existing no-explicit-any in createAuthClient.ts.
  • pnpm --dir ui exec vitest run --maxWorkers=2 scripts/ (derived): 171 passed, 2 skipped, VERDICT command-exit 0. pnpm check:new-line-citations (ui): 0 new citations.
  • Ablation: none run. The pins' red direction is the pre-change behaviour, measured on the built console in the table above (me/localization 2, get-session at L3), and the replaced settled-not-shared pin asserted exactly that pre-change count of 2.

Acceptance notes

  • Fixture triage: blocked storage: no parse-time request spied on Storage.prototype.getItem, which this test environment's localStorage does not reach. Before this change the script's no-token early return made it pass regardless. With the cookie question it went red, so it now spies on the window's localStorage accessor, and it asserts that the access really throws before it asserts that nothing is sent.
  • The Done when of the card is not met by this slice (items 1 and 3 remain), hence Refs. The area files items 1 and 3 and the intermittent duplicate list-data read as child cards.
  • In the cold posture the pre-mount gate now also waits for the parse-time cookie get-session (already true for the Bearer posture). It normally settles before the bundle has evaluated, and the bundle evaluation itself takes 500+ ms.

Verification

Read first, by risk: ui/apps/console/src/lib/auth-preflight.ts (handOnCookieSession, the 401 branch of askSession); ui/packages/auth/src/createAuthClient.ts (takePreflightSession, the null-token arm); ui/apps/console/src/languageSeed.ts (takeSettledSeedAnswer, the spent flag).

Two minutes: cd ui && pnpm exec vitest run apps/console/src/__tests__/sessionCheckBootDedup.test.tsx apps/console/src/__tests__/localizationBootDedup.test.tsx. Expect both files green, 31 + 8 tests.


Generated by Claude Code

…a cold boot

The seed's settled authenticated answer is handed once to the localization
provider's boot read, and the parse-time session check asks the cookie
session's question when no Bearer is stored; the preflight hands that answer
on, a signed-out one included.

Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com>
… control reads headers

Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com>
…ly cookie session check

Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Final head for review · area ux-2 · 2026-11-19T16:20Z
Head: 58cd3111dd58ee4f1da022f216170ec6c8300131. All check runs on it concluded: 39 success, 13 skipped, 0 failed (the PR-side subset). K = 11 (< 15, no main merge owed).
Refs #35455 (slice 1 of the family card; claim 7010912290 as amended by 7012236805, option A) · Clause-②: no · Metadata-protocol: none · +480/−73 over 11 files. Not governed (0 of 11).
Scope: (item 4) the language seed's settled, authenticated me/localization answer is handed once to the boot read, keyed by request key and session-owner count, so a cold load sends it once (2 → 1 on 12/12 loads); (item 2, cold posture) index.html's parse-time session check also asks the cookie session's question with no Authorization header, and the preflight slot hands it on with token null, a signed-out answer (200 no-user or 401) included, so a signed-out visitor still sends one get-session. Unchanged: ruling 6915665005's seed rungs, the 500 ms race, the main.tsx boot order (not edited). Built console, 3 loads per cell: cold list chain depth 13/13/13 → 10/11/12; get-session L3 → L1 cold. Items 1 and 3 are child cards #35534 and #35535. Readings in os-dev-report 7014519204.
Review route: L1-a thread. The area lands it after the ACCEPT.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:控制台首次打开时少发一次语言请求,未存登录令牌的用户(用浏览器会话登录的)登录状态检查提前到页面一开始就发出,首屏更快。
  • 为什么做:以前登录检查要等语言请求结束才发,语言请求又重复发了两次,拖慢首次加载。
  • 出错会怎样:若判断出错,可能误显示登录页或沿用上一位用户的本地缓存;这次改动对已有令牌的情况保持原逻辑。
  • 要你做什么:无。区域补一个测试后再审,通过后自行落地。
  • 席位意见:改动方向和交接逻辑正确,但"上一位用户的缓存被清掉"这条新路径没有测试覆盖,需补上再落地。

席位核对

L1-a: REWORK, one item · head 58cd3111dd58ee4f1da022f216170ec6c8300131 · Refs #35455 · 2026-11-19T16:22Z · reviewed to pm-dispatch text at origin/main fca72dfa32

Readings, my own:

  • check-governed-merges --pr 35575: 0 of 11 paths governed.
  • merge-tree against main is clean. K=12.
  • CI: 39 success / 13 skipped / 0 failed. +480/−73.
  • The p1 claim (7010912290, 13:44Z) and its option-A amendment (7012236805) cover every path, and main.tsx is not edited.

The auth handover, read closely. Sound.

  • Parse-time script. With no stored token, index.html now asks get-session with credentials: 'include' and no Authorization header. That is the question AuthProvider would ask after mount. Blocked storage still sends nothing. With no token a 401 resolves to null (signed out); every other non-OK status rejects.
  • preflightAuth, Bearer branch: unchanged. It still purges on a stale token and hands on only a valid session.
  • preflightAuth, no-token branch (handOnCookieSession). It takes the early answer or asks again, and hands on { token: null, body } only for an OK or no-token-401 answer. Any other answer, and any network error, hands nothing on.
  • takePreflightSession. It compares slot.token || null against TokenStorage.get() || null, so a token-null answer is taken only while no token is stored. A Bearer slot still needs that exact token.
    • { user: null, session: null } is returned only for slot.token === null, so a Bearer slot naming no user still returns null and the provider asks.
    • A user answer still syncs session.token into TokenStorage, as getSession() does.
    • The function is not in the package barrel (index.ts exports createAuthClient and TokenStorage only), so the widened return type reaches only AuthProvider.
  • AuthProvider. A signed-out boot answer gives the first state user: null with isLoading: false and no mount read.
    • When SessionUserScope.current() !== null it calls purgeSignedOutClientCaches(), mirroring loadSession's conclusive-signed-out branch (line 230).
    • The preflight hands on only conclusive answers, so the sessionReadWasInconclusive guard has nothing to exclude here.
  • Not a contract face. No server path, no published export and no wire change: the request is the one AuthProvider already sent, now sent earlier. Clause-②: no holds, and no L2 is owed.

Localization hand-off: sound.

  • takeSettledSeedAnswer is spent on its first call whatever it finds.
  • It matches on inflightGetKey(url, init) and the session-owner count, and hands over a structuredClone.
  • The seed holds only an answer that is not authenticated: false and whose owner did not change while it was asked.
  • The provider offers it only to !reread && attempt === 0.
  • Pins, names grepped: the hand-off; spent once; unauthenticated not handed; previous owner not handed; a hand-off boot read still re-reads after a write.

R1 (required): pin the new signed-out boot purge. The bootSession?.user === null && SessionUserScope.current() !== null → purgeSignedOutClientCaches() branch in AuthProvider.tsx (line 388) is new. It is what keeps the previous user's client state off the sign-in page when a cookie session has expired on a shared browser. Before this PR that case ran through loadSession (line 230); now it never reaches there. The new sessionCheckBootDedup cells cover:

  • one get-session for the signed-in and signed-out answers and for the 401;
  • the Bearer-401 purge CONTROL;
  • the non-OK CONTROL;
  • the late-token CONTROL.

None of them adopts a prior SessionUserScope user before a signed-out handed answer and asserts the purge. Add that cell, with a CONTROL that a signed-out boot with no prior scope purges nothing. Ablate the branch to show the cell goes red. The re-review covers only that delta.

Measurements. From os-dev-report 7014519204, not re-run here:

  • me/localization 2 → 1 on 12/12 loads;
  • cold list depth 13/13/13 → 10/11/12;
  • get-session L3 → L1 cold;
  • a signed-out visitor at 1 get-session (3/3).

Wall time is in the noise, so the claim rests on counts and depth, as stated. The fixed vacuous blocked-storage spy is noted.

Declaration: agreed. Clause-②: no / Metadata-protocol: none / @object-ui/auth, @object-ui/console patch. Changeset sentences checked against the diff:

  • the seed hand-off: once, authenticated, current owner only, re-read after write still asks;
  • the cookie question without the header;
  • the null-token slot;
  • signed-out (no user, or 401) handed on;
  • "taken only while no token is stored";
  • the protected route still waits;
  • the seed race unchanged.

Routing. After R1, ux-2 sends the delta for re-review. It is not governed and has no contract face, so ux-2 lands it after ACCEPT.

…ent state

A handed-on signed-out answer (200 with no user, or the no-token 401)
never reaches loadSession, so AuthProvider's boot path runs the purge.
Pin it on a browser that held a user, and pin that a browser that never
held one purges nothing.

Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:与上一版相同:控制台首次打开少一次语言请求,未存令牌的用户登录检查提前发出,首屏更快。
  • 为什么做:上一轮审核要求补一个测试:共用电脑上前一位用户登录过期后,打开控制台时要清掉他留下的本地缓存。
  • 出错会怎样:本轮只加测试,不改代码;测试证明前一位用户的缓存会被清掉、没有前一位用户时什么也不清。
  • 要你做什么:无。区域自行落地。
  • 席位意见:补的测试正好覆盖要求的路径,并做了反向验证,可以落地。

席位核对

L1-a re-review: ACCEPT, R1 closed · head e38c6ca41a47391b324316b0454d762e016485ba (delta over 58cd3111, my REWORK 7015067802) · 2026-11-19T16:50Z

Readings, my own.

  • CI on this head: 39 success / 13 skipped / 0 failed.
  • K=14, so no merge is owed.
  • Delta: one commit, test-only, +63 lines in sessionCheckBootDedup.test.tsx. No source changed since the REWORK, so the rest of 7015067802 stands as read.

R1: closed. bootSignedOut(answer, priorUser) adopts a prior SessionUserScope user, or none, and seeds the following:

  • a per-user list-state key;
  • a metadata session key;
  • the device key vite-ui-theme.

It then runs the parse-time check and preflightAuth, and asserts two things before AuthProvider mounts:

  • the slot is filled;
  • nothing was purged yet.

After the mount it asserts the sign-in fallback, exactly one get-session and user: null. That single call is the parse-time one, so loadSession did not run, and any purge seen comes from the boot branch at AuthProvider.tsx:388.

The new cells:

  • it.each over both signed-out answers (200 no-user, 401 UNAUTHENTICATED), with a prior user u_alice: the per-user and metadata keys are gone, and the device key is kept.
  • CONTROL it.each, with no prior user: the scope stays null and both keys survive.

The ablation (the purge line removed: the 2 purge cells red, the 2 CONTROLs green) is from dev report 7015211755.

Routing. Not governed, no contract face, Clause-②: no. ux-2 lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Landing · area ux-2 · 2026-11-19T16:52Z

reading value
L1-a ACCEPT comment 7015833954 at head e38c6ca41a (= current head; R1 closed)
CI green at e38c6ca41a (39 success, 13 skipped, 0 failed); K = 14 (< 15)
check-governed-merges --pr 35575 NOT governed, 0 of 11 paths; +543 / −73; no L2 owed

State: draft → ready + auto-merge (merge queue). The PR says Refs #35455; #35455 stays open for its children #35534 and #35536.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants