Skip to content

feat(settings): write setting values through v2 - #366

Merged
Quick104 merged 5 commits into
mainfrom
apiv2-stack/18-settings-writes-v2
Sep 23, 2026
Merged

Quick104 merged 5 commits into
mainfrom
apiv2-stack/18-settings-writes-v2

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

Setting value writes now go through /api/v2 on the shared APIv2Client, without mutation IDs. Each settings surface keeps one pending value per key and retries only that latest value, on a bounded backoff, while its owner still matches. When the retries run out, the surface holds that key and offers "Try Again" and "Discard Held Change" (owner decision D4). The v1 write methods, the mutation-ID plumbing and the unwired dispatchSettingCommand are gone.

Problem

Inventory rows 44, 45 and 46 are live v1 writes in SiloAPI+Settings.swift:

  • putValue: PUT /api/v1/settings/values/{key}
  • putNavigationShortcutItem: PUT /api/v1/settings/values/nav.shortcuts/item
  • deleteValue: DELETE /api/v1/settings/values/{key}

Three settings surfaces call them: the player's device settings (PlayerSettingsFlusher), the profile subtitle and metadata preferences (ProfileSettingsWriter / ProfilePrefsEditor), and the interface customization outbox (UICustomizationPreferences).

All three surfaces depended on v1 idempotent replay. They sent X-Silo-Mutation-Id and read X-Silo-Idempotent-Replay. They also retried under the same ID and handled 409 mutation_id_conflict.

v2 has none of that. The server ignores the header, rejects a mutation_id body member with 422, and replays nothing (claim A4). Every accepted write advances the row's revision. The openapi contract marks all three operations natural_idempotent, and D4 sets the retry rule.

Main also had an unwired v2 path, APIv2Client.dispatchSettingCommand, plus its SettingsMutationCommand, SettingsMutationAuthority and SettingsMutationHold types. Nothing called any of it.

Solution

Wire layer. APIv2Client+Settings.swift gains updateSettingValue, updateNavigationShortcut and deleteSettingValue. All three go through a new internal settingsWrite in APIv2Client.swift, which replaces dispatchSettingCommand. settingsWrite works like settingsRead:

  • It checks the probe verdict and captures the owner.
  • It refuses a write for a profile other than the session's selected one. The household-parent profile_id query is never sent.
  • It refuses a request whose pinned requestIdentity no longer matches.
  • It runs inside withOwnerFence.

All three are natural_idempotent, so HTTPClient.shouldAttemptRefresh no longer excludes settings value PUT/DELETE: a write sent with an expired bearer refreshes once and re-sends the same value under the same captured owner, instead of entering the D4 backoff with the stale token. docs/native-api-v2.md now says so.

Each operation asserts its one success status: 200 for a PUT, 204 for a DELETE (I2). A PUT receipt must describe the row that was addressed: the key, the scope, a revision above 0, the profile, this device's id for profile_device, this client family for profile_client, and the string library_id or series_id. Any other receipt throws the new APIv2Error.unexpectedSettingReceipt, and the write counts as uncertain. A DELETE 404 problem means nothing is stored there and becomes SettingsAPIError.noValueAtScope. Request bodies are exactly {"value": …} and {"item": …, "present": …}, coded with SettingsWireCoding, so value keys stay verbatim.

Errors. SettingsAPIError.from now maps v2 problems:

  • A 422 at path.key or query.keys becomes unknownSetting.
  • A 422 at query.scope becomes scopeNotAllowed.
  • A 422 at body.value or body.item becomes invalidValue.
  • Other problems become server(status:code:message:).
  • HTTPError.requestIdentityChanged and authorityChanged become the new ownerChanged.

The v1 envelope mapping and the mutationIdConflict and clientLocalSetting cases are deleted, because v2 cannot produce them. The effective read now reports a row for another profile as a refused response, not as an owner change.

D4 failure classes. A new SettingsAPIError.writeFailure puts every failure in one class:

  • retry: transport failure, 5xx, 408, 429, a 409 compare-and-set conflict, a 401 that outlived refresh, or a mismatched receipt.
  • release: any other definite refusal.
  • ownerChanged
  • waitForCondition: no profile selected, or a v1-only server.

SettingWriteRetryPolicy carries the bound. The default allows 5 retries at 1, 2, 4, 8 and 16 s, capped at 60 s. The interactive policy allows 3 retries at 1, 2 and 4 s.

Surfaces.

  • Player device settings (PlayerSettingsFlusher). The player.pendingDeviceSettingWrites.* journal and its partitioning stay (I7). The background flush stays. PendingSettingWrite drops mutationId and gains failedAttempts and isHeld. Entries from earlier builds still decode, and their mutationId is ignored (I17).
    • Past the bound, the key is held. It stays in the journal and in memory, but no flush sends it. A new edit of that key replaces the hold, and other keys keep flowing.
    • An owner change keeps the write for the next trigger in the same partition, or leaves it to its own partition's journal.
    • A refusal drops the write and notifies the settings screen once.
    • PlayerSettings exposes heldDeviceSettingKeys and rejectedDeviceSettingChange. discardHeldDeviceSettingChanges() reads the effective values before dropping the hold. If that read fails, the hold stays, because the discarded value is the only copy on the device. A v1-only server has no stored value, so there the hold is dropped and the local value stays. refreshFromServer keeps painting unsettled values over the server's older answer. The legacy import never overwrites a key with its own pending change.
  • Profile subtitle and metadata preferences. ProfileSettingsWriter.write retries on the interactive policy while the editor confirms the value is still the latest for its key and profile. It throws HeldChange after the bound and Superseded when a newer edit arrives. The mutation-ID map is gone.
    • ProfilePrefsEditor records held values per key and profile, keeps showing them across reloads, and never re-sends them on its own. Editing that control again sends the new value, even when it matches the baseline, because the held value may have reached the server.
    • The editor adds hasHeldChanges, retryHeldChanges(), discardHeldChanges() and a .held save state. discardHeldChanges() repaints each discarded control from its last saved value before it reloads, so an offline discard cannot leave the value on screen to be sent with the next edit.
    • A definite refusal (for example a 422 at body.value or a 403) is released: the control goes back to its saved value, and the refused value is not queued again. Only owner changes and missing-profile or v1-only conditions stay owed for the next save.
  • Interface customization (UICustomizationPreferences). Outbox entries carry a local operationId, which is never sent, and a retry state. Caches that stored mutationId still decode.
    • A retryable failure schedules one backoff timer that re-queues only the failed entries. Past the bound the entry is held.
    • A refresh skips held entries and does not paint over their keys.
    • A definite refusal releases the value write. Shortcut rejections still roll back and refresh.
    • hasHeldChanges is observable. retryHeldChanges() and discardHeldChanges() are new; discarding also rolls back a held shortcut.

UI. New HeldSettingChangesSection (iOS and macOS) and TVHeldSettingChangesRows (tvOS, plain buttons in the pane's native focus graph) show the text "A change couldn't be saved to the server. It stays on this device until you try again or discard it." next to "Try Again" and "Discard Held Change". They appear in Playback, Subtitles and Interface settings on iOS and macOS, and in the Playback, Subtitles and General panes on tvOS. The tvOS Playback rows sit above Reset, so pane entry focus is unchanged. Playback settings also show a one-time "Not Saved" notice with OK when the server refuses a device setting change. If "Discard Held Change" can't reach the server, the Playback rows keep the held change and change their footer to "Couldn't reach the server to discard this change. It stays on this device until the server can be reached."

Deleted. SiloAPI.putValue(…mutationId:…) and the v1 shortcut and delete bodies, SettingValueWriteReceipt, newSettingMutationId(), dispatchSettingCommand, SettingsMutationCommand, SettingsMutationAuthority and SettingsMutationHold. The v1 write tests and their stub routes are removed from SettingValuesAPITests. StoredSettingValue is now Decodable and takes the string library_id.

Failure outcomes

All three operations are natural_idempotent (openapi x-silo-retry-safety).

Outcome What counts Player device settings Profile subtitle / metadata Interface customization
Definite success PUT 200 with a receipt for the addressed row. DELETE 204, or 404 (nothing stored). Retired from the journal. Baseline advances; "Saved". Entry removed from the outbox.
Definite failure, not sent No profile selected; v1-only server (probe verdict or legacy 404). Kept, no timer; the next trigger sends it. A DELETE against a v1-only server settles locally. Kept as owed for the next save. A v1-only server shows the update message and stops the drain. Kept, no timer; the next refresh sends it.
Definite failure, not sent Owner changed before dispatch. Stays with its own partition; never sent for another owner. "The profile changed before this could be saved." The operation context check drops it.
Definite failure, response 400, 403, 404 on PUT, 410, 422, or an unexpected 2xx status. Dropped, logged, and reported once ("Not Saved" / OK). Reported once with the server's message or "The server didn't accept this change (HTTP n)."; logged. The control goes back to its saved value, and the refused value is not sent again. Value write released; shortcut rolled back and refreshed; error shown.
Uncertain or transient No response, timeout, 5xx, 408, 429, 409 conflict, 401 after refresh, mismatched receipt; also an owner change while the request was in flight. Retried as the latest value, 5 retries at 1–16 s. Then held: kept locally and in the journal, and not sent until "Try Again". "Discard Held Change" reads the server first, then drops the hold and repaints the server value. If the server can't be reached, the change stays held and the rows say "Couldn't reach the server to discard this change. It stays on this device until the server can be reached." Retried inline, 3 retries at 1–4 s, while still the latest value. Then held until "Try Again", a new edit, or "Discard Held Change". Discarding puts the control back to its last saved value, even when the reload fails, so the discarded value is never sent. Retried by a backoff timer, 5 retries at 1–16 s. Then held: kept in the cache and shown, and not replayed by refresh until "Try Again" or "Discard Held Change".

D4 is the plan's one named exception to "uncertain: hold, never auto-replay". It allows a bounded replay of the latest value only, and only while the captured owner matches. No request carries a mutation ID.

Validation

  • iOS, tvOS and macOS builds passed on the final branch.
  • iOS tests (SiloTests/SettingValueWritesTests SiloTests/SettingValuesAPITests SiloTests/PlayerSettingsFlushTests SiloTests/UICustomizationPreferencesTests SiloTests/ProfileAndQualitySettingsTests SiloTests/OverlayPrefsStoreTests SiloTests/APIv2ContractTests SiloTests/PlaybackProtocolV3Tests SiloTests/DurableCommandStoreTests SiloTests/CredentialIdentityTests) passed: 408 tests, 0 failures. The same classes under SiloTVTests passed: 403 tests, 0 failures.
  • Before the review fixes, the full SiloTests suite passed (1626 tests, 2 skipped, 0 failures) and the full SiloTVTests suite passed (1483 tests, 2 skipped, 0 failures) on this branch.
  • After the review fixes (offline discard, refused profile writes), ProfileAndQualitySettingsTests, PlayerSettingsFlushTests, SettingValueWritesTests and UICustomizationPreferencesTests passed on iOS (209 tests) and tvOS (204 tests) with 0 failures. The two new ProfileAndQualitySettingsTests cases fail against the editor without the fix.
  • scripts/ci/check-no-api-v1.sh passed. The v1 literal counts drop in SiloAPI+Settings.swift, SettingValueModels.swift, PlayerSettingsFlusher.swift and SettingValuesAPITests.swift.
  • The owner-fence count (withOwnerFence / sameCredentialIdentity lines in iosApp/iosApp) stays at 60. settingsWrite replaces the fence that dispatchSettingCommand held.
  • New tests:
    • SettingValueWritesTests (on StubURLProtocol through APIv2TestStub) covers:
      • the PUT, shortcut and DELETE wire shape: paths, the scope and string library_id query, and the profile, device and client-family headers, with no X-Silo-Mutation-Id and no profile_id
      • exact-body encoding
      • the single success status
      • receipt mismatches, which are uncertain and retryable
      • a write for another profile, which is never sent
      • an answer that arrives after a profile switch, which is discarded
      • each problem type mapping to its SettingsAPIError and write-failure class
      • the retry schedule
      • an expired bearer that refreshes once and re-sends the write (testExpiredBearerRefreshesAndResendsTheWriteOnce)
    • PlayerSettingsFlushTests covers:
      • a hold after the bound, persisted in the journal, with no send by a later flush, and "Try Again" sending the change
      • "Discard" clearing memory and the journal and sending nothing
      • a new edit replacing a hold while other keys keep flowing
      • a refusal reported once
      • an owner change arming no timer
      • a legacy journal entry with mutationId still restoring
      • PlayerSettings keeping a held value across a refresh until it is discarded
      • an offline discard that keeps the change held and the value unchanged, then completes once the effective read succeeds
    • ProfileAndQualitySettingsTests covers:
      • bounded inline retry, then a hold, then "Try Again"
      • "Discard" repainting the server value without writing
      • a new edit replacing a held metadata language
      • a refusal that is not retried
      • an offline discard (writes and the effective read both fail) that repaints the last server value and sends nothing with the next sibling edit
      • a refused subtitleLanguage (422 at body.value, and 403) that goes back to the saved value and is sent exactly once across a later subtitleMode edit
    • UICustomizationPreferencesTests covers a hold after the bound that survives a restart, is skipped by refresh, and is discarded without a write, plus "Try Again" with a fresh budget. The shortcut and card-presentation replay tests now assert that the same desired value is re-sent, not the same mutation ID.
  • The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, built for macOS and passed the v1 path guard. Every branch in the stack builds on its own.
  • Not run: the plan's manual check (change a player setting with the network off, on a device or simulator against a bridge server).

Risks and follow-ups

  • Every retry, whether automatic or "Try Again", advances the row's revision. Last writer wins across devices, as on v1. This is the accepted D4 trade-off.
  • Profile-editor holds live in memory for the life of the settings view model. They are not persisted across a relaunch. Before this change, a failed profile write was also only owed in memory.
  • Sign-out and server switch do not clear the per-(server, profile, device) player journal partitions or the per-(server, profile, family) interface outboxes. That behavior is unchanged. A held change reappears only for the same server and profile, and settingsWrite refuses any other owner. Plan §9's "sign-out clears barriers" is left for a follow-up that adds a key enumeration to SharedDefaults.
  • The server still advertises supports_idempotent_writes: true (settings_values.go:328). Nothing reads it.
  • SettingScopeIdentity.profileLibrary still takes an Int and is sent as a string. No write surface targets profile_library today.
  • The new held-change rows were checked by build only, not by hand on any platform. The tvOS rows are plain Buttons in the pane's native focus graph, placed after the existing sections.
  • Expected conflicts: feat(player): support all marker occurrences #343 edits APIv2Client.swift near the settings helpers. feat(watch-party): add iOS and tvOS rooms and synchronized playback #347 and the auth lane edit HTTPClient.swift, where this PR changes the requestData doc comment and removes the settings-write line from shouldAttemptRefresh.

AI disclosure

Code and description written by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.


Part 18 of 50 in the Apple API v2 stack. Base: apiv2-stack/17-settings-reads-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4379ca70-cbdb-40c1-8b73-441788b7542c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T13:43:37.969125Z ffba129 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

@Quick104

Copy link
Copy Markdown
Contributor Author

Code review summary

Reviewed head: bfb41315 (apiv2-stack/18-settings-writes-v2).

Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration.

Verified findings, all fixed on this branch:

  • major: If the server is unreachable, a discarded subtitle change still reaches the server on the next subtitle edit
  • minor: If the server is unreachable, "Discard Held Change" for playback settings keeps the discarded value active on the device
  • minor: Profile subtitle writes the server definitely refused are queued again and re-sent, which contradicts the PR's failure table
  • whole-stack review: D4 settings retries resend an expired bearer because settings PUT/DELETE are still excluded from 401 refresh

Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no /api/v1 request from the new builds except the retained health probe.

Remaining: no open verified findings. Merge in stack order.

Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack.

Review by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfb413157c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +180 to +182
private var heldSubtitleEditorValues: [SubtitleWriteIdentity: String] = [:]
/// The metadata language write that ran out of automatic retries.
private var heldMetadataWrite: MetadataWrite?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Persist held profile changes beyond the editor

When a profile write exhausts its retries, these in-memory properties are the only record of the held value. SettingsView owns the editor through a newly created @State SettingsViewModel, so recreating the Settings view or terminating the app destroys the value and its Try Again/Discard state, despite the UI saying it stays on the device. Persist held values per profile and key, as the other settings outboxes do.

Useful? React with 👍 / 👎.

Comment on lines +1188 to +1189
pendingSyncWrites.removeValue(forKey: key.rawValue)
saveCache(for: context.cacheKey)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reconcile optimistic values after a definitive refusal

When a value write receives a definite refusal such as 403 or 422, this removes the durable outbox entry but leaves the optimistically assigned storedPrimaryMenu or storedCardPresentation in the cache, and it does not schedule the “next refresh” mentioned by the comment. The app therefore continues applying a setting the server rejected—potentially across restart—until an unrelated refresh occurs. Restore the prior value or fetch the effective value before permanently releasing the entry.

Useful? React with 👍 / 👎.

Comment on lines +1700 to +1702
for (key, write) in pendingSyncWrites where write.retry.isHeld {
pendingSyncWrites.removeValue(forKey: key)
if let settingKey = SettingKey(rawValue: key) { setSyncError(nil, for: settingKey) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep held values when offline discard cannot reconcile

If the user discards a held value while the server is still unreachable—the common condition that created the hold—this removes the outbox entry and persists the optimistic value before refresh() is attempted. The failed refresh leaves that discarded menu or card presentation active in the cache while hasHeldChanges becomes false, so the user can no longer retry or discard it. Keep the hold until an authoritative read succeeds, or retain enough prior state to roll it back locally.

Useful? React with 👍 / 👎.

@Quick104
Quick104 force-pushed the apiv2-stack/18-settings-writes-v2 branch from bfb4131 to b46bf1c Compare September 23, 2026 13:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b46bf1c73a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if pendingMetadataWrite == held { pendingMetadataWrite = nil }
preferredMetadataLanguage = savedBaseline.metadataLanguage ?? PlaybackPrefSentinel.none
}
heldSubtitleEditorValues.removeAll()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve held changes for inactive profiles

When this editor survives a profile switch, heldSubtitleEditorValues can contain entries for both the previously bound profile and the current one, but discarding the current profile's held change removes the entire dictionary. For example, if profile A has a held subtitle change and profile B later has one, choosing Discard while viewing B silently deletes A's retry state as well. Remove only entries whose profileId matches boundProfileId so another profile's unsaved change remains recoverable.

Useful? React with 👍 / 👎.

@Quick104
Quick104 force-pushed the apiv2-stack/17-settings-reads-v2 branch from 01c8da7 to cca0d4b Compare September 23, 2026 13:36
Base automatically changed from apiv2-stack/17-settings-reads-v2 to main September 23, 2026 13:36
Quick104 and others added 5 commits September 23, 2026 09:36
The setting value writes (PUT and DELETE /api/v1/settings/values/{key}
and PUT .../nav.shortcuts/item) still used v1 and its mutation-id replay:
X-Silo-Mutation-Id, X-Silo-Idempotent-Replay and 409
mutation_id_conflict. v2 has no replay. It ignores the header, rejects a
mutation_id body member, and marks all three writes natural_idempotent.
Main also carried an unwired dispatchSettingCommand with its command
types.

The writes now go through the shared APIv2Client (updateSettingValue,
updateNavigationShortcut and deleteSettingValue) via a new owner-fenced
settingsWrite. It refuses another profile and a stale pinned identity,
asserts 200 or 204, checks the receipt against the addressed row, and
maps a DELETE 404 to noValueAtScope. SettingsAPIError maps v2 problems
by rejected location, gains ownerChanged, and sorts every failure into
the D4 classes retry, release, ownerChanged and waitForCondition.

Per owner decision D4, each surface keeps one pending value per key and
retries only the latest value on a bounded backoff while its owner still
matches. After the bound it holds that key and offers "Try Again" and
"Discard Held Change". This covers the player flusher (whose journal and
background flush stay), the profile subtitle and metadata editor, and
the interface customization outbox. Old journals and caches that carry
mutation ids still decode. Refused changes are released and reported
once. The v1 write methods, SettingValueWriteReceipt,
newSettingMutationId, dispatchSettingCommand and the SettingsMutation*
types are deleted.

Stack-PR: W4-B
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Use HeldSettingChange.message directly instead of a private forwarding
property, and share the flusher's locked held-key computation between
heldKeys and publishHeldKeys.

Stack-PR: W4-B
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Discarding a held subtitle or metadata change relied on the reload to
repaint the control. Offline, the reload fails and leaves the discarded
value on screen, so the next edit of any subtitle control sent it along
with that edit. A subtitle value the server definitely refused (422, 403)
was also kept as owed and sent again with the next edit.

Discard now puts each control still showing a discarded value back to its
last saved value before reloading. A definite refusal is released: the
control goes back to its saved value and nothing is queued. Owner changes
and missing-profile or v1-only conditions stay owed as before.

Stack-PR: W4-B
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… server

"Discard Held Change" for player device settings dropped the hold and then
refreshed. Offline, the refresh reapplied the local cache, which holds the
discarded value, so playback kept using it while the screen no longer
marked it unsaved.

Discard now reads the effective values first and drops the hold only when
that read succeeds, then paints the server's values. If the server can't be
reached, the change stays held and the Playback rows say so. A v1-only
server stores nothing, so there the hold is dropped and the local value
stays.

Stack-PR: W4-B
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Settings value PUT/DELETE are natural_idempotent, but HTTPClient kept them
on the single-dispatch exclusion list. A write after the access token
expired got a 401 with no refresh, and the D4 retry loop resent the same
stale bearer until the change was held.

Drop the exclusion so a 401 refreshes once and resends under the same
captured owner. A 401 that survives the refresh still maps to .retry.

Stack-PR: W4-B
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 force-pushed the apiv2-stack/18-settings-writes-v2 branch from b46bf1c to ffba129 Compare September 23, 2026 13:37
@Quick104
Quick104 merged commit dd9db56 into main Sep 23, 2026
3 of 6 checks passed
@Quick104
Quick104 deleted the apiv2-stack/18-settings-writes-v2 branch September 23, 2026 13:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffba12961d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

profileID: profileID,
expectedIdentity: expectedIdentity
)
return try Self.settingReceipt(response, key: key, scope: scope, profileID: profileID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject PUT receipts that contain a different value

When a whole-value PUT returns 200 for the expected key and scope but the receipt contains a stale or incorrectly encoded value, this call accepts it because the requested value is never passed into settingReceipt. The settings surfaces then retire their pending operation or advance their saved baseline even though the receipt says the desired value was not stored, leaving no retry path. Pass the requested value into the receipt validator and compare it using isSemanticallyEquivalent(to:).

Useful? React with 👍 / 👎.

Comment on lines +1442 to +1444
case .release:
pendingDeletes.removeValue(forKey: identity)
saveCache(for: context.cacheKey)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore reset state after a definitive DELETE refusal

When resetCardPresentationToInherited() receives a definitive DELETE refusal such as 403 or 422, it has already persisted storedCardPresentationSource = nil; this branch removes the only pending delete and records an error, which also prevents the reset method's follow-up refresh. The UI therefore reports the card setting as inherited and hides the reset action even though the server still has the explicit family override, until an unrelated refresh occurs. Restore the prior source or reconcile with an authoritative read before releasing the delete.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant