Skip to content

fix(web): save the rest of a settings page when an edited field becomes environment-managed - #4673

Merged
Quick104 merged 4 commits into
mainfrom
fix/settings-save-skip-env-managed
Nov 20, 2026
Merged

Quick104 merged 4 commits into
mainfrom
fix/settings-save-skip-env-managed

Conversation

@Quick104

@Quick104 Quick104 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: Apple N/A (no admin settings form); Android N/A (no admin settings form); Roku N/A (no admin settings form)

An admin settings page can't save any of its edits after a server restart makes one of the edited fields environment-managed. The field turns read-only ("Set by SILO_SERVER_NAME in the server's environment.") but keeps the admin's draft and still counts it as unsaved. Save sends it with the other edits, and the server refuses the whole batch ("branding.server_name is managed by an environment variable"). The locked field can't be changed back, and every later Save gets the same refusal. This applies to every page built on the shared settings form and every variable in the environment settings table from #4498.

This change drops a field's draft once the server reports that the environment sets it. The field then shows the server's value, the save bar counts only fields the admin can still save, and Save sends only those. A save the server refuses as invalid also re-reads which keys the environment sets, so the form catches up even when nothing else has refreshed that list.

Approach

  • useSettingsForm checks its unsaved keys against managed_by_env_vars from GET /api/v2/admin/settings/sensitive-status and removes the draft of any key the environment now sets. It does this during render, the same way the hook already resets drafts when the acting profile changes. The one exception is a staged empty redis.db. The server still accepts clearing it under REDIS_URL, because that is how a saved number gets removed, so that draft stays. The server's refusal is unchanged.
  • useUpdateServerSettings invalidates the sensitive-status query when the server refuses a save with validation_failed, which is how the environment refusal arrives. While the page stays open through a restart, nothing else refetches that list: window-focus refetching is off, and a server restart doesn't fire the browser's online event. Without this, the first refusal would repeat on every Save. Other failures, such as timeouts and server errors, don't trigger the refetch.
  • useSettingsForm now treats the status as unknown (sensitiveStatusError) only when no list has ever loaded. Before, any failed re-read counted, even with a list already loaded. On the Storage page that state replaces the whole editor, drafts included. A failed re-read now keeps the last list. The pages that handle sensitiveStatusError (Storage, General, Search) see it only on a first-load failure, which the follow-up about failed status reads builds on.

Not covered here: when the variable's value differs from the stored one, startup writes it to server_settings, which changes the settings revision. The form's concurrency guard then answers 412 for the remaining edits until the admin discards them. Main does the same after any outside settings change. That is a separate gap in how the settings form handles a 412, and it has its own follow-up.

Validation

  • Reproduced on a Silo dev deployment built from main (66b836f). Steps: edit Server name and Login subtitle on Settings → General, restart the API with SILO_SERVER_NAME set to the stored value, then press Save. With the page left open, every Save answered 422 and the field never turned read-only. After a network reconnect refreshed the field to read-only, it still showed the draft, the bar counted 2, and Save answered 422. The subtitle stayed unsaved in both cases.
  • Same steps on the fix (c2e4898 for the page-left-open flow, 5c8876a for the rest, which none of the later commits reach). With the page left open, the first Save answers 422, the field turns read-only with the environment's value, the count drops to 1, and the second Save answers 200. After a reconnect, the first Save answers 200. When the locked field was the only edit, the save bar goes away. A reload and the server_settings row show the subtitle stored and the server name left at the environment's value.
  • The page-left-open flow at a 390 px phone width gives the same results before and after as at desktop width, with the same data on both builds.
  • With a variable whose value differs from the stored one, main and the fix both answer 412 (see Approach). The fix still drops the locked draft and sends only the subtitle.
  • Three integration tests in settingsWrite.test.ts run the form through a real query client:
    • The refusal, the refresh, and the second save. Fails on main.
    • An ordinary validation refusal whose re-read fails: the form keeps its known list and its draft. Fails on 5c8876a, an earlier head of this PR.
    • A staged redis.db clear surviving REDIS_URL taking over. Fails on 73eb033, the head before that fix.
  • Web gate under Node 24 on 47f9adb (c2e4898 only tightens a test): lint, format check, build, bundle budget, and the full vitest suite (303 files, 3053 tests) pass. Under Node 26, four unrelated test files fail the same way on main.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/settings-env-locked-draft/

Risks

The drop is silent. If an admin typed into a field and the environment then took it over, that text is gone, and the field's "Set by …" note is the only explanation. The server would refuse that value anyway. In a cluster whose API servers were started with different environments, the form follows whichever server answered the sensitive-status request.

Follow-ups

Each of these is a separate pull request in progress. All of them happen on main too.

  • The settings form answers 412 after any outside settings change and stays stuck until Discard, including a restart whose variable changes a stored value.
  • Settings pages keep, and later save, drafts for fields they have hidden: the Jellyfin Web draft that Enable Jellyfin API stages, the public S3 Advanced fields, and the dependent fields in the wizard and on Playback. The Use Redis switch can also keep showing off after its drafts are gone (Gemini G2, G3, G4).
  • The Storage page offers a storage transition while the environment sets a storage key, and the server refuses every transition in that state (Gemini G1).
  • Most settings pages leave fields editable when the sensitive-status read fails. Only Search, Storage, and General handle it.

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.

Council review

Background review: 3 rounds, last reviewed c2e4898 (the merged head).

Member Round 1 (5c8876a) Round 2 (73eb033) Round 3 (c2e4898)
Sol (gpt-6.2-sol, xhigh) 6/10 6.5/10 7/10
Opus (claude-opus-5-5, high) 8/10, no findings 8/10 9/10
Gemini (gemini-4-neon, xhigh) 5/10 6.5/10 9/10

Fixed:

  • 73eb033 kept a failed refresh after an ordinary validation refusal from switching the Storage page to its reload notice (Sol S2).
  • 47f9adb replaced 73eb033's direct read, which could overwrite a newer list, skipped retries, and could write into the cache after sign-out (Sol S4, S6, S7; Opus O2; Gemini G6; Kody). The refresh is a query invalidation again, and the form reads isLoadingError (Opus O1).
  • 47f9adb also keeps a staged redis.db clear (Sol S5).
  • c2e4898 makes the re-read test check that the known list survives (Gemini G7).

Round 3, answered:

  • Sol S8: when API servers are started with different per-process variables, one server's read can drop a draft that another server would have accepted. This is the cluster limitation that Risks describes. Keeping such drafts set aside instead was tried and dropped. A draft that comes back after the form had cleared its baseline could overwrite another admin's newer save without a 412. It could also return unexpectedly, and set-aside secret drafts would stay in memory.
  • Sol S9: a Save pressed again before the refresh lands only repeats the refusal.
  • Gemini G9: the Use Redis switch state, already in Follow-ups (G4).
  • Opus O3 (two assertions that document intent): kept.

Answered: hidden companion or dependent drafts (Sol S1, Gemini G2, G3, G4), storage transitions refused under storage variables (Gemini G1), and the 412 after a changed value (Gemini G5, Kody) all happen on main and are in Follow-ups. The stale value after a late-acknowledged save (Sol S3) also happens on main, and the save's own settings refetch corrects it.

Visual review: 1 round, captures of the reconnect and different-value cases from an earlier head with the same visible behavior

Member Round 1
Sol better, 8/10
Opus better, 7/10
Gemini better, 7.5/10

Answered: every visual finding concerns styling the before captures show too (disabled-input contrast, where the modified dots sit, no confirmation after a successful save, a clipped sidebar item), or the silent drop that Risks describes. The captures of the page-left-open and only-edit cases come from the final head and were checked by the implementer, not the council.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code subagents (code-review finders and checkers); T3 Code delegate_task for the council (Codex, Claude, Antigravity)
  • Model(s): claude-opus-5-5 (implementation, review), claude-sonnet-5-5 (review finders), gpt-6.2-sol, gemini-4-neon (council)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: code review at xhigh (four finders, a validation check, and a sweep) led to deleting the dropped draft instead of copying the snapshot into it, refreshing the environment list after a refusal, and limiting that refresh to validation refusals. Three background rounds then reshaped how a failed re-read is handled. The plan round was skipped as a mechanical fix, and a simplify pass ran before each commit. See Council review for the background and visual rounds.

🤖 Generated with Claude Code

…es environment-managed

A settings page kept a draft for a field after a server restart made the
field environment-managed. The field turned disabled but stayed counted as
unsaved, and Save sent it with the other edits, so the server refused the
whole batch and none of the edits were saved.

The settings form now drops a draft once sensitive-status reports its key
as set by the environment: the field shows the server's value, the save bar
counts only editable fields, and Save sends only those. A save the server
refuses as invalid also refetches sensitive-status, since nothing else does
while the page stays open through a restart, so a second Save goes through.

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

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 6b52bd1e-c479-4b36-b02b-05f00de2a9a3
Commits

Reviewing files that changed from the base of the PR and between 66b836f and c2e4898.

Files selected for processing: 3

  • web/src/hooks/queries/admin/settings.ts
  • web/src/hooks/queries/admin/settingsWrite.test.ts
  • web/src/hooks/useSettingsForm.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T22:45:50.337825Z c2e4898 New commits
🔒 Security Review ✅ Completed 2026-11-20T22:47:32.123548Z c2e4898 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.

@silo-kody

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

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish labels Nov 20, 2026
@silo-triage

silo-triage Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Resolved: phone-width before-and-after captures now cover the environment-managed field, remaining unsaved edit, and successful persistence after reload, with both builds identified.

Original request

Please add before-and-after captures at a phone-width viewport for the changed settings flow, showing the environment-managed field, unsaved-change count, and successful save of the remaining edit. CONTRIBUTING.md treats desktop and mobile web as separate surfaces; the shared form’s value and save-state changes affect mobile too, even without layout or styling changes. Name the before/after builds with the captures.

Comment thread web/src/hooks/queries/admin/settings.ts Resolved

@Quick104 Quick104 left a comment

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.

Adversarial review (gemini-4-neon, reviewed 5c8876a)

Verified claims that hold: environmentRefusesSave arrives as 422 validation_failed on PUT /api/v2/admin/settings when the If-Match guard passes (internal/api/handlers/admin.go:1633-1635, internal/apiv2/admin_settings_write.go:89-98), managed_by_env_vars covers every key environmentRefusesSave refuses (internal/api/handlers/admin_settings_inspection.go:66-74, cmd/silo/main.go:787-798,1436-1437, cmd/silo/env_settings.go:75-81), and nothing else refetches sensitive-status while a visible tab stays open across a restart (web/src/lib/query-client.ts:47-48, web/src/components/RealtimeEventsProvider.tsx:579-581,1284-1307).

Five issues remain across the change and the settings pages it serves (G2, G3, and G5 are inline on their diff lines; G1 and G4 sit outside the diff hunks):

G1 (High) — Locked StorageSettings bypasses useUpdateServerSettings, so POST /api/v2/admin/storage-transitions never refreshes sensitive-status

  • Location: web/src/hooks/queries/admin/settings.ts:165-180, web/src/pages/admin-settings/StorageSettings.tsx:641-647,725-784
  • Trigger: On an install with locked storage (artworkLocked or privateLocked), open Settings → Storage, edit any location key (artwork.storage_backend, artwork.local_path, s3.public_endpoint, s3.public_bucket, s3.public_key_prefix, s3.private_endpoint, s3.private_bucket, or s3.private_key_prefix) alongside another storage key in STORAGE_TRANSITION_KEYS (such as s3.public_region, s3.public_path_style, s3.public_url_auth, or S3 credentials). Restart the server with a storage env var matching the recorded location (permitted by CheckEnvironmentSettings in internal/api/handlers/admin_settings_env.go:45-51), then click Review transition and Queue transition.
  • Impact: Because storageLocationChangePending is true and nonTransitionKeys is empty (StorageSettings.tsx:730), useUpdateServerSettings is never called. POST /api/v2/admin/storage-transitions answers 422 validation_failed (internal/storagetransition/service.go:325-331,479, wired at cmd/silo/main.go:4003; mapped at internal/apiv2/admin_storage_transition.go:179-181). useCreateStorageTransition has no onError invalidation for sensitive-status, and StorageSettings.tsx:781-783 catches the error with a generic toast. The env-managed location draft stays dirty, storageLocationChangePending stays true, the SaveBar stays stuck on Review transition, and the remaining storage edits cannot be saved without discarding all edits or reloading.
  • Evidence: web/src/hooks/queries/admin/settings.ts:165-180 defines only onSuccess; web/src/pages/admin-settings/StorageSettings.tsx:92-102,725-784 routes every STORAGE_TRANSITION_KEYS save through createTransition while a location edit is staged.
  • Suggested repair: Add an onError handler to useCreateStorageTransition that invalidates [...adminKeys.serverSettings(), "sensitive-status"] on V2ProblemError with problemType === "validation_failed". In StorageSettings.tsx, surface the problem detail in the catch toast and close the transition dialog once storageLocationChangePending clears so the SaveBar returns to Save.

G4 (Medium) — RedisGroup leaves "Use Redis" stuck OFF and disabled when REDIS_URL drops Redis drafts while another General edit stays dirty

  • Location: web/src/pages/admin-settings/RedisGroup.tsx:41-53,99-101
  • Trigger: With redis.url stored in the database, open Settings → General, toggle Use Redis off (setEnabledOverride(false); stageRedisUrl(form, "")), and edit another General field (for example branding.login_subtitle). Restart with REDIS_URL set to the same stored URL (ETag unchanged) and click Save.
  • Impact: The first Save gets 422 validation_failed, sensitive-status refreshes with redis.url and redis.db under REDIS_URL, and useSettingsForm drops both Redis drafts. Because branding.login_subtitle is still dirty, form.dirtyCount drops to 1 rather than 0, so if (form.dirtyCount === 0) setEnabledOverride(null) (RedisGroup.tsx:51) does not run. enabled stays false while urlEnv is "REDIS_URL": Use Redis renders OFF and disabled with "Set by REDIS_URL", hiding the URL, Database number, and Test connection rows even though Redis is active, until the remaining edits are saved or discarded.
  • Evidence: web/src/pages/admin-settings/RedisGroup.tsx:48-53 only clears enabledOverride on form.dirtyCount === 0 and computes const enabled = enabledOverride ?? (redisUrl.trim() !== "" || configured).
  • Suggested repair: Clear enabledOverride and ignore it when computing enabled whenever urlEnv != null.

AI disclosure: reviewed by gemini-4-neon via Antigravity in T3 Code.

Comment thread web/src/hooks/useSettingsForm.ts Resolved
Comment thread web/src/hooks/useSettingsForm.ts Resolved
Comment thread web/src/hooks/queries/admin/settings.ts Resolved
@Quick104

Copy link
Copy Markdown
Contributor Author

The evidence page now has 390 px phone-width before and after captures for the flow where the page stays open. Before is 66b836f (main); after is 5c8876a (this head). Both runs used the same data. They show the environment-managed field and the unsaved-change count after the first refusal, then the second Save storing the remaining edit and the reload confirming it. The PR description's Validation section lists the result.

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

@silo-triage silo-triage Bot removed the evidence-required Needs before-and-after evidence before the Evidence check passes label Nov 20, 2026
…save fails

A save refused as invalid now re-reads which keys the environment sets.
When that read failed, the query turned errored, and the Storage page
traded its editor, drafts included, for a reload notice. The refresh now
reads the list directly and updates the cache only when the read succeeds,
so a failed read keeps the last known list.

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

silo-kody Bot commented Nov 20, 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 left a comment

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.

Adversarial review (gpt-6.2-sol, reviewed 5c8876a)

Posted by the PR author's run because the reviewer's tool couldn't submit a review pinned to the commit. The findings are the reviewer's, in summary.

S1 (P2): a retried Save can turn Jellyfin Web off on its own. Turning Enable Jellyfin API off also stages jellyfin_compat.web_enabled: "false". If the server restarts with SILO_JELLYFIN_ENABLED=true matching the stored value, the refresh locks the API switch and drops its draft, but the companion draft stays hidden and dirty. A component test showed the second PUT sending only web_enabled: "false". Suggested: drop the companion edit when its parent draft is dropped (web/src/hooks/useSettingsForm.ts, web/src/pages/admin-settings/CompatibilityProxiesSettings.tsx setJellyfinAPIEnabled).

S2 (P2): an ordinary validation error can strand Storage drafts. Any validation_failed refusal, such as a relative artwork path, now refreshes sensitive-status. If that refresh fails (502 in the test), the query turns errored, and the Storage page replaces its editor, Save and Discard with a reload notice. On main the same refusal left the editor available for correction (web/src/hooks/queries/admin/settings.ts onError, web/src/pages/admin-settings/StorageSettings.tsx status-error state).

S3 (P3): an acknowledged save can restore an outdated locked value. If the old process accepts a change and the restarted process then reports a different environment-set value, the form shows the new locked value until the earlier PUT settles, then the response's older value. Main ends with the same stale display. Suggested: advance the field's edit version when its draft is dropped (web/src/hooks/useSettingsForm.ts draft removal and save reconciliation).

Score: 6/10.

AI disclosure: reviewed by gpt-6.2-sol via Codex in T3 Code; posted by Claude Code (claude-opus-5-5).

Comment thread web/src/hooks/queries/admin/settings.ts Resolved

@Quick104 Quick104 left a comment

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.

Adversarial review (claude-opus-5-5, reviewed 73eb033)

The round-2 change fixes the case it set out to fix: a failed status read after a validation_failed refusal now keeps the last list, and the Storage page keeps its editor and drafts. Within onError, fetchQuery and refetchQueries would not get there. On TanStack v5 both move the query to status: "error" while keeping its data, so useQuery().isError turns true and Storage swaps in the reload notice again. Among mutation-side options, the direct queryFn plus setQueryData is the simplest. The new test drives a failure-handling path that no type check catches, so it fits "Decide what to test". Two nits:

O1 (nit, boundary): the errored-list signal belongs in useSettingsForm, not the mutation. web/src/hooks/useSettingsForm.ts:25 reads isError, which is also true when a refetch fails while data is still cached. Other refetches of this key can still fail the same way. After a successful save, onSuccess invalidates sensitive-status, and a 30 s stale refetch runs when the page mounts again. If that read fails (two 5xx in a row with the default single retry), Storage still replaces its editor with "reload before editing" even though a usable list is cached. That part was already on main. Reading isLoadingError (an error with no data yet) instead of isError closes all three paths in one place. onError could then go back to invalidateQueries, and this PR's test would pass unchanged. One cost to check: General and Search use sensitiveStatusError to show "connection unknown", and with this change they would show the cached status after a failed refetch. That seems acceptable to me, but it changes what those pages show.

O2 (nit, correctness): the hand-rolled read skips the query cache's lifecycle. At web/src/hooks/queries/admin/settings.ts:314, onError checks isCapturedProfileAuthorityActive only before the read starts, and .then(setQueryData) doesn't check again. If the admin signs out and signs in to another server or account while the read is in flight, App.tsx:375 clears the cache and the old read then writes the previous server's env-var list into the new session, marked fresh for 30 s. useSettingsForm would then drop drafts or lock fields based on another server's environment. invalidateQueries didn't have this problem, because a fetch on a cleared query resolves into a detached Query. The same setQueryData can also overwrite a newer list from a concurrent onSuccess refetch if it resolves second. That second case does no harm in practice, since the list changes only on restart. Repair: check isCapturedProfileAuthorityActive(intent.profileContext) again inside .then. O1 removes the issue entirely by returning to invalidateQueries.

Round 1: my hand-written query-key note is resolved (the module constant is used now). S2 is resolved by 73eb033. The others were deferred as pre-existing or separate, and I didn't re-review them.

AI disclosure: written by Claude Opus 5.5 (claude-opus-5-5) via Claude Code, as an adversarial review sub-agent.

@Quick104 Quick104 left a comment

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.

Reviewed commit 73eb033669becf42d61f6c4cab04a1977d3dfc61.

  • S4 (P2) An older status read can remove a lock the recovery read just found. If a reconnect refetch starts before the settings refusal, the recovery GET can publish the new lock while that refetch is still running. When the older read finishes, TanStack Query replaces the cache with its result and the form offers an edit the server will refuse again. A test with two deferred responses reproduced the stale cache on this head and passed on 5c8876a. Coordinate the recovery read with in-flight reads for the same query key and retain the last successful status if recovery fails. settings.ts
  • S5 (P3) The form drops a Redis database clear the server accepts. Clear the Database number field, edit another field, then let the status query discover REDIS_URL. The form drops the empty redis.db draft and reports a successful save for the remaining edit, leaving the stored override in place. The validator can stay unchanged when the environment supplies the same URL and database already in use. The form sent the clear on the PR base and omitted it on this head. Preserve an empty redis.db draft when applying the environment locks. useSettingsForm.ts · admin.go
  • S6 (P3) A transient gateway error consumes the whole recovery attempt. A single 502 on the status GET after an environment refusal is enough to leave the field editable and its draft in every retry of the save until another read succeeds. With the app's query retry policy, the previous head recovered on the next GET. Keep the bounded retry for the recovery read and leave the editor available if those attempts fail. settings.ts · query-client.ts

Reviewed with Codex (gpt-6.2-sol).

@Quick104 Quick104 left a comment

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.

Adversarial review (gemini-4-neon, reviewed 73eb033)

Round-1 items (G1–G5): resolved (deferred to separate fixes; verified against the server storage-transition check, dependent-field / RedisGroup gating on main, and the pinned If-Match baseline behavior on 412).

New findings on 73eb033:

  • G6 (Medium) — Out-of-order manual refresh can overwrite newer sensitive-status cache entries (web/src/hooks/queries/admin/settings.ts:313-317)

    • Trigger: onError starts ADMIN_SENSITIVE_STATUS_QUERY.queryFn() outside QueryCache without awaiting it, so the mutation settles immediately and the form can save again while that read is still in flight. If a corrected save succeeds and invalidates sensitive-status (settings.ts:257-259), or a later validation_failed read completes first across a restart or rolling deploy, the earlier slow queryFn() call resolves last and writes unconditionally with queryClient.setQueryData(ADMIN_SENSITIVE_STATUS_QUERY.queryKey, status).
    • Impact: The stale snapshot replaces the newer cache entry and resets dataUpdatedAt to Date.now() (staleTime: 30_000), reverting configured or managed_by_env_vars across every useAdminSensitiveStatus observer for up to 30 seconds (e.g., flipping a newly saved secret back to unconfigured and hiding its Clear action, toggling Redis off, or re-enabling an env-locked field). In the reverse direction, setQueryData sets manual: true and does not cancel an already-in-flight Query refetch, which can overwrite the manual update when it completes.
    • Repair: Either guard the write with a monotonic refresh sequence and queryClient.getQueryState(key) checks (skipping setQueryData if a newer refresh started, dataUpdateCount advanced since start, or fetchStatus === "fetching"), or keep invalidateQueries so QueryCache owns cancellation and ordering and compute sensitiveStatusError in web/src/hooks/useSettingsForm.ts:25 as isError && sensitiveData == null so a failed background refetch preserves the last cached status.
  • G7 (Low) — New regression test does not wait for the direct queryFn() failure to settle and checks an empty environment map (web/src/hooks/queries/admin/settingsWrite.test.ts:185-210)

    • Trigger: On 73eb033, onError calls ADMIN_SENSITIVE_STATUS_QUERY.queryFn() directly instead of through QueryClient, so client.isFetching() remains 0 while the 502 read runs, and statusReads += 1 executes before the response body is decoded and rejected. The initial /sensitive-status fixture also returns managed_by_env_vars: {}, and the assertions only check sensitiveStatusError and dirtyKeys.
    • Impact: await waitFor(() => expect(client.isFetching()).toBe(0)) no longer waits for the failed refresh to finish, and the test does not verify that a previously known env-managed entry (envVar(...)) and sensitiveStatusReady stay intact after the 502.
    • Repair: Wait for the second /sensitive-status read to finish settling (for example by tracking completion of the second response read), seed a non-empty managed_by_env_vars entry on the first read, and assert sensitiveStatusReady and envVar(...) remain unchanged after the failure.

AI-assisted review: gemini-4-neon via Antigravity in T3 Code.

…ep a redis.db clear

The settings form reported the environment list as unavailable whenever a
re-read failed, even with a list already loaded, and the Storage page then
traded its editor and drafts for a reload notice. The form now treats the
status as unknown only when no list has loaded. That lets the refresh after
a refused save go back to invalidating the query, which coordinates it with
other reads, keeps the retry policy, and is dropped on sign-out, instead of
the direct read added in the previous commit.

The server accepts clearing redis.db under REDIS_URL, which is how a saved
number is removed, so the form keeps that draft when REDIS_URL takes over
instead of dropping it with the other environment-set keys.

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

silo-kody Bot commented Nov 20, 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 left a comment

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.

Adversarial review (gpt-6.2-sol, reviewed c2e4898)

S8 (P2) A replica-local lock can erase a valid draft

In web/src/hooks/useSettingsForm.ts:65, any status response that lists a key deletes its draft. SILO_DB_MAX_CONNECTIONS applies per process and can legitimately be set on just one API replica (internal/config/env_settings.go:18, :97). Edit Database max connections in General Settings after an unlocked replica answers the initial read. If a background status read hits the replica with the override, the form deletes the draft before any save. In a hook test, a later unlocked response re-enabled the field, but the next PUT contained only the unrelated subtitle edit. Keep the blocked draft and restore it to the save batch if the lock clears.

S9 (P3) Retrying Save before the status read finishes sends the refused batch again

web/src/hooks/queries/admin/settings.ts:312 starts invalidation in the background. General Settings re-enables Save as soon as the rejected mutation settles (web/src/pages/admin-settings/GeneralSettings.tsx:83, :237). With the status response held open after a 422, clicking Save again sent the same locked key and restarted the status query. Repeated clicks can delay recovery. Keep Save busy until this refresh settles, including when the read fails.

Review by Codex (gpt-6.2-sol).

@Quick104
Quick104 merged commit 6b57a44 into main Nov 20, 2026
22 checks passed
@Quick104
Quick104 deleted the fix/settings-save-skip-env-managed branch November 20, 2026 22:56

@Quick104 Quick104 left a comment

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.

Adversarial review (gemini-4-neon, reviewed c2e4898)

G9 (low): RedisGroup leaves enabledOverride stuck off when useSettingsForm drops redis.url while another draft remains

  • Location: web/src/pages/admin-settings/RedisGroup.tsx:44-53 (coupled with web/src/hooks/useSettingsForm.ts:65-85)
  • Trigger: Open General Settings on a server with redis.url stored (for example redis://cache:6379/3) and REDIS_URL unset. Flip Use Redis off (setEnabledOverride(false) + stageRedisUrl(form, "")) alongside either another General Settings edit (such as branding.login_subtitle) or a prior clear of redis.db to "". Restart the server with REDIS_URL set to the same URL (the settings ETag stays unchanged) and click Save. The 422 validation_failed refusal refreshes sensitive-status, and useSettingsForm drops redis.url (and non-empty redis.db) while keeping the other draft or the exempted empty redis.db clear, leaving form.dirtyCount > 0.
  • Impact: RedisGroup.tsx:49-52 resets enabledOverride only when form.dirtyCount === 0, so enabled stays false even though urlEnv is "REDIS_URL" and the redis.url clear draft was dropped. The Use Redis switch renders disabled and off while Redis is active from REDIS_URL, hiding the URL, Database, and connection-check controls until all remaining edits are saved or discarded. When an empty redis.db clear was staged, that draft stays counted in SaveBar and is still submitted on Save while its field is hidden inside the collapsed group.
  • Repair: Clear enabledOverride when urlEnv != null in web/src/pages/admin-settings/RedisGroup.tsx (for example, if (urlEnv != null && enabledOverride !== null) setEnabledOverride(null); after the dirtyCount === 0 check), so an environment-managed REDIS_URL shows the Redis fields and any retained redis.db clear.

AI-assisted review generated with gemini-4-neon via Antigravity (T3 Code).

Quick104 added a commit that referenced this pull request Nov 20, 2026
A failed settings read during Reload turned the form's loadError on even
though the snapshot was still loaded, and pages that show a load error
replaced the form, drafts and all. loadError now means what it says: the
snapshot never loaded, like the secret status since #4673.

The Use Redis switch also follows the stored URL again when the page goes
clean, not only when its Redis edits clear: switching Redis on with no
URL saved stages nothing, so Discard has to reset it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 20, 2026
With #4673, a draft for a key the environment takes over is dropped. When
SILO_JELLYFIN_ENABLED takes over a staged API switch-off, the Jellyfin
Web switch-off staged with it stayed, with no field to show it, and Save
wrote it. The page now drops that switch-off whenever the API switch-off
it goes with is no longer staged.

The Redis takeover test now keeps a staged database number, the case in
which the old switch state outlived #4673's draft drop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 21, 2026
…#4696)

* fix(web): stop settings pages from saving changes the admin can't see

Several settings pages hid a field when the setting that controls it
changed, but kept the field's unsaved edit. The save bar counted it and
Save wrote it.

- Storage (admin and setup wizard): the link-mode settings stay in view
  while they hold an edit.
- Setup wizard Connect apps: a typed Jellyfin address stays in view after
  Jellyfin is turned off.
- Playback: the device picker, Buffer ahead, and the lower-version
  preference stay in view while they hold an edit; saved device paths
  keep their rows.
- Compatibility: Jellyfin Web's switch-off is staged only with a real API
  switch-off and is taken back by any other flip.
- Redis: switching it off with no saved URL drops what was typed, and the
  switch follows REDIS_URL once the environment takes over.

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

* fix(web): mark kept rows and keep only the edited ones

Review follow-ups for the hidden-draft fix:

- A link-mode setting the selected mode doesn't use stays only while it
  holds an edit, row by row, rather than keeping the whole Cloudflare
  group in view.
- A row kept in view for an unsaved edit after its switch or mode would
  hide it carries the existing unsaved-change dot. SecretField forwards
  that marker.
- The device picker builds rows from the saved list first and orders a
  toggle by the rows, so switching a device back on restores the saved
  order instead of leaving a reordered list staged.

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

* fix(web): drop the Jellyfin Web switch-off when its API draft goes

With #4673, a draft for a key the environment takes over is dropped. When
SILO_JELLYFIN_ENABLED takes over a staged API switch-off, the Jellyfin
Web switch-off staged with it stayed, with no field to show it, and Save
wrote it. The page now drops that switch-off whenever the API switch-off
it goes with is no longer staged.

The Redis takeover test now keeps a staged database number, the case in
which the old switch state outlived #4673's draft drop.

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

* fix(web): one rule for the Jellyfin Web switch-off; keep saved device order

Review follow-ups on #4696:

- Compatibility: the switch handler is back to staging Jellyfin Web off
  with every API switch-off, and one layout effect drops that draft
  whenever an API switch-off isn't staged. That covers flipping back,
  switching off an API already saved off, the window right after a save,
  and the environment taking the switch over.
- Playback: a device toggle orders the list saved paths first, so turning
  a device off and back on restores the saved list even when detection
  lists the devices in another order.

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

* fix(web): keep a kept device picker from adding NVENC-incompatible paths

Review follow-ups on #4696:

- Playback: shown under NVENC or "none" only because it holds an unsaved
  change, the device picker now only takes devices back to their saved
  state. NVENC reads the setting as a CUDA device, so adding render paths
  there would save a value NVENC can't use.
- The Redis takeover test uses the server's shape (REDIS_URL manages both
  Redis keys) and keeps an unrelated edit staged, the case where the old
  switch state outlived the dropped drafts.

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

* fix(web): mark the changed devices in a kept device picker

Review follow-up on #4696: under a mode the device picker doesn't apply
to, a device row whose switch differs from the saved list now carries the
unsaved-change dot, like every other row kept for an edit.

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

* fix(web): treat a device toggle back to the saved list as no change

Review follow-up on #4696: a saved device list that isn't in canonical
form (a space after a comma) never matched the toggled string, so
switching back to the saved devices left a draft with every switch of a
kept picker locked. A toggle that lands on the saved devices now drops
the draft.

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

* test(web): check that only the unrelated edit survives a Redis takeover

Review follow-up on #4696.

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

* test(web): stage the Redis number with the switch-off in the takeover test

Review follow-up on #4696: the fixture reports a saved database number,
as the server does for a saved URL, so the switch-off stages both Redis
keys and the test checks that only the unrelated edit survives REDIS_URL
taking them over.

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

* fix(web): keep a device revert staged while a save settles

Review follow-up on #4696 (Kody): a device toggle back to the saved list
reset the draft directly, so during a save of that setting the revert
was dropped and the save wrote the unwanted devices. The toggle now
stages the saved string itself and lets the form decide whether that
undoes the edit, as it does for every other field; only an unset value,
which the snapshot never carries, is dropped directly, and not while a
save is in flight.

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

* fix(web): let a kept device picker always reach the saved list

Review follow-up on #4696 (Sol S7): after a settings refresh, a staged
device list could match the saved devices or differ only in order, and
the kept picker under NVENC or Software then locked every switch. Under a
mode the picker doesn't apply to, any device can now be switched off and
only saved devices switched on, so the saved list is always reachable and
no render path can be added for NVENC. A list that differs only in order
marks its selected rows.

Component tests cover NVENC refusing a new render path and an order-only
list going back to the saved one; both fail on main.

Co-Authored-By: Claude Opus 5.5 <[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

bug Something isn't working impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant