[codex] Add template widget communication helpers#5
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughAdds cross-platform widget reload API and types, a startLiveActivity flag to control native ActivityKit requests, iOS timeline reload hooks after template/activity/session mutations, latest-activity resolution bridge methods, new SwiftUI surface views with hotspot intent buttons, Android reload broadcasts, plugin wiring, and a web stub. ChangesWidget Kit Extensions: Reload, Live Activity Control, and SwiftUI Views
Sequence Diagram(s)(omitted — changes are organizational and spread; no new multi-component runtime sequence beyond those described in layers) Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
Beta npm buildMaintainers can publish this PR to npm for fast testing. Comment The workflow will:
Security note: beta publish is only enabled for branches inside this repository. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@android/src/main/java/app/capgo/widgetkit/CapgoWidgetKit.java`:
- Around line 188-191: reloadWidgets currently ignores its kind parameter and
always sends global broadcasts; change it to emit kind-scoped notifications when
kind is non-null by calling notifyStoreChanged and notifyWidgetBridgeChanged
with the kind context (or by adding/using overloads that accept a kind) so only
widgets of that kind reload. Locate the reloadWidgets method and update the
calls to notifyStoreChanged and notifyWidgetBridgeChanged (or add new methods
like notifyStoreChanged(kind) / notifyWidgetBridgeChanged(kind, /*options*/)) to
attach the kind string to the broadcast intent/extras; preserve the global
behavior when kind is null.
In `@ios/Sources/CapgoWidgetKitPlugin/CapgoTemplateWidgetBridge.swift`:
- Around line 105-112: latestActivity currently takes the first filtered item
from listActivities without guaranteeing recency, so sort or pick the newest
envelope before returning: call listActivities(bundle:) then filter by status
(as in the existing guard), and return the envelope with the latest timestamp
(e.g., use max(by:) or sort by
StoredTemplateActivityEnvelope.createdAt/updatedAt descending) so latestActivity
always returns the most recent StoredTemplateActivityEnvelope; adjust
resolveLatestLayout callers if they rely on implicit ordering.
In `@ios/Sources/CapgoWidgetKitPlugin/CapgoTemplateWidgetViews.swift`:
- Around line 198-205: The computed property resolvedLayout currently uses
silent error suppression with "try?" around
CapgoTemplateWidgetBridge().resolveLayout(...) which hides failures; change it
to a do-catch: call CapgoTemplateWidgetBridge().resolveLayout(activityId:
activityId, surface: surface, bundle: bundle, now: now()), return the layout on
success, and in the catch block log the error (using os_log or Swift's Logger)
with context (activityId, surface, bundle) and then return nil so the
placeholder UI still appears but failures are visible for debugging.
In `@README.md`:
- Line 222: Revert all manual edits inside the README's <docgen-index> and
<docgen-api> sections (undo changes around reloadWidgets and the other listed
blocks), then add the proper TypeScript declarations and JSDoc in
src/definitions.ts: define the reloadWidgets() function signature, create the
ReloadWidgetsOptions interface, and add the startLiveActivity property to the
StartTemplateActivityOptions type with appropriate types and JSDoc comments;
finally run `bun run docgen` to regenerate the README so the auto-generated
sections are updated.
- Around line 139-140: Remove the redundant pre-action call to
CapgoWidgetKit.reloadWidgets() in the SVG Template Usage example: keep the await
CapgoWidgetKit.performTemplateAction(...) call only, since performTemplateAction
already triggers timeline refreshes on iOS
(TemplateLiveActivityManager.performAction calls reloadWidgetTimelines()) and
broadcasts ACTION_TEMPLATE_STORE_CHANGED on Android, and reloadWidgets() is a
no-op on web; update the example to avoid the extra await and any explanatory
text that implies a manual reload is required before performTemplateAction.
In `@src/web.ts`:
- Around line 416-418: The web implementation of reloadWidgets has a mismatched
signature; update async reloadWidgets(): Promise<void> to accept the optional
parameter used by the CapgoWidgetKitPlugin interface: async
reloadWidgets(_options?: ReloadWidgetsOptions): Promise<void> (you can ignore
the param name or prefix with underscore), ensuring the method signature matches
CapgoWidgetKitPlugin.reloadWidgets(options?: ReloadWidgetsOptions):
Promise<void>.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0294c2e6-8f15-47d8-9d92-f4a4b11c1f7a
📒 Files selected for processing (10)
README.mdandroid/src/main/java/app/capgo/widgetkit/CapgoWidgetKit.javaandroid/src/main/java/app/capgo/widgetkit/CapgoWidgetKitPlugin.javaios/Sources/CapgoWidgetKitPlugin/CapgoTemplateWidgetBridge.swiftios/Sources/CapgoWidgetKitPlugin/CapgoTemplateWidgetViews.swiftios/Sources/CapgoWidgetKitPlugin/CapgoWidgetKit.swiftios/Sources/CapgoWidgetKitPlugin/CapgoWidgetKitPlugin.swiftios/Sources/CapgoWidgetKitPlugin/TemplateLiveActivityManager.swiftsrc/definitions.tssrc/web.ts
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Summary
startLiveActivity: falseso JS can persist SVG template surfaces for regular widgets without launching an iOS Live ActivityreloadWidgets, plus automatic reloads after template, widget session, and widget message changesValidation
bun run buildbun run lint(passes with existing SwiftLint warnings)bun run verify:iosJAVA_HOME=/opt/homebrew/opt/openjdk@21 ANDROID_HOME="$HOME/Library/Android/sdk" ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" PATH="/opt/homebrew/opt/openjdk@21/bin:$HOME/Library/Android/sdk/platform-tools:$PATH" bun run verify:androidbun run verify:packageNotes
The first
bun run verifyattempt passed iOS and then stopped because the shell had no Java runtime configured. Android verification passed after pinning the local Java 21 and Android SDK paths.Summary by CodeRabbit