Uh oh!
There was an error while loading. Please reload this page.
Wire assets/rereference web route and add assets/upload UX (#31) - #393
Conversation
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 @@## v1.0.0-beta.2 #393 +/- ##
================================================
Coverage ? 70.96% ================================================
Files ? 168 Lines ? 3844 Branches ? 0 ================================================
Hits ? 2728 Misses ? 1116 Partials ? 0
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:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- RereferenceAssetError: document its CLI-layer role and relationship to CloudKitError (it wraps the thrown CloudKitError; stays in MistDemo). - Integration: extract PNG byte-encoding into a dedicated PNGEncoder enum; IntegrationTestData.generateTestImage now delegates to it. - WebServer+Pending: enumerate the remaining pending calls and repoint the landed-but-unwired stubs from the closed scaffolding issue #370 to the new route-wiring tracking issue #394. - Tests: split MockBackend into +RecordOperations / +ServiceOperations extensions to clear the file_length warning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code ReviewCriticalNone found. The critical transport-separation invariant is fully upheld — Major1.
The Suggested fix: Pass 2. Implicit cross-file global dependency in JS:
Suggested fix: Either declare it with Minor3.
The Suggested fix: Expand the 4. Missing test coverage for
5.
The Nit6. The file now handles user discovery, asset upload, and rereference in addition to record/zone changes — seven processors total. Consider splitting asset and user processors into their own files in a follow-up to keep the naming honest. 7. Pre-existing XSS note (not introduced here)
SummaryThe transport safety architecture is correct and the import/ACL conventions are followed throughout all new files. The JS XSS surface for new code is clean ( The main substantive concern is Major #1 — 🤖 Generated with Claude Code |
Bind CloudKit's assets/rereference endpoint and add an ergonomic MistKit API, flipping the MistDemo #31 stubs to real implementations. - openapi.yaml: add the assets/rereference path + AssetRereferenceResponse ({ assets: [AssetValue] }); regenerate the MistKitOpenAPI client. - CloudKitService.rereferenceAssets(_:zoneID:database:) -> [Asset] (thin wrapper) and rereferenceAsset(fromRecord:toRecord:) -> RecordInfo (compose: rereference + modify the target). - Verified live: the endpoint validates atomically — a bad entry (missing source record) fails the whole request with HTTP 400 BAD_REQUEST ("record to rereference does not exist"), so there are no per-item failures; the wrapper returns [Asset] and throws on the top-level error. The untagged .asset write is accepted and stored as ASSETID, so no request-side type tagging is needed. - IntegrationTestData.generateTestImage: emit a real, decodable solid-color PNG (correct CRC-32 + Adler-32, stored deflate) with no CoreGraphics, so the uploaded and re-referenced records render in the CloudKit Dashboard. - RereferenceAssetPhase + RereferenceAssetCommand: real implementations, with the phase wired into the public/private integration pipelines. - Unit tests: descriptor mapping, top-level BAD_REQUEST reason, compose reuse. Web-server route wiring for assets/rereference remains a #31 pending stub, to be wired next. [skip ci] Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
) Finishes the assets/rereference web-server wiring left as a pending stub in fdcaef0 and adds an /api/assets/upload route. Moves the asset UI from its own card into the Notes panel: a Generate button stages a 96×96 PNG (rendered client-side via Canvas) that the save flow uploads as part of the record write, and the rereference sub-section reuses the selected row as the source. Existing notes with assets now preview their image via CloudKit's signed downloadURL. Adds WebServerTests+Assets covering forwards and 401 paths for both endpoints; updates MockBackend to capture upload/rereference calls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- RereferenceAssetError: document its CLI-layer role and relationship to CloudKitError (it wraps the thrown CloudKitError; stays in MistDemo). - Integration: extract PNG byte-encoding into a dedicated PNGEncoder enum; IntegrationTestData.generateTestImage now delegates to it. - WebServer+Pending: enumerate the remaining pending calls and repoint the landed-but-unwired stubs from the closed scaffolding issue #370 to the new route-wiring tracking issue #394. - Tests: split MockBackend into +RecordOperations / +ServiceOperations extensions to clear the file_length warning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f48395d to
d495928Compare- Rename the PNG test-image helper enum/file PNGEncoder -> PNGData and its factory generateTestImage(sizeKB:) -> generate(withSizeInKB:). - Move the shared integration recordType constant onto MistDemoConfig; update all phase call sites. - Delete the now-empty IntegrationTestData. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d495928 to
b97fcb0CompareCode Review — PR #393: Wire assets/rereference + assets/upload UXThis is a well-structured PR that completes a long-standing stub. The overall architecture is sound and follows established MistKit patterns. Below are my findings. OverviewThe PR implements two new CloudKit operations:
The three-call composition in IssuesError specificity (moderate)
guardlet asset = descriptors.first else{throwCloudKitError.invalidResponse // no context
}guardlet targetInfo =try lookups.first?.get()else{throwCloudKitError.invalidResponse // ambiguous — first nil, or .get() failed?
}guardlet recordType = targetInfo.recordType else{throwCloudKitError.invalidResponse // which field?
}The middle guard is particularly tricky: Missing error-path tests (moderate)
JavaScript memory duplication (minor)
return{ dataURL, base64, blob,byteLength: bytes.length};
No PNG validation test (minor)
Client-side record-name validation (minor)
Positives
Nits
Test plan gapThe one unchecked box — manual web smoke test — is understandable for a draft PR, but the three-call round-trip in Overall: solid implementation that completes a long-standing stub. The main ask before merge is improving the error messages in 🤖 Generated with Claude Code |
Code Review — PR #393: Wire assets/rereference web route and add assets/upload UXOverall: This is a solid feature implementation that completes the Findings1. |
Resolve PR #31/#393 review findings on the asset-rereference work: - Add CloudKitError.incompleteResponse(reason:) and use it (with descriptive reasons) for the three rereferenceAsset guards instead of bare invalidResponse; split the middle guard so an empty lookup (target not found) is distinct from a per-record lookup failure. - Add a rereferenceAsset overload taking recordType/recordChangeTag to skip the lookupRecords round trip; the original method now delegates to it. - Add compose-error tests (no descriptor, target not found, missing recordType, targetField defaulting) plus an overload test asserting no lookup occurs. - RereferenceAssetPhase verify: require fileChecksum when present, treat the unstable signed downloadURL as fallback only. - Remove duplicate success print in RereferenceAssetCommand. - Trim over-documented processRereferenceAssetsResponse comment. - app.js: drop redundant dataURL (reconstruct inline); assets.js: read assets-source locally instead of via the app.js global. Also fix SubscriptionRoundtripPhase to reference MistDemoConfig.recordType (IntegrationTestData.recordType was moved in b97fcb0) so MistDemo builds. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Code Review — PR #393: Wire |
Summary
assets/rereferenceleft as a pending stub in fdcaef0 (issue Referencing Existing Assets (assets/rereference) #31). Adds a siblingPOST /api/assets/uploadroute built onCloudKitService.uploadAssetsso the demo can drive the full upload → rereference flow from the browser.downloadURL.Implementation notes
WebRequests.Creategained an optionalrecordNameso the browser can pass the upload receipt's record name through torecords/create— this is how MistKit-mode binds the just-uploaded bytes to the new record./api/assets/upload→/api/records/create|update); CloudKit JS mode passes theBlobinline tosaveRecordsand lets CK JS handle the upload.WebBackendadapters forward toCloudKitService.uploadAssetsandrereferenceAsset(fromRecord:field:toRecord:field:).Test plan
swift buildclean inExamples/MistDemoswift test— 945 tests pass (added 4: forwards + 401 for each new endpoint)./Scripts/lint.sh(both root andExamples/MistDemo/) — clean, no periphery warnings on the new codeswift run mistdemo web→ sign in → set title → Generate → Create uploads + binds the PNG; selecting an existing note with an image renders its preview; Rereference copies the image to another note.🤖 Generated with Claude Code