Skip to content

fix(desktop): map backend settings keys for recording-permission and private-cloud-sync#6420

Merged
beastoin merged 2 commits into
mainfrom
fix/desktop-settings-decode-6417
Apr 8, 2026
Merged

fix(desktop): map backend settings keys for recording-permission and private-cloud-sync#6420
beastoin merged 2 commits into
mainfrom
fix/desktop-settings-decode-6417

Conversation

@beastoin
Copy link
Copy Markdown
Collaborator

@beastoin beastoin commented Apr 8, 2026

Summary

  • Add CodingKeys to RecordingPermissionResponse mapping enabledstore_recording_permission
  • Add CodingKeys to PrivateCloudSyncResponse mapping enabledprivate_cloud_sync_enabled
  • Fixes Settings page decode errors — the backend returns different key names than Swift expected

Tests

6 unit tests in SettingsResponseTests.swift:

  • ✅ RecordingPermissionResponse decodes store_recording_permission: true
  • ✅ RecordingPermissionResponse decodes store_recording_permission: false
  • ✅ RecordingPermissionResponse fails with wrong key enabled
  • ✅ PrivateCloudSyncResponse decodes private_cloud_sync_enabled: true
  • ✅ PrivateCloudSyncResponse decodes private_cloud_sync_enabled: false
  • ✅ PrivateCloudSyncResponse fails with wrong key enabled

All 6 tests pass locally.

Risks / Edge Cases

  • If backend ever normalizes to return {"enabled": ...}, these CodingKeys would need updating
  • Mobile Flutter app already uses the current backend keys — no backend change needed

Fixes #6417

🤖 Generated with Claude Code

beastoin and others added 2 commits April 8, 2026 01:37
…teCloudSyncResponse

Map Swift `enabled` field to actual backend keys: `store_recording_permission`
and `private_cloud_sync_enabled`. Fixes decode errors on Settings page load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 tests covering RecordingPermissionResponse and PrivateCloudSyncResponse
decode with correct backend keys and failure with wrong keys.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 8, 2026

Greptile Summary

This PR fixes a JSON decoding bug in the macOS desktop app where RecordingPermissionResponse and PrivateCloudSyncResponse were silently failing to decode because the Swift property name enabled didn't match the actual backend JSON keys (store_recording_permission and private_cloud_sync_enabled). Adding explicit CodingKeys resolves the mismatch, confirmed by reading backend/routers/users.py lines 209 and 259.

Confidence Score: 5/5

Safe to merge — targeted bug fix with correct key mappings verified against the backend source and covered by dedicated unit tests.

The CodingKeys additions are confirmed correct by reading backend/routers/users.py (lines 209 and 259). All remaining findings are P2 or absent. Tests are comprehensive.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/APIClient.swift Added CodingKeys to RecordingPermissionResponse and PrivateCloudSyncResponse to correctly map Swift enabled to backend JSON keys; fix verified against backend routers.
desktop/Desktop/Tests/SettingsResponseTests.swift New test file with 6 unit tests covering both structs for true/false decoding and explicit rejection of the old wrong key enabled.

Sequence Diagram

sequenceDiagram
    participant App as Desktop App
    participant API as Backend API

    App->>API: GET /v1/users/store-recording-permission
    API-->>App: {"store_recording_permission": true}
    Note over App: CodingKeys maps<br/>store_recording_permission → enabled
    App->>App: RecordingPermissionResponse(enabled: true) ✅

    App->>API: GET /v1/users/private-cloud-sync
    API-->>App: {"private_cloud_sync_enabled": false}
    Note over App: CodingKeys maps<br/>private_cloud_sync_enabled → enabled
    App->>App: PrivateCloudSyncResponse(enabled: false) ✅
Loading

Reviews (1): Last reviewed commit: "test(desktop): add unit tests for settin..." | Re-trigger Greptile

@beastoin
Copy link
Copy Markdown
Collaborator Author

beastoin commented Apr 8, 2026

All checkpoints passed — ready for merge

Checkpoint Status
CP1-CP6
CP7 Reviewer ✅ PR_APPROVED_LGTM
CP8 Tester ✅ TESTS_APPROVED (6/6 tests pass)
CP9 Live test ⏭️ Skipped (settings decode, no audio paths)

Awaiting human merge approval.

by AI for @beastoin

@beastoin
Copy link
Copy Markdown
Collaborator Author

beastoin commented Apr 8, 2026

CP9 + E2E Test Results — Mac Mini (pr6420 named bundle)

Build

  • Clean rebuild from fix/desktop-settings-decode-6417 (commit 73b2f0e79)
  • Verified CodingKeys strings in binary: store_recording_permission, private_cloud_sync_enabled present
  • Named bundle: pr6420.app (com.omi.pr6420)

CP9: Settings Decode Fix Verification ✅

Before fix (v0.11.251):

[error] Decoding error - key 'enabled' not found
[error] Failed to load backend settings: The data couldn't be read because it is missing.

After fix (pr6420 build):

grep "decode.*error|enabled.*not found|Failed to load backend settings" → (empty)
SettingsSyncManager: synced from server ✅

Zero decode errors — both RecordingPermissionResponse and PrivateCloudSyncResponse decode successfully.

Privacy Settings Loaded Correctly

  • Store Recordings: ON (decoded from store_recording_permission)
  • Private Cloud Sync: ON (decoded from private_cloud_sync_enabled)
  • Encryption: Active

Screenshots

Settings General
Settings

Privacy Settings (the fix)
Privacy

Gotcha Found During Testing

Initial build used stale cached binary from SWIFT_BUILD_DIR=/tmp/swift-build-* (shared across worktrees). Had to delete Desktop/.build/debug/Omi Computer* and force full rebuild to pick up changes. The SWIFT_BUILD_DIR env var doesn't override SwiftPM's default .build/ directory when used with --package-path.

by AI for @beastoin

@beastoin beastoin merged commit b0ac37d into main Apr 8, 2026
3 checks passed
@beastoin beastoin deleted the fix/desktop-settings-decode-6417 branch April 8, 2026 02:04
@beastoin
Copy link
Copy Markdown
Collaborator Author

beastoin commented Apr 8, 2026

lgtm

Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
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.

Desktop: Backend settings decode error — key mismatch for recording-permission and private-cloud-sync

1 participant