perf(ui): collapse the post-login first-load resolution chain and warm the agent base - #16907
Merged
lalalune merged 3 commits intoJul 23, 2026
Merged
Conversation
…m the agent base The canary's post-token first load on staging serializes a status probe (/api/v1/user, ~0.8s) -> /api/v1/eliza/agents (~1.8s) -> bind -> cold agent-base /api/auth/me (~2.3s) before the composer is usable (FIRSTLOAD-REAL-2026-07-22 trace: firstLoadMs 4.9-7.0s, phase stall first-run-required -> starting-runtime ~10s). Three chain cuts in listOrAutoProvisionCloudAgent / bindCloudAgent: - A stored bearer skips the getCloudStatus (/api/v1/user) probe: the agents list IS the connectivity probe, and its result is reused as knownAgents for the bind, so the list is fetched exactly once. A failed list falls back to the status probe + login re-entry (stale-token semantics unchanged). - After handleCloudLogin lands a bearer there is no post-login status re-probe: the old probe's result was overridden by the token check anyway. The probe still runs when no token landed. - The bind fires a fire-and-forget listConversations on the just-bound agent base so the cold container/worker wake overlaps persist + coordinator transitions + auth/me instead of serializing behind them; the hydrate-phase fetch stays authoritative. Structural regression test (no timing assertions): one list fetch and zero status probes on the bearer path, knownAgents reuse, no post-login re-probe, stale-token degrade, warm-up fired / non-blocking / optional. Conductor test updated: the popup pre-open test now clears the stored bearer its beforeEach plants, since a usable stored token short-circuits login before any popup (which is the point of the fast path). Co-authored-by: shadow <shadow@shad0w.xyz>
…icy ratchet) Co-authored-by: shadow <shadow@shad0w.xyz>
0xSolace
force-pushed
the
sol/firstload-resolution-chain
branch
from
July 23, 2026 04:19
5d28f9e to
cc199ec
Compare
…the structural call-shape assertions correctly The test-realness audit's line heuristic flags expect(*mock*).toHaveBeenCalled* regardless of what the test proves. These assertions ARE the contract here — the invariant is the request SHAPE (0 status probes / 1 list fetch / warm-up fired), asserted alongside outcome checks. Rename the stub bindings so the heuristic scopes correctly; no behavioral change. Co-authored-by: shadow <shadow@shad0w.xyz>
Member
|
Reviewed + adversarially re-verified: the removed post-login /api/v1/user probe result was genuinely dead (overridden by getCloudAuthToken), knownAgents reuse plumbing verified end-to-end on develop, listConversations warm-up is read-only/optional-chained, base blobs match current develop head (post-6f93b6a3da, no overlap with the startup auth prime gate). All checks green at verification. Squash-merging. [pr-queue-review] |
4 tasks
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.
The stall (fresh staging trace, 2026-07-22, build 050b263-era staging
11353ad7)The demo path's post-login first load is a SERIAL resolution chain. Live canary-boundary trace (real CLI-session sign-in on
app-staging.elizacloud.ai, renderer startup marks #9565 + network timings):/api/v1/user(status probe)/api/v1/eliza/agents/api/auth/mefirstLoadMs)Coordinator phase
first-run-required → starting-runtimemeasured 9.9–10.4s across runs (includes the popup/session mint). Hydration itself is already off the critical path (#16885 pins it); this PR attacks the chain the F2-port receipts flagged as the real stall (FIRSTLOAD-REAL-2026-07-22).Three chain cuts (
listOrAutoProvisionCloudAgent/bindCloudAgent)getCloudStatus(→/api/v1/user) ran before the agents list on every silent cloud entry. With a stored bearer, the agents list itself is the authoritative connectivity probe — and it's the data the bind needs anyway. Fetch it immediately and reuse it asknownAgentsforselectOrProvisionCloudAgent, so the list is fetched exactly once (previously twice: once here, once inside the provisioning call). A failed list falls back to the status probe + login re-entry, so a stale/revoked token keeps the exact legacy recovery semantics.handleCloudLogin, the old code probed status again — and then overrode the result withgetCloudAuthToken(client)anyway. The landed bearer IS the proof; the probe now runs only when no token landed (server-side-key logins), where its result still decides the outcome.persist → coordinator transitions → /api/auth/me. The bind now fires a fire-and-forgetlistConversationson the just-bound base so that cold cost overlaps the phases between bind and hydrate; the hydrate-phase fetch remains authoritative, failures are irrelevant, and client shims without the chat surface no-op.Regression test — structural, not timing-based
first-run-finish.firstload-chain.test.ts(7 tests), pinning the shape so it can't flake:knownAgentsreuse verified on the provisioning callneeds-cloud-loginpreserved when neither token nor probe succeedOne existing conductor test updated (
pre-opens the Cloud auth window…): its suite-levelbeforeEachplants a stored bearer, which now correctly short-circuits login before any popup — the test clears it, since the popup path is only reachable when login is genuinely needed.Verification
packages/uifirst-run suite: 27 files / 346 tests green (includes the reused-shared-handoff contract suite over the edited function)useCloudStatesame-tab + stale-login suites, hydrate-nonblocking (test(ui): non-blocking startup hydration invariant — first usable load (first-5 strike F2 port) #16885),App.chat-overlay-first-run: greenbunx tsc --noEmit(ui): clean · biome: cleanfirst-run-finish.ts(4/7 fail: status-probe counts + warm-up), passes with itCoordination
packages/uifirst-run/bind).Expected canary movement: removes ~2.6s of serial round trips from
firstLoadMsand overlaps the ~2.3s cold agent-base wake; targets the stagingloadbudget ≤5s.Receipts:
projects/eliza-fleet/FIRSTLOAD-REAL-2026-07-22.md(trace before/after + method).[sol-firstload-real]
Evidence Gate
N/A - no visual surface change; pure .ts startup-flow logic (no .tsx/.css touched). The "before" is the network trace below.N/A - no visual surface change; acceptance is the staging canary firstLoadMs budget post-deploy.N/A - no user-visible flow change; identical screens, fewer serial round trips behind them.N/A - no backend/server code changed; client-side request-ordering only.req=11831 res=12590 200 GET /api/v1/user(status probe ~0.8s, removed on bearer path) →req=12591 res=14382 200 GET /api/v1/eliza/agents(~1.8s, now the probe itself, fetched once + reused as knownAgents) →req=14424 res=16742 200 GET <agent>.staging.elizacloud.ai/api/auth/me(~2.3s cold wake, now overlapped by the bind warm-up) → composer usable at 16792 (firstLoadMs 4930ms). Full JSON trace + renderer startup marks archived in the fleet lane receipt (domain-artifacts row). Structural after-proof:first-run-finish.firstload-chain.test.ts7/7 green, 4/7 fail against the unpatched module.N/A - no agent/action/provider/prompt/model change; UI startup resolution order only.projects/eliza-fleet/FIRSTLOAD-REAL-2026-07-22.md(workspace, referenced from Discussion 🤖 Agent Fleet — Coordination HQ (guidelines + standup) #14308); probe script is the F2-port trace probe (Playwright vs https://app-staging.elizacloud.ai) with per-request issue timestamps. No DB/wallet/generated-file artifacts apply to a client request-ordering change.