Skip to content

perf(web): keep sign-in, the seek bar, and admin user code out of the launch bundle - #2246

Merged
Quick104 merged 3 commits into
mainfrom
perf/web-launch-bundle
Oct 10, 2026
Merged

Quick104 merged 3 commits into
mainfrom
perf/web-launch-bundle

Conversation

@Quick104

@Quick104 Quick104 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

The web app's launch bundle carried code most visits never run: the sign-in page, the seek bar, and the admin user module. Shared helpers pulled the last two in by import. Separately, CI failed any PR whose launch bundle moved more than 1 KiB from the number in web/perf-budget.json, so each size change needed a budget edit unrelated to the change.

This change moves that code out of the launch bundle and replaces the byte-count gate with a report. It affects web app load time for everyone and the CI workflow for contributors.

Approach

Launch bundle:

  • Login is now a lazy route, like the other auth pages.
  • formatTime moves from SeekBar.tsx to player/utils/formatTime.ts. Importers of formatTime no longer pull in the seek bar.
  • Admin session code imports adminAuthority instead of adminUsers, so the admin user module stays out of the launch path.
  • The codec-detection prewarm is a dynamic import. If it fails to load, the watch page imports the same module and probes on its own.
  • signedInBoot.test.tsx loads the Login module before each run, so the suspended route doesn't outlast the test's settle step.

CI:

  • budget:check still prints the launch bundle size. It now fails only when the React vendor chunk imports another chunk or index.html gains a cross-origin render-blocking resource. A config change can break those two silently, and a byte count can't tell a real regression from normal churn.
  • perf-budget.json and budget:update are removed, and the CI step and CONTRIBUTING.md are renamed to match.

Web only. No API, jellycompat, silo-apple, or silo-android impact.

Validation

  • tsc -b, pnpm run format:check on changed files, and ESLint on changed files pass. ESLint reports only warnings that already exist on lines this PR doesn't touch.
  • make test-web: 843 files, 7,287 tests pass.
  • pnpm run budget:check on production builds: the eager launch bundle drops from 322,316 to 303,444 brotli bytes, and the entry chunk from 204,469 to 185,596. The vendor chunk imports nothing, and index.html has no cross-origin render-blocking resources.
  • Built and served main and this branch with vite preview and opened /login: the sign-in page renders the same on both. The Login chunk, including the CommonJS react-qr-code package, loads and runs without console errors.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2246/

Risks

  • The sign-in page now loads as a separate chunk. Signed-out visitors see the routed loading fallback briefly before the form; on localhost, Login's first request started about 0.45 s after navigation, against about 0.1 s on main. A failed chunk fetch has the same failure mode as the other lazy auth routes.
  • The QR device sign-in flow was not exercised against a running server.
  • The vendor-react chunk hash changes once, because the lazy Login chunk needs a CommonJS interop helper from it. Browsers download React again on the next upgrade.
  • The byte-count gate is gone, so launch bundle growth no longer fails CI. The size stays in the CI log.
  • Anything outside this repository that calls pnpm run budget:update will break. Nothing in this repository calls it.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code (code, tests, bundle analysis, evidence), GitHub CLI (gh)
  • Model(s): claude-opus-5-5 (code, validation, and this revision of the description); claude-sonnet-5-5 (first draft of the description)
  • Involvement: AI-assisted
  • Adversarial review: n/a

Quick104 and others added 2 commits October 10, 2026 15:49
The bundle check failed whenever the eager launch bundle moved more than
1 KB from the number in web/perf-budget.json, in either direction. Pull
requests that grew it by less than that left the number alone, so main
drifted to the edge and the next unrelated change crossed it; editing a
lazy page also shifts the entry chunk by a few hundred bytes because it
lists lazy chunk hashes. The number was rewritten 16 times in 16 days,
mostly to match main.

The check now prints the eager size without failing on it. It still
fails when the React vendor chunk imports another chunk and when
index.html gains a cross-origin render-blocking resource. The pnpm
script keeps its name because PR CI runs main's copy of the workflow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… launch bundle

Every launch downloaded code that a signed-in Home never runs:

- The Login page and its QR code library. Login now loads like the other
  sign-in pages, behind the routed Suspense boundary.
- The full SeekBar component, which the persistent playback bar imported
  only for formatTime. formatTime moves to player/utils/formatTime.ts
  and every caller imports it from there.
- The codec detection module, which the shell only prewarms. The
  prewarmer now imports it dynamically; the watch page still probes on
  its own if the warm-up fails.
- The admin users API, which the admin sessions code reached only for
  three helpers re-exported from adminAuthority.ts. Those callers now
  import adminAuthority.ts directly.

The eager launch bundle drops from 322,326 to 303,365 brotli bytes, and
the entry chunk from 204,479 to 185,517. The boot request-budget test
preloads the Login module, since its settle loop waits on requests and
not on module imports. The vendor-react chunk hash changes once because
the lazy Login chunk needs a CommonJS interop helper for react-qr-code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T20:20:38.968589Z d8c9c9f New commits
🔒 Security Review ✅ Completed 2026-10-10T20:20:46.970326Z d8c9c9f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104 Quick104 added priority: P2 Limited scope, workaround exists, or polish impact: perf Unusable slowness on normal hardware labels Oct 10, 2026 — with Cursor
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8789e06e-5363-464d-a421-3f971ab10bd5

📥 Commits

Reviewing files that changed from the base of the PR and between ed04aa5 and d8c9c9f.


📒 Files selected for processing (2)
  • web/src/player/components/ChaptersMenu.tsx
  • web/src/player/components/SeekBar.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

The PR updates the web bundle checker, app loading, admin session authority checks, and playback time formatting.

Changes

Bundle checks

Layer / File(s) Summary
Bundle checker behavior
.github/workflows/trusted-linux-ci.yml, CONTRIBUTING.md, web/package.json, web/perf-budget.json, web/scripts/check-bundle-budget.mjs, web/scripts/check-bundle-budget.test.mjs
The checker reports bundle size without enforcing saved size or resource-count budgets. It checks vendor-chunk imports and fails for cross-origin render-blocking resources. Its tests and supporting descriptions change, and the update script and budget file are removed.

App loading

Layer / File(s) Summary
Lazy page and codec loading
web/src/App.tsx, web/src/test/signedInBoot.test.tsx
The Login page and codec-detection module load dynamically. The prewarmer ignores import or warm-up failures. The signed-in boot test imports Login before running.

Admin session authority

Layer / File(s) Summary
Admin session authority checks and scope
web/src/api/v2/adminSessions.ts, web/src/api/v2/adminSessionsCache.ts, web/src/hooks/queries/admin/stats.ts
Session-page requests check admin authority before and after each request. Session query keys use admin authority scope, and the fallback query context uses captureAdminAuthority().

Playback time formatting

Layer / File(s) Summary
Shared playback time formatter
web/src/player/utils/formatTime.ts, web/src/player/components/SeekBar.tsx, web/src/pages/audiobooks/player/MiniBar.tsx, web/src/pages/audiobooks/player/NowListening.tsx, web/src/playback/WatchPlaybackChrome.tsx, web/src/player/components/ChaptersMenu.tsx, web/src/player/components/MarkerEditPanel.tsx, web/src/player/components/PlayerControls.tsx
A shared utility formats playback time as m:ss or h:mm:ss. SeekBar and other playback components import the formatter from the utility module.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: rhainland


Merge Risk: ⚪ Minimal · up to d8c9c

The reviewed formatter change preserves current call sites, and no merge-blocking risk is evident.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the primary performance change: moving sign-in, seek-bar, and admin user code out of the launch bundle.
Description check Passed The description directly explains the launch-bundle changes, CI policy changes, validation results, risks, and affected areas.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR





🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Note

Grok commenting on Quick's behalf.

Ranked impact: perf, priority: P2: trims sign-in, seek bar, and admin user code from the launch bundle for every visit; nothing is broken today.

Scope note: replacing the byte-count budget gate with a report is a separate CI policy change from the code splitting (the description calls it "Separately"), so it may be worth its own PR if reviewers want to weigh it on its own.

# Conflicts:
#	web/src/player/components/ChaptersMenu.tsx
@Quick104
Quick104 merged commit e88f141 into main Oct 10, 2026
20 checks passed
@Quick104
Quick104 deleted the perf/web-launch-bundle branch October 10, 2026 20:24
blurbery added a commit to blurbery/silo-server that referenced this pull request Oct 13, 2026
…dle"

This branch only carried that commit so the web launch bundle budget check would pass. Silo-Server#2246 fixed the budget on main, so the change now stays in Silo-Server#2204 alone.

This reverts commit e954671.
Quick104 added a commit that referenced this pull request Oct 15, 2026
…ayed mark (#2217)

* fix(web): keep the download storage API out of the launch bundle

RealtimeEventsProvider loads with the app and imported
adminDownloadStorageRootKey from the download storage API module, which
pulled that whole module into the launch chunk. The key now lives in
adminDownloadStorageCache, as adminSessionsKey does, so the API stays in
the admin Downloads chunk.

The launch bundle drops from 326,619 B to 326,313 B brotli, back inside
the budget check's tolerance.

* fix(userstore): keep a played mark made in the same second as a removal

A history removal stores its watermark to the microsecond, but imported
progress and history were checked against it as whole-second RFC 3339
text. A played mark in the same second as an earlier removal compared at
or before the watermark and stayed hidden, while webhook sync recorded
the event as applied.

The Postgres store now compares imported writes with the watermark as
timestamptz, and watch state hands imported history to the store with
its full time. Imported history keeps its whole-second stamp unless that
second is at or before the watermark, so replays still match rows stored
before. SQLite keeps whole-second text and truncates sub-second input.

* fix(userstore): count imports in the same second as one play

An import that lands in a removal's second keeps its precise time, so an
exact-time duplicate check let the same play through twice when two
sources reported it a few milliseconds apart. Imported history now
treats any row in the same second as the same play, which also still
matches whole-second rows stored before. AddHistory inserts the time it
checked.

* test(userdb): check the error from closing the test database

* Revert "fix(web): keep the download storage API out of the launch bundle"

This branch only carried that commit so the web launch bundle budget check would pass. #2246 fixed the budget on main, so the change now stays in #2204 alone.

This reverts commit e954671.

---------

Co-authored-by: Quick104 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact: perf Unusable slowness on normal hardware priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant