Fix event endpoint persistence #831
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoRun configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where event hook and NTFY endpoint settings could be inadvertently lost or incorrectly reconciled. It introduces explicit type definitions for these settings in the API client, refines the client-side reconciliation logic for NTFY endpoints to prevent data loss from empty server responses, and adds a mechanism to signal to the backend when empty arrays for event hooks or NTFY endpoints are intentional, ensuring proper persistence of these configurations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix persistence for event endpoints. It introduces logic to prevent accidental wiping of eventHooks and ntfyEndpoints when syncing with the server.
The changes in app-store.ts correctly add a flag to signal intentional empty arrays to the server. However, the change in __root.tsx introduces a data synchronization bug by preventing clients from updating when the server state is an empty array. This will cause clients to become out of sync if a user deletes all endpoints. I've left a comment with a suggestion to fix this.
apps/ui/src/routes/__root.tsx
Outdated
| if ( | ||
| JSON.stringify(serverEndpoints) !== JSON.stringify(currentEndpoints) && | ||
| serverEndpoints.length > 0 | ||
| ) { |
There was a problem hiding this comment.
This change introduces a potential data synchronization issue for ntfyEndpoints, and a similar issue already exists for eventHooks on lines 603-606.
The condition serverEndpoints.length > 0 is likely intended to prevent an uninitialized empty array from the server from wiping the client's state. However, it also prevents syncing a deliberately cleared list of endpoints. If a user deletes all endpoints on one device, other clients will fail to sync this change and will retain a stale list.
Given that app-store.ts now sends a special flag (__allowEmpty...) when clearing endpoints, we can be more confident that an empty array from the server is an intentional state.
To ensure correct synchronization, this length check should be removed.
if (JSON.stringify(serverEndpoints) !== JSON.stringify(currentEndpoints)) {
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ui/src/routes/__root.tsx`:
- Around line 616-619: The reconciliation currently prevents updates when
serverEndpoints is an empty array due to the `serverEndpoints.length > 0` guard,
so explicit clears from the server never propagate; update the condition in the
code that compares `JSON.stringify(serverEndpoints) !==
JSON.stringify(currentEndpoints)` (the block referencing serverEndpoints and
currentEndpoints) to remove the `serverEndpoints.length > 0` requirement so that
an intentionally empty `serverEndpoints` will pass the check and overwrite local
state (i.e., allow the JSON.stringify inequality alone to drive the update),
ensuring intentional empty-array writes reconcile correctly.
ℹ️ Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a8d95764-bbf9-4224-a55a-33e23936a6fc
📒 Files selected for processing (3)
apps/ui/src/lib/http-api-client.tsapps/ui/src/routes/__root.tsxapps/ui/src/store/app-store.ts
Remove the `length > 0` guards in fast-hydrate reconciliation that prevented intentional empty-array clears from syncing across clients. Server-side wipe protection (`__allowEmpty*` escape hatches) already ensures empty arrays in the server are intentional. Addresses PR AutoMaker-Org#831 review feedback from CodeRabbit and Gemini. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Changes from fix/event-hook-endpoint * fix: Allow empty eventHooks/ntfyEndpoints to reconcile from server Remove the `length > 0` guards in fast-hydrate reconciliation that prevented intentional empty-array clears from syncing across clients. Server-side wipe protection (`__allowEmpty*` escape hatches) already ensures empty arrays in the server are intentional. Addresses PR AutoMaker-Org#831 review feedback from CodeRabbit and Gemini. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Changes from branch fix/event-hook-endpoint
Summary by CodeRabbit
New Features
Improvements