Skip to content

Fix event endpoint persistence #831

Merged
gsxdsm merged 2 commits intoAutoMaker-Org:v1.0.0rcfrom
gsxdsm:fix/event-hook-endpoint
Mar 4, 2026
Merged

Fix event endpoint persistence #831
gsxdsm merged 2 commits intoAutoMaker-Org:v1.0.0rcfrom
gsxdsm:fix/event-hook-endpoint

Conversation

@gsxdsm
Copy link
Collaborator

@gsxdsm gsxdsm commented Mar 4, 2026

Changes from branch fix/event-hook-endpoint

Summary by CodeRabbit

  • New Features

    • Event hooks are now available in global settings for configuring triggers and custom actions.
    • Notification endpoints (Ntfy) can be configured in global settings, including server, topic and authentication.
  • Improvements

    • Global settings synchronization improved to more reliably detect and apply changes, including intentional empty lists for hooks/endpoints.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 73831921-2a32-40d9-b55f-ca46ec43640d

📥 Commits

Reviewing files that changed from the base of the PR and between 6f2394f and f5752b6.

📒 Files selected for processing (1)
  • apps/ui/src/routes/__root.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/ui/src/routes/__root.tsx

📝 Walkthrough

Walkthrough

Adds eventHooks and ntfyEndpoints to the global settings API type, sends explicit allow-empty flags when updating global settings with empty arrays, and relaxes reconciliation so server and client hooks are compared by value (no longer requiring server length > 0).

Changes

Cohort / File(s) Summary
Settings Type Definition
apps/ui/src/lib/http-api-client.ts
Extended getGlobal return type to include optional eventHooks and ntfyEndpoints arrays inside the settings payload.
Settings Synchronization & Reconciliation
apps/ui/src/routes/__root.tsx, apps/ui/src/store/app-store.ts
Reconciliation now compares server/client hooks by JSON value without requiring non-empty server lists. When updating settings, add __allowEmptyEventHooks: true or __allowEmptyNtfyEndpoints: true alongside empty arrays to signal intentional empty state.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped through types and tiny flags,
Marked empty nests with careful tags,
Hooks and endpoints now declared,
No surprise when arrays are bared,
A quiet sync — carrot bags! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix event endpoint persistence' accurately describes the main change: fixing persistence of event hooks and ntfy endpoints (endpoints) across clients by allowing intentional empty arrays to sync from server.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • API Type Definitions: Extended the global settings API response type to include eventHooks and ntfyEndpoints, ensuring proper type safety for these configurations.
  • Endpoint Reconciliation Logic: Enhanced the ntfyEndpoints reconciliation process in the root layout to prevent accidental data loss by only reconciling if the server-provided array is not empty.
  • Intentional Empty Array Signaling: Implemented a mechanism to explicitly signal to the server when eventHooks or ntfyEndpoints are intentionally being set to an empty array, preventing misinterpretation as stale state and ensuring correct persistence.

🧠 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
  • apps/ui/src/lib/http-api-client.ts
    • Added type definitions for eventHooks and ntfyEndpoints to the global settings API response.
  • apps/ui/src/routes/__root.tsx
    • Modified the ntfyEndpoints reconciliation logic to only update if the server-provided array is not empty, preventing accidental overwrites.
  • apps/ui/src/store/app-store.ts
    • Updated the updateGlobal calls for eventHooks and ntfyEndpoints to include a special flag (__allowEmptyEventHooks or __allowEmptyNtfyEndpoints) when sending an empty array, indicating an intentional clear.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +616 to +619
if (
JSON.stringify(serverEndpoints) !== JSON.stringify(currentEndpoints) &&
serverEndpoints.length > 0
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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)) {

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd7108a and 6f2394f.

📒 Files selected for processing (3)
  • apps/ui/src/lib/http-api-client.ts
  • apps/ui/src/routes/__root.tsx
  • apps/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>
@gsxdsm gsxdsm merged commit 20e7c74 into AutoMaker-Org:v1.0.0rc Mar 4, 2026
6 checks passed
@gsxdsm gsxdsm deleted the fix/event-hook-endpoint branch March 4, 2026 04:33
gsxdsm added a commit to gsxdsm/automaker that referenced this pull request Mar 4, 2026
* 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>
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.

1 participant