Skip to content

fix(web): keep the download storage API out of the launch bundle - #2204

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
blurbery:fix/web-launch-bundle-budget
Oct 14, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
blurbery:fix/web-launch-bundle-budget

Conversation

@blurbery

@blurbery blurbery commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #2203
Validation tasks: none

RealtimeEventsProvider, which loads with the app, takes adminDownloadStorageRootKey from api/v2/adminDownloadStorage.ts. That pulls the whole download storage API module into the launch chunk, even though only the admin Downloads page calls it. This change moves the key out, so the API goes back into the Downloads chunk.

I opened this when #2168 pushed main over the launch bundle budget (#2203). #2246 has since brought main back under it, so this no longer fixes a failing check. It now just trims 292 B brotli off the launch bundle.

Approach

  • The key now lives in api/v2/adminDownloadStorageCache.ts, the same way adminSessionsKey lives in adminSessionsCache.ts for the same provider. The provider and the storage query hooks import it from there, and the storage module no longer exports it.

Validation

  • Launch bundle, from the budget:check step in CI's Web (build) job:
  • CI on e201f76: every job passed.
  • On the original commit e954671: Vitest for the realtime provider, the storage API, the Downloads page and the downloads widget (58 tests) passed, tsc -b and Prettier were clean, and ESLint reported only the eight warnings RealtimeEventsProvider.tsx already has on main.

Evidence

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

The page has the budget check from CI and where the storage API lands in each build, measured before #2246; the Validation numbers above are current. Nothing a user sees changes: every page, the admin Downloads page included, behaves the same.

Risks

  • The query key's value is unchanged, so cached queries and realtime refreshes match as before.

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 (desktop app)
  • Tool(s): Claude Code; git, gh, pnpm (vite, vitest, tsc, eslint, prettier)
  • Model(s): claude-opus-5-5
  • Involvement: AI-assisted
  • Adversarial review: n/a, a small import move with no behaviour change

AI-assisted with Claude Opus. I directed the task and designed the work.

Note

Move adminDownloadStorageRootKey out of the download storage API module

Moves the admin download-storage root-key helper from adminDownloadStorage.ts into a new cache module, adminDownloadStorageCache.ts. This keeps the launch bundle from pulling the storage API module. The helper builds the same scoped query-key tuple as before; only imports change in RealtimeEventsProvider.tsx and downloadStorage.ts. No behavior change.

Macroscope summarized e201f76.

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.
@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 ⚠️ Failed 2026-10-10T07:26:50.313078Z e954671 PR opened
ℹ️ 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.

@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 ❌

@Quick104 Quick104 added priority: P1 Core-path bug; painful workaround — next after P0 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: 94a50254-07b3-4572-a96b-2d9fca106c03
📥 Commits

Reviewing files that changed from the base of the PR and between bf63b3d and e954671.

📒 Files selected for processing (4)
  • web/src/api/v2/adminDownloadStorage.ts
  • web/src/api/v2/adminDownloadStorageCache.ts
  • web/src/components/RealtimeEventsProvider.tsx
  • web/src/hooks/queries/admin/downloadStorage.ts

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

📝 Walkthrough
📝 Walkthrough

Walkthrough

The admin download-storage root query-key helper moved to adminDownloadStorageCache. The realtime events provider and admin download-storage query hook now import the helper from that module.

Changes

Admin download storage query key

Layer / File(s) Summary
Move and rewire the root query-key helper
web/src/api/v2/adminDownloadStorageCache.ts, web/src/api/v2/adminDownloadStorage.ts, web/src/components/RealtimeEventsProvider.tsx, web/src/hooks/queries/admin/downloadStorage.ts
The cache module now defines the root query-key helper using the download-storage key and authority scope. The old definition and its imports were removed from the API module. Both consumers now import the helper from the cache module.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor · Severity of issue fixed: Medium

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to e9546

The query-key relocation preserves the scoped key for in-repository callers, and the reported launch bundle remains within the CI check’s accepted tolerance. No actionable merge risk is evident.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #2203 requires the Web build bundle-budget check to pass, either by reducing the eager launch bundle or by raising the budget with a reason. This pull request moves adminDownloadStorageRootKey…
Out of Scope Changes check Passed The reviewed changes are limited to moving adminDownloadStorageRootKey and updating its two consumers. The new cache module preserves the query-key value and scope behavior. The reported validation …
Description check Passed The description clearly explains that moving adminDownloadStorageRootKey prevents the download storage API from entering the launch bundle while preserving behavior.
Title check Passed The title clearly and concisely states the main change: keeping the download storage API out of the launch bundle.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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.

blurbery added a commit to blurbery/silo-server that referenced this pull request Oct 10, 2026
…is green

Any change under scripts/ makes CI run the web jobs, and main fails the web
launch bundle budget until Silo-Server#2204 lands (Silo-Server#2203). This PR changes no web code,
so the pins wait for that. CI's Go DB pins job already ran all five
contracts on 88cfac0, whose code this commit leaves as it is, and they
passed.
blurbery added a commit to blurbery/silo-server that referenced this pull request Oct 10, 2026
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

Copy link
Copy Markdown
Contributor

Review of e201f76: I found no defects. The key keeps the same value, and the storage API no longer loads at launch.

What I checked

  • I built the web app for current main (f8b16ef) and for this branch merged into it, which merges cleanly. The eager launch bundle goes from 308,141 B to 307,823 B brotli, 318 B smaller. In the merged build, the storage request functions are only in the lazy AdminDownloads chunk. The downloads/storage strings left in the entry chunk belong to the generated operation-ID table that every route carries.
  • adminDownloadStorageRootKey has two importers, and both now use the new module. No test or vi.mock depends on the old export. The realtime refresh at RealtimeEventsProvider.tsx:867 schedules the root key without exact, so it still prefix-matches all five Downloads queries.
  • Vitest passed for the realtime provider, the storage API, the Downloads page, and the admin query hooks (90 files, 521 tests). tsc -b is clean.

Remaining issues: none.

Optional follow-up, outside this PR: the provider still imports the whole adminDownloadPreparations module, including listAdminDownloadPreparations and runAdminDownloadPreparationAction, just to get adminDownloadPreparationsKey. Since #2246, the bundle check reports the launch size without failing on it, so CI won't catch the next eager API import added here. Moving that key into a *Cache.ts module would fix the preparations case. A no-restricted-imports rule scoped to this provider would catch later ones.

#2203: since #2246 stopped CI from gating on the launch bundle size, the failure in #2203 no longer happens on main. The issue is still open, so a maintainer can close it. This PR lists it as related without closing it, which is correct.

Validated features: I couldn't read the v1.0 validation board from this session, so I haven't checked any passed cases against it. The diff changes no runtime behavior: the key value, its importers, and the refresh matching are all the same. I don't expect it to reach any validated case, and Validation tasks: none looks right, but I haven't confirmed that on the board.

User manual: unaffected, since nothing a user sees or configures changes.

Apple/Android: no follow-up needed. This changes only how the web app is bundled, not the API.

Fit: 9/10 · Readiness: 9/10 — ready

  • Fit: every web session downloads less at launch. The change splits the key from its API module the same way adminSessionsCache.ts and jellyfinStatusCache.ts already do, and adds no new surface.
  • Readiness: it moves code without changing behavior, and I verified it with a build, tests, and a typecheck against current main. The branch is 55 commits behind main but merges without conflicts.

Reviewed with Claude Code (claude-opus-5-5).

@Quick104
Quick104 merged commit 3b98a5e into Silo-Server:main Oct 14, 2026
20 checks passed
Quick104 pushed a commit that referenced this pull request Oct 15, 2026
…uring it (#2205)

* fix(autoscan): don't record a failed poll's error on a source reset during it

RecordError stamped last_error and last_run_at unconditionally. A poll
that was running when an admin repointed or reconfigured its source, and
that then failed, wrote the old server's error onto the source, and its
last_run_at stamp made the source wait out its interval before polling the
new upstream.

RecordError now takes the rows the poll read and writes only while they
still hold, using the same check AdvanceMarker uses: the source's marker,
connection binding and source_config, and the connection's upstream read
FOR SHARE. When they don't, the error stays on the poll's event only.

Closes #2202

* fix(autoscan): note a dropped error on the poll event and cover the review's cases

- The poll event says when a failed poll's error was kept off the source
  because an admin reset it during the poll, as a skipped marker advance
  already does.
- The shared write helper rejects a connection row that isn't the source's
  binding, for both AdvanceMarker and RecordError.
- docs/admin-api.md describes the failure path next to the success path.
- Tests: an API key rotation still records the error, each dropping edit
  is checked to have reset the source, a skipped write still finishes the
  event as an error holding the marker, and a resolve failure carries the
  connection row only when it was read. The AdvanceMarker stale-poll tests
  and the unknown-source test now run as DB contracts in CI.

* chore(ci): hold the autoscan DB contract pins until main's web build is green

Any change under scripts/ makes CI run the web jobs, and main fails the web
launch bundle budget until #2204 lands (#2203). This PR changes no web code,
so the pins wait for that. CI's Go DB pins job already ran all five
contracts on 88cfac0, whose code this commit leaves as it is, and they
passed.
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]>
@blurbery
blurbery deleted the fix/web-launch-bundle-budget branch November 6, 2026 00:01
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: P1 Core-path bug; painful workaround — next after P0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants