Skip to content

perf(chat): Chat loads its dialogs and subpages when they open - #2623

Merged
k2b-cloud-agents[bot] merged 3 commits into
mainfrom
perf/pwa-chat-lazy
Nov 5, 2026
Merged

k2b-cloud-agents[bot] merged 3 commits into
mainfrom
perf/pwa-chat-lazy

Conversation

@k2b-cloud-agents

Copy link
Copy Markdown
Contributor

Chat currently downloads every dialog and secondary destination before its list, conversation and composer are usable. Load those destinations through importOnDemand() when they open, with immediate localized loading feedback and an inline retry after a failed download. Info retains its state when closed; deferred SSR seeds are discarded if a live invalidation arrives during download.

Narrow capability-contract imports remove YAML from the static graph. Zod remains because the browser uses it to validate API responses, messages and live events. Rare destinations render the same loading surface on the server and first client render, then consume their authorized SSR seed. Chat response compression stays unchanged.

Before / after

Same isolated production setup, fictional 3-chat fixture with 40 messages in the linked chat; phone Chromium 390×844@3, CPU 4×, RTT 150 ms, download 200,000 B/s. Times are medians of three runs on the shared VM. Each stack was cleaned up before the next measurement.

Metric Before After
Chat island entry, unpacked 841,920 B 486,732 B
Static Chat manifest closure, unpacked 1,656,362 B 1,264,263 B
Static closure, gzip / Brotli 530,105 / 445,085 B 406,655 / 353,725 B
Static closure files 40 36
Cold chat-link JS transfer / unpacked, whole page 476,495 / 1,699,093 B 388,054 / 1,317,190 B
Cold chat-link JS files, whole page 53 51
Chat-link HTML, decoded 125,808 B 118,991 B
Start → Chat first visit, interactive 4,692 ms 4,238 ms
Cold chat link, interactive 10,096 ms 7,951 ms
Median CLS 0 0

The sibling perf-baseline harness fix was not available, so these measurements reuse the report's production runtime, probe and phone profile. Deterministic manifest byte counts are the primary regression signal; VM timing varies. No shared island-budget mechanism exists on origin/main: the smallest Chat-local guard checks the actual production entry ≤500 KiB, its static closure ≤1280 KiB, and the static graph for dialog/subpage/YAML/dictation/picker regrowth.

Verification and parity

  • SSR and first-render parity: ChatWorkspace.render.test.tsx (37), pwa.page.render.test.ts (9).
  • Immediate loading, failure, retry, disposal and initial dialog focus: deferred behavior (4) and real chunk-download browser tests (4). The latter also cover live invalidation during loading and retained Info search.
  • Fixed dialog frame on desktop and phone through loading/error/recovery; six screenshots and measurement details.
  • Existing Channels (27), Threads (18), Search (6), For you (5), message mutations (8), notification settings (9) browser cases pass, one file at a time.
  • Focus/cancel/create (4), Info URLs/reload/Back/light/dark/EN/DE (10), personal list/history (4) focused browser cases pass.
  • Chat typecheck, both bundle guards, scoped Biome, nine relevant repository rules, documentation check (198 pages), production build and git diff --check pass.
  • Fresh Codex CLI reviews completed; verified findings fixed and covered by focused tests.
  • Real iOS, microphone recording and database integration were not run locally; CI owns the full suites.

No unrelated layout, history, reload, authentication or compression changes. No issue required for this single-commit performance change.

@k2b-cloud-agents
k2b-cloud-agents Bot added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@k2b-cloud-agents
k2b-cloud-agents Bot added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit d2524bb Nov 5, 2026
42 checks passed
@k2b-cloud-agents
k2b-cloud-agents Bot deleted the perf/pwa-chat-lazy branch November 5, 2026 03:15
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant