Resolve #329: CloudKit JS alternate backend + browser-flag defaults#335
Conversation
Enables the previously-disabled "CloudKit JS (browser)" toggle in the
mistdemo web UI and wires real container.privateCloudDatabase calls
(performQuery / saveRecords / deleteRecords) behind it, so each CRUD
operation can be driven either through MistKit on the server or
CloudKit JS in the browser against the same container with the same
auth token.
- index.html: replace cloudKitJsNotWired() short-circuits with real
CloudKit JS handlers; add fieldsToCKJS() to wrap the demo's flat
{key: "value"} shape into CloudKit JS's {key: {value: ...}} form;
add runCloudKitJsOperation() to surface the hasErrors/errors payload
pattern that CloudKit JS uses in place of throwing.
- Update mode hint: both backends share the same Apple ID session
token, container, and REST surface; only the SDK shape differs.
- Move the index-page tests into WebServerTests+Index.swift (matching
the existing +CRUD extension pattern) and add a smoke test asserting
the CDN script tag, an enabled toggle, the three call sites, and
absence of the placeholder.
No server-side changes: the auth-token capture flow already shares
the ckWebAuthToken across both modes via WebAuthTokenStore.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The auth-token command's whole purpose is to capture a token, so the default of auto-opening the browser is the right UX. The web command is a long-running server that's often driven from another machine (or a non-default browser), so auto-launch is the wrong default there. - Rename AuthTokenConfig.noBrowser → openBrowser (default: true). - Rename WebConfig.noBrowser → openBrowser (default: false). - Add BrowserFlagResolver shared between the two configs: --no-browser sets no.browser=true (wins if both flags are set), --browser sets browser=true, otherwise the per-command default applies. - Both commands accept --browser and --no-browser; help text states the per-command default explicitly. - Update README options table and the AuthTokenConfig / AuthTokenCommand tests; add coverage for the resolver's precedence rule. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 330-interactive-mistdemo #335 +/- ##
============================================================
- Coverage 70.23% 70.21% -0.03%
============================================================
Files 543 545 +2
Lines 14969 14999 +30
============================================================
+ Hits 10514 10532 +18
- Misses 4455 4467 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review — PR #335: CloudKit JS alternate backend + browser-flag defaultsOverviewThis PR wires up CloudKit JS as the alternate browser-side backend for the MistDemo web UI, and refactors the browser-open UX from a single What Works Well
Issues and Suggestions1. Missing
|
Summary
container.privateCloudDatabasedirectly when CloudKit JS mode is active. Same Apple ID session token, same container, same REST surface as MistKit mode — only the SDK shape differs.auth-tokenkeeps its default of auto-opening the browser;webflips to not auto-opening (long-running server, often driven from another machine). Both commands accept--browserand--no-browser;--no-browserwins if both are set.Test plan
swift testfromExamples/MistDemo— 920 tests pass.swift testfrom repo root — 483 tests pass.mise exec -- swift-format -i -r Sources/ Tests/— clean.mise exec -- swiftlint— 0 violations in 487 files.swift run mistdemo web --api-token "$CLOUDKIT_API_TOKEN" --browseropens browser, both mode toggle buttons work, CRUD operations succeed in both modes against the same container.swift run mistdemo auth-token --api-token "$CLOUDKIT_API_TOKEN"still opens the browser by default;--no-browsersuppresses it.Out of scope
330-interactive-mistdemobefore Add public database interface to MistDemoApp and web #275 starts.🤖 Generated with Claude Code
Perform an AI-assisted review on