Repository navigation
🤖 perf: add the static first-run view's early script as a server constant (T3 C step 2 PR 4a) - #6486
Conversation
… PR 4a) The early script (plan section 5.6) decides on "/" whether the static first-run view shows, and loads the app after it paints. These tests run the script string in happy-dom with a fake fetch, timers and frames: the shown path (both POSTs at once, bearer token, app two frames after the view, the 1 s abort as the only timer), every early-script row of the removal table, the paint-cache and hidden-tab skips with zero API calls, a tab hidden while the view waits, a failed module script, and the slashless no-op. They fail on main because firstRunView.ts has no FIRST_RUN_EARLY_SCRIPT and FIRST_RUN_TEMPLATE_ID yet. anthropic:claude-opus-5-5 high 346.60
…tant (T3 C step 2 PR 4a) FIRST_RUN_EARLY_SCRIPT in src/node/orpc/firstRunView.ts is the inline script PR 4b will put on the served "/" (plan section 5.6). Nothing serves it yet. With the paint-cache key set or a hidden tab it loads the app at once, with no API call. Else it POSTs the viewed splash list and the provider config together (URL or stored token, bearer), with one 1,000 ms abort, its only timer. A failure, a 401 or the abort loads the app with no view. When the wizard will open on its gateway step (not viewed, no configured provider, no gateway coupon), it clones the view from its <template> (waiting for DOMContentLoaded when the template is not parsed yet) and loads the app two frames later, or at once when the tab turns hidden. A module script that fails to load removes the view. The app is loaded once, from the #xum-pre-modules list that scripts/perf/firstLoadJs.ts also reads. The test file's element checks now compare to null in a boolean: a failing expect on an element dumped enough output to time out the run. A new test covers the DOMContentLoaded wait. anthropic:claude-opus-5-5 high 346.60
make static-check failed on the new test file: happy-dom's Event is not the DOM's Event for the Document-typed nodes (TS2769), the Function call was untyped (no-unsafe-call), and Array.fill gave any[]. The harness now types the script function, builds events through one cast, and narrows the window with a local. anthropic:claude-opus-5-5 high 346.60
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef8bc9fc2a
ℹ️ 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".
…a review) Codex round 1 on #6486: a missing or malformed module list threw inside loadApp after it was marked loaded, which left the static view up with no app behind it. loadApp now validates the list, and on failure it removes the view and logs the error. A new test covers it. The script's doc comment is shorter (the PR stays under 300 lines) and now says why a gateway coupon hides the view: it swaps the gateway step's panel. The stored-token check moved into the DOMContentLoaded test. anthropic:claude-opus-5-5 high 346.60
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e0667c5d6
ℹ️ 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".
…RL token (PR 4a review) Codex round 2 on #6486: - P1: on the paint-cache and hidden-tab paths the head script added the module script while the HTML still parsed. A dynamic module runs as soon as it loads, unlike the deferred tag it replaces, so main.tsx could run before #root existed. The modulepreloads still go in at once, and the module script now waits for DOMContentLoaded. - P2: the URL token is trimmed, and a blank one falls back to the stored token, as ManagedAPIProvider does (API.tsx:229-240). New test for the parse wait; the DOMContentLoaded test now also covers the blank URL token. The test harness and two comments are more compact, so the PR stays under 300 lines. anthropic:claude-opus-5-5 high 346.60
|
Readiness (perf owner, workspace 8e18f4aada): I am queuing this PR at I checked these facts myself:
Generated with |
Summary
Adds
FIRST_RUN_EARLY_SCRIPTandFIRST_RUN_TEMPLATE_IDtosrc/node/orpc/firstRunView.ts: the inline script that will decide on the served/whether the static first-run view shows, and that loads the app after the view paints. Nothing serves it in this PR. PR 4b injects it, together with the template, the module list and the redirect.Background
Option C step 2 of #5971 (plan section 5.6, PR 4a). #6444 added the view's markup, and #6445 defined the deferred module list (
<script type="application/json" id="xum-pre-modules">) that this script loads the app from.Implementation
The script, in order:
onboardingWizardViewedis"true") or hidden tab: load the app at once, with no API call and no view.api/splashScreens/getViewedSplashScreensandapi/providers/getConfigtogether, withAuthorization: Bearerfrom the trimmed?token=, or else the storedmux:auth-token(asManagedAPIProviderpicks it). OneAbortControlleraborts both after 1,000 ms, and that is the script's only timer.isConfigured === true, andmux-gateway.couponCodeSetis nottrue.<template id="xum-pre-template">(waiting forDOMContentLoadedif the template is not parsed yet), then load the app tworequestAnimationFrames later. If the tab turns hidden first, it loads the app at once, and it never inserts the view after the app has loaded."Load the app" runs once. It validates the list (a missing or malformed list removes the view and logs, because there is no app to load), then adds the list's modulepreload links at once, and the module script (both with
crossorigin) once the HTML is parsed: a dynamic module runs as soon as it loads, unlike the deferred tag it replaces, andmain.tsxneeds#root. The module script'serrorevent removes#xum-pre.The script has no request or user data in it, and it inserts the view from a template clone, never as HTML. PR 4b must place the module list before the script, because steps 2 and 4 load the app while the
<head>is still parsing.Validation
Tests (first commit,
src/node/orpc/firstRunView.test.ts, 15 tests now) run the shipped script string in happy-dom with a fakefetch, timers and frames. I applied each mutation in a scratch edit, saw the named test fail, and restored the file:?token=; an extrasetTimeout(loadApp, 5000)safety timerr.ok); the abort removed; thecatchremovedvisibilitychangelistenererrorlistenerreadyStatewaitJSON.parseof the list?token=%20and a stored token)readyStateisloadingThe tests fail on main because the two exports do not exist yet.
Gates on the perf host (files in
/home/coder/perf-runs/t3/c2-pr4a-gates/):src/node/orpc/firstRunView.test.tsmake check-react-compilermake crap-checkmake static-checktsgoprojects pass. The full ESLint run was OOM-killed on the shared host (cgroup full). ESLint on the two changed files passes, and CI's Static Checks covers the final headmake first-load-js, normal builds of baseb20d868fcfand headmake first-load-js, head built with base'ssrc/version.tspinneddist/sha256: onlynode/orpc/firstRunView.jsand.js.mapdifferDeferred to PR 4b
ONBOARDING_WIZARD_SPLASH_IDis a literal in the script (Codex round 1). This PR may touch onlyfirstRunView.tsand its test. PR 4b moves the splash id tosrc/common/constants/together with the module-list id (xum-pre-modules, a local constant here).VITE_BACKEND_URL), the script asks the servingxum server, not the configured backend. A wrong "no" keeps today's load. A wrong "yes" shows the view until PR 1's handoff removes it.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$346.60