Skip to content

fix(web): keep a device override saved while its reset was answering - #5619

Open
rangoDJ wants to merge 6 commits into
Silo-Server:mainfrom
rangoDJ:fix/5522-device-reset-keeps-newer-save
Open

rangoDJ wants to merge 6 commits into
Silo-Server:mainfrom
rangoDJ:fix/5522-device-reset-keeps-newer-save

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: none. Merge order: none. Follows #5408 (merged), whose 404 handling this keeps.

Problem

Closes #5522
Validation tasks: none

Other clients: Apple N/A, Android N/A, Roku N/A (web admin cache only)

In Admin › Devices, a device override reset removes its row from the cached settings list when the delete settles. The removal matches rows by scope, profile, device and key. If a save on the same override was sent while the reset was still answering, and the reset's answer (204, or 404 since #5408) arrived after the save settled, the reset removed the saved row. The server keeps the saved value, but the list shows the override as gone until a refetch answers, and a reopened subtitle appearance editor starts from the inherited value.

Approach

Reworked after review: the admin setting writes are queued instead of ordered by revision numbers.

  • The five admin setting write hooks in web/src/hooks/queries/admin/users.ts (useUpdateAdminUserDeviceSetting, useDeleteAdminUserDeviceSetting, useDeleteAllAdminUserDeviceSettingsForDevice, useUpdateAdminUserSetting and useDeleteAdminUserSetting) share one TanStack Query mutation scope, as useSaveAdminDashboardLayout does. A save made while a reset is pending is sent only after the reset has answered and dropped its row, so the saved row stays.
  • The offline check in settingWriteOptions runs when a write is queued. A queued write now checks again when it is sent, so a write made online is still refused unsent if the connection dropped while it waited. The check sits in the two write calls (setAdminSettingValue, deleteAdminSettingValue), which the new adminSettingWrites.ts wraps along with the shared options. Only these hooks call them.
  • The earlier version's removedSettingRows.ts, which worked out the server's order from revision numbers, is gone. users.ts keeps main's row removal and is 796 lines, under its 800-line limit.
  • Costs: one slow write holds the ones behind it, since writes have no client deadline, and a queued write waits while the tab is hidden.

Validation

  • New in adminSettingWrites.test.tsx, next to the module it tests (deviceOverrideWrite.test.tsx is at its 800-line limit and is unchanged):
    • sends a device override save made during its reset once the reset answers, for one override and for reset-all. It holds the DELETE, makes a save, checks that no PUT goes out while the DELETE is unanswered, then releases the DELETE. It checks the PUT went out after it and that the cached list holds the saved row.
    • refuses a queued device override save when the connection drops while it waits: the save is queued online, the browser goes offline before the reset answers, and the save fails with SettingWriteOfflineError without a PUT.
  • All three fail with main's users.ts (output under Evidence) and pass with this change.
  • vitest run src/hooks/queries/admin passes, 44 files and 259 tests. tsc --noEmit, eslint and prettier on the changed files are clean.
  • Not tested: the race in a browser against a real server.

Evidence

No screen changes in the usual case. Hook test results for vitest run src/hooks/queries/admin/adminSettingWrites.test.tsx on web/:

Before (users.ts from main):

   × sends a device override save made during its reset once the reset answers (one override) 245ms
   × sends a device override save made during its reset once the reset answers (every override for the profile) 207ms
   × refuses a queued device override save when the connection drops while it waits 164ms
AssertionError: expected [ 'DELETE', 'PUT' ] to deeply equal [ 'DELETE' ]
AssertionError: expected { …(9) } to be an instance of SettingWriteOfflineError
      Tests  3 failed (3)

After (this branch, e6197fc):

      Tests  3 passed (3)

Risks

  • A slow admin setting write delays the writes made after it until it answers or fails.
  • No API, schema or config change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code in the Claude desktop app
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Fix admin setting save racing an in-flight device override reset

  • A device override save made while a reset mutation is pending now waits for the reset and is sent after it. The saved row stays in the cached settings list.
  • Adds shared adminSettingWriteOptions in adminSettingWrites.ts. All admin setting hooks in users.ts now use one mutation scope and disable retries.
  • Adds a refuseOffline guard: writes made while the React Query online manager reports offline throw SettingWriteOfflineError instead of calling the API.
  • Behavioral Change: admin setting mutations no longer retry on failure, and saves queued behind a reset fail without a PUT if the app goes offline before the reset responds. Covered by new tests in adminSettingWrites.test.tsx.

Macroscope summarized e6197fc.

A reset in Admin > Devices dropped every cached row at the override's
profile, device and key once its delete settled. When a save on the same
override settled first, that took the saved row out of the list until a
refetch answered.

The reset now reads the cached revision and write time of each row it
targets before the delete is sent, and drops only rows still at that
version. Reset-all reads them per key, before each delete.

Closes Silo-Server#5522

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 29, 2026
@silo-kody

silo-kody Bot commented Nov 29, 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 ❌

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Admin setting mutations now share a serialized mutation scope and common retry settings. Set and delete wrappers check connectivity before calling the API. Tests cover saves queued behind resets and writes that become offline while waiting.

Changes: Admin setting writes

Layer / File(s) Summary
Shared write policy
web/src/hooks/queries/admin/adminSettingWrites.ts
The shared options use the admin-setting-write mutation scope and disable retries. Set and delete wrappers check connectivity before calling their API functions.
Mutation wiring and queued-write validation
web/src/hooks/queries/admin/users.ts, web/src/hooks/queries/admin/deviceOverrideWrite.test.tsx
Admin setting update, delete, device override, and bulk reset mutations use the shared options. Tests verify that saves wait for resets and reject if connectivity is lost while waiting.

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ResetMutation
  participant AdminSettingWriteScope
  participant SaveMutation
  participant onlineManager
  participant SettingsAPI
  ResetMutation->>AdminSettingWriteScope: starts reset in shared scope
  ResetMutation->>SettingsAPI: sends DELETE
  SaveMutation->>AdminSettingWriteScope: queues setting write
  SettingsAPI-->>ResetMutation: completes DELETE
  AdminSettingWriteScope->>SaveMutation: runs queued write
  SaveMutation->>onlineManager: checks isOnline()
  onlineManager-->>SaveMutation: returns connectivity status
  SaveMutation->>SettingsAPI: calls setAdminSettingValue
Loading

Possibly related PRs

Suggested labels: javascript

Suggested reviewers: rhainland, quick104

Merge Risk: Moderate · up to e9c37

The change serializes admin setting writes so a save made during a device-override reset is no longer dropped from the cache, and it refuses queued writes if the connection drops. No runtime defect was found. However, the added tests push one test file over the repository's 800-line limit, which fails a required CI check. Splitting the new tests into their own file should clear it before merge.

Security architecture risk: Low · up to e9c37

The change prevents a late reset response from hiding a save made in the same admin session. The tradeoff is that a slow or stalled request can now delay unrelated settings changes in that session. The change does not add permissions or expose a new endpoint.

Retained concerns

  • Trivial · reliability · inferred: One queue now covers unrelated admin setting targets within a QueryClient. A slow bulk reset holds the queue across its per-key requests, and a single request that never settles can hold it indefinitely because settings writes have no application deadline. The base did not couple unrelated writes this way.

View findings in the submitted review

Security review details

Security Blast Radius

  • inferred — The new execution coupling reaches the affected admin hooks sharing one QueryClient, across target users and devices. It does not serialize independent clients or change which persisted settings the existing endpoints can address.

Trust Boundaries and Controls

  • observed — The new wrappers do not elevate authority or rewrite the target user, setting key, or scope. The existing transport still builds session headers from the supplied snapshot, and the write helpers still disable authentication retry.

Hardening Proposals

  • proposed — Consider isolating unrelated targets while preserving ordering across single resets, bulk resets, and mirrored keys that touch the same rows. Bind authority to each queued intent explicitly, and define how to reconcile an unknown write outcome before releasing conflicting work.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names a device override reset that drops a save made while the reset was pending, which matches the PR's stated fix for issue #5522. The objectives describe a later rework that serializes ad…
Linked Issues check Passed [#5522] requires a device-override reset to remove only the rows it cleared. A save made after the reset starts must stay in the Admin › Devices cached list. At the reviewed head, web/src/hooks/querie…
Out of Scope Changes check Passed The changes at head are in web/src/hooks/queries/admin/adminSettingWrites.ts (new shared mutation options and connectivity-checked wrappers), web/src/hooks/queries/admin/users.ts (hooks now use the sh…
Description check Passed The description states the problem (a device override reset removing a saved row from the Admin › Devices cache), the approach (a shared TanStack Query mutation scope for the five admin setting write …
Full details: Title check

Explanation

The title names a device override reset that drops a save made while the reset was pending, which matches the PR's stated fix for issue #5522. The objectives describe a later rework that serializes admin setting writes under a shared mutation scope. The title does not name that serialization, but it still describes a real, central aspect of the change.

Full details: Linked Issues check

Explanation

[#5522] requires a device-override reset to remove only the rows it cleared. A save made after the reset starts must stay in the Admin › Devices cached list. At the reviewed head, web/src/hooks/queries/admin/adminSettingWrites.ts defines adminSettingWriteOptions with scope { id: "admin-setting-write" } and retry: false. Mutations in that scope run one at a time. A save made during a pending reset is sent only after the reset answers and its onSuccess removal runs. The server therefore processes the save after the delete, and the reset response cannot remove the saved row. The exported setAdminSettingValue and deleteAdminSettingValue wrappers also refuse the write unsent when onlineManager reports offline, so a queued write made online is not sent after the connection drops. The head no longer contains removedSettingRows.ts, so the revision-comparison approach named in the current PR description is no longer in the code. The description is stale. The wiring of the five hooks in users.ts (adminSettingWriteOptions used by the update, delete, device override and reset-all mutations) is taken from the AI-generated change summary and was not read directly, because the file was not read in full. The new tests in deviceOverrideWrite.test.tsx were not read or run in this review. The PR reports they cover the wait behavior and fail on main. A browser race against a real server is untested.

Full details: Out of Scope Changes check

Explanation

The changes at head are in web/src/hooks/queries/admin/adminSettingWrites.ts (new shared mutation options and connectivity-checked wrappers), web/src/hooks/queries/admin/users.ts (hooks now use the shared options and wrappers) and deviceOverrideWrite.test.tsx (new tests). The shared scope is the serialization mechanism that the PR objectives require for the five admin setting write hooks, so it is connected to #5522. The connectivity check in the wrappers is named in the objectives as part of the same rework. The shared scope also applies to Preferences-tab writes through the same five hooks, which the objectives include. No unrelated edits were identified in the evidence reviewed. The PR description's Approach section describes superseded code (removedSettingRows.ts, revision comparison), so the description should be updated to match head.

Full details: Description check

Explanation

The description states the problem (a device override reset removing a saved row from the Admin › Devices cache), the approach (a shared TanStack Query mutation scope for the five admin setting write hooks, plus an online check when each queued write is sent), the validation (three new tests in adminSettingWrites.test.tsx with before/after results), and the risks. It matches the changeset described in the raw summary, so it is related and specific.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Nov 29, 2026
Comment thread web/src/hooks/queries/admin/users.ts Outdated
* One write of a row: its revision and write time. A row deleted and saved
* again gets a new write time even if its revision starts over.
*/
const rowVersion = (row: AdminSettingValueRow) => `${row.revision}@${row.updated_at ?? ""}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

Recreated rows can have the same version within one second

A delayed reset response can remove a newly saved row because updated_at has whole-second precision and revision restarts after deletion. Use a write identifier that cannot collide across recreation.

Prompt for LLM
File web/src/hooks/queries/admin/users.ts, line 235:

Recreated rows can have the same version within one second

The backend formats `updated_at` to whole seconds and restarts `revision` after deletion, so deleting and recreating a revision-1 row within the same second gives the saved row the same version as the deleted row. The delayed reset response then removes the newly saved row from the cache, reproducing the original regression; use a write identifier that cannot collide across recreation.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly fixed in d24d339. The version now includes the value, and the rule no longer relies on the version alone: the server stores a new row at revision 1 and adds 1 on each save (pgstore/setting_values.go:270, userdb/setting_values.go:266). A row of revision 1, deleted and saved again within the same second with the same value, still matches what the reset read and is dropped until the list's refetch answers. In that case the dropped row's value is the one the admin had before the reset. I've listed this under Risks.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying. Including the value narrows the collision, but it does not eliminate it: a revision-1 row recreated with the same value within the same timestamp second can still be removed from the cache by the delayed reset response.

The impact is temporary—the refetch should restore the server’s saved row—but until then the list can show no override, and reopening the editor can start from the inherited value. Documenting that residual risk is appropriate. A complete fix would need a non-colliding write identity or another way to distinguish a recreated row.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer applies: e9c3710 drops the revision comparison. Admin setting writes now go out one at a time, so a save made during a reset is sent after the reset has answered and dropped its row.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. In e9c3710, the revision-based comparison is gone, so the version-collision scenario in the original suggestion no longer applies. The shared mutation scope serializes the admin setting writes: a save queued during a reset is sent after the reset completes and removes the cached row.

The tradeoff is that a slow write can delay subsequent writes, as noted in the PR.

Comment thread web/src/hooks/queries/admin/users.ts Outdated
same(row.series_id, identity.seriesId) &&
keys.has(row.key)
isRowAt(row, identity, keys) &&
(versions === undefined || versions.get(row.key) === rowVersion(row))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

A save processed before the delete is incorrectly retained

If a save completes before the pending delete, the server removes it but the changed rowVersion keeps it cached. Track server-side ordering rather than treating a changed version as proof that the save came later.

Prompt for LLM
File web/src/hooks/queries/admin/users.ts, line 287:

A save processed before the delete is incorrectly retained

A changed cached version does not prove that the save happened after the delete on the server: the save can complete first while the delete request is still pending. In that ordering the delete removes the saved value on the server, but this condition retains it in the cache and can offer the deleted override back if the refetch is delayed or fails.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d24d339. A save the server handles before the delete updates the existing row, so its revision is past the one the reset read before it was sent. That row now goes. A save after the delete creates a new row at revision 1 and stays. The test settles a device override saved while its reset was answering has both orders: a saved row at revision 3 over a cached 2 is dropped (it failed on ab77256), and one at revision 1 is kept (it fails on main).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The added tests address the ordering concern I raised: they cover both a save processed before the delete and one processed afterward.

That distinction relies on the server guaranteeing that an update increments the existing row’s revision and a post-delete save creates a row at revision 1. I haven’t independently verified the fix or those guarantees.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer applies: e9c3710 drops the revision comparison. Admin setting writes now go out one at a time, so a save made during a reset is sent after the reset has answered and dropped its row.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification. Based on your description, the original suggestion no longer applies: the revision comparison is gone, and serializing the writes prevents a save queued during a reset from being sent until the reset has completed.

I haven’t independently verified e9c3710 or its tests.

Comment thread web/src/hooks/queries/admin/users.ts Outdated
Comment on lines +253 to +258
const rows =
queryClient.getQueryData<AdminSettingValueRow[]>(
adminUserSettingValuesKey(authority, userId),
) ?? [];
return new Map(
rows.filter((row) => isRowAt(row, identity, keys)).map((row) => [row.key, rowVersion(row)]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

A settings query completing during reset leaves deleted rows cached

An in-flight settings query can load a pre-delete row after an empty snapshot, leaving the deleted override cached until a refetch succeeds. Distinguish query results from newer saves when reconciling the reset.

Prompt for LLM
File web/src/hooks/queries/admin/users.ts, lines 253-258:

A settings query completing during reset leaves deleted rows cached

An empty snapshot treats every row loaded while the delete is pending as a newer save, even when an in-flight settings query merely returns the pre-delete row. The successful reset then leaves that deleted override in the cache until a subsequent refetch succeeds.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d24d339. A key with no cached row when the reset was sent can't be told apart, so its row now goes once the reset settles, as on main. Only a key the reset read keeps a row, and only by the revision rule above.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying. That addresses the reported case: when no row was cached at reset time, a matching row loaded while the reset is pending will be removed when it succeeds, as it was on main.

The tradeoff is that a genuinely new save in that same empty-snapshot window is also indistinguishable and can be removed from the cache until refetch. I haven’t independently verified the fix in d24d339.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer applies: e9c3710 drops the revision comparison. Admin setting writes now go out one at a time, so a save made during a reset is sent after the reset has answered and dropped its row.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—the original suggestion targets the revision-based reconciliation, which e9c3710 removes. With the shared mutation scope, a save queued during a reset is sent after the reset settles and removes the matching cached row.

I haven’t independently verified the implementation or test results.

@coderabbitai coderabbitai Bot added the javascript Pull requests that update javascript code label Nov 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — If a save commits before the server processes a reset, but the save response updates the cache after the reset captures its snapshot and before cleanup runs, the reset preserves the version it actually deleted. The base removed that row by identity. The head reports success and schedules reconciliation without waiting for it, so a reopened editor can use the deleted value if the refresh is delayed, skipped, or fails.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 70be5939-6955-4282-b805-9c3f1d89898c
Commits

Reviewing files that changed from the base of the PR and between 95df9d7 and c720f8d.

Files selected for processing: 2

  • web/src/hooks/queries/admin/deviceOverrideWrite.test.tsx
  • web/src/hooks/queries/admin/users.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.

users.ts was at its 800-line size limit, and Silo-Server#5522's version check took
it past. The removal helpers, cachedRowVersions and dropSettingRows now
live in removedSettingRows.ts and take the settings list's query key,
so users.ts no longer needs the wrapper that passed it on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 30, 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 ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — If a competing save commits before the delete but publishes a different cached version after the reset takes its snapshot, the successful delete now leaves that row in the cache. The base removed it at delete completion. If the follow-up read fails or is skipped, a reopened editor can use a value the server already deleted. This affects recovery of the admin view, not the stored setting or delete authority.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d759e0c6-1ed4-4331-b888-148b871f802b
Commits

Reviewing files that changed from the base of the PR and between c720f8d and ab77256.

Files selected for processing: 2

  • web/src/hooks/queries/admin/removedSettingRows.ts
  • web/src/hooks/queries/admin/users.ts

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

@rangoDJ

rangoDJ commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

On CodeRabbit's advisory finding (a save that commits before the reset but reaches the cache after the reset reads its versions): yes, that row stays until the list's refetch answers. It's the trade-off listed under Risks. Keeping it means the cache never drops a value the server may still hold. The base's rule drops by identity, which is the bug in #5522. The refetch starts in the same onSuccess.

…sion

The reset kept every cached row whose version changed after it was sent.
That also kept a save the server handled before the delete, which the
delete then cleared. The server stores a new row at revision 1 and adds
1 on each save, so a row past the cached revision is such a save and
goes; a lower revision, or revision 1 written again, is a save after the
delete and stays. A key that wasn't cached when the reset was sent goes,
as before Silo-Server#5522. The version now includes the value, so a row of
revision 1 deleted and saved again in the same second with a new value
also stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 30, 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 ❌

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Quick104

Copy link
Copy Markdown
Contributor

This PR fixes a real problem, but queuing the admin setting writes would fix it more simply. Give the five admin setting write hooks in web/src/hooks/queries/admin/users.ts (useUpdateAdminUserDeviceSetting, useDeleteAdminUserDeviceSetting, useDeleteAllAdminUserDeviceSettingsForDevice, useUpdateAdminUserSetting and useDeleteAdminUserSetting) one shared TanStack Query mutation scope, as useSaveAdminDashboardLayout already does. A save made while a reset is pending is then sent only after the reset has answered and dropped its row, so the saved row stays, and removedSettingRows.ts isn't needed. This branch works out the server's order from revision numbers instead, and two cases break that in hook tests:

  • Intro skip pair. withSavedSettingRow gives the companion row the saved row's revision, but the two halves' real revisions can differ: the intro_skip_mode migration created its rows at revision 1. With intro_skip_mode at revision 2 and auto_skip_intro at 5, a save the server handles before the reset leaves the deleted auto_skip_intro override in the list. Main drops both rows.
  • Two saves after the reset. With the row at revision 1, two saves the server handles after the delete land at revisions 1 and 2. The late reset answer then drops the revision 2 row, which is [bug] A device override reset that answers after a newer save drops the saved override from Admin › Devices #5522 again.

The rework needs two more things. Each scoped mutationFn should check onlineManager.isOnline() again, because the offline check in settingWriteOptions runs when a write is queued, not when it's sent. The new test should assert that the PUT isn't sent until the DELETE answers. The queue has two costs that seem acceptable for admin edits: one slow write holds the ones behind it, since writes have no client deadline, and a queued write waits while the tab is hidden.

I merged main into the branch (11992ad) to clear the conflict in users.ts. I recommend reworking it this way, so I've stopped the line-by-line review here.

Fit: 5/10. The fix belongs in Silo, but it adds a second way to work out write order, one that depends on the server's revision rules, where queuing the writes removes the race.

🤖 Claude Code (claude-opus-5-5)

…g revisions

The five admin setting write hooks now share one mutation scope, so a
save made while a reset is still answering is sent only after the reset
has answered and dropped its row. The reset can no longer drop the
saved row. This replaces removedSettingRows.ts, which worked out the
server's order from revision numbers and broke for the intro skip pair
and for two saves after a delete.

Each write checks for a connection again when it is sent, since the
offline check in settingWriteOptions runs when the write is queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 30, 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 ❌

@rangoDJ

rangoDJ commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Reworked as you suggested in e9c3710.

  • The five admin setting write hooks share one mutation scope, so a save made during a reset goes out only after the reset has answered and dropped its row. removedSettingRows.ts is gone.
  • Each queued write checks onlineManager.isOnline() again when it is sent. The check is in the two write calls, wrapped in the new adminSettingWrites.ts.
  • The new tests assert that the PUT isn't sent until the DELETE answers, for one override and for reset-all, and that a save queued online is refused unsent if the connection drops while it waits. All three fail with main's users.ts.

The description is updated.

*/
export const adminSettingWriteOptions = {
...settingWriteOptions,
scope: { id: "admin-setting-write" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

One stalled write blocks all admin setting changes

An unanswered write blocks later writes to unrelated users and devices because v2 has no default deadline. Serialize only writes to the same setting identity, and ensure stalled requests cannot block unrelated writes indefinitely.

Prompt for LLM
File web/src/hooks/queries/admin/adminSettingWrites.ts, line 16:

One stalled write blocks all admin setting changes

Every admin settings mutation shares this scope, so an unanswered write blocks all later writes, including writes to unrelated users and devices; `v2` gives writes no default deadline. Serialize only conflicting setting identities and ensure a stalled request cannot indefinitely prevent unrelated writes.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changed. The maintainer's review that asked for this queue named the same cost and judged it acceptable for admin edits: one slow write holds the ones behind it, since writes have no client deadline. It's also in the PR's Risks.

Serializing per setting identity isn't a drop-in change either. A TanStack Query mutation scope is fixed per hook, not per call, so these hooks can't pick a scope from the user, device or key they write. A reset-all also spans several keys, and one delete of an intro skip key clears its mirrored half. A client deadline for setting writes would apply to every setting write, not only these, so it should be its own change if the maintainers want one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The shared queue’s blocking behavior is an explicit, maintainer-accepted tradeoff for admin edits and is documented in the PR’s risks. The reset-all and mirrored-key cases also make conflict-specific serialization more involved than the suggestion implies.

I withdraw the suggestion as a blocker for this PR. Request deadlines or finer-grained scheduling can be considered separately if the operational cost becomes a concern.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — One queue now covers unrelated admin setting targets within a QueryClient. A slow bulk reset holds the queue across its per-key requests, and a single request that never settles can hold it indefinitely because settings writes have no application deadline. The base did not couple unrelated writes this way.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddb2dccc-1a0b-49e0-9533-06b583cfb246
Commits

Reviewing files that changed from the base of the PR and between ab77256 and e9c3710.

Files selected for processing: 3

  • web/src/hooks/queries/admin/adminSettingWrites.ts
  • web/src/hooks/queries/admin/deviceOverrideWrite.test.tsx
  • web/src/hooks/queries/admin/users.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.

deviceOverrideWrite.test.tsx crossed its 800-line limit (834). The two
queued-write tests now live in adminSettingWrites.test.tsx, next to the
module they test, and that file is back to main's 683 lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 30, 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 ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] A device override reset that answers after a newer save drops the saved override from Admin › Devices

2 participants