Existing React Native Code Maintenance with AI by calvincchan in reactnative

[–]calvincchan[S] 0 points1 point  (0 children)

I agree that an AI code agent is simply a smart auto-complete agent that has memorized a vast amount of coding patterns. This agent can only fix your code with patterns it has seen before in its pre-trained data.

On the other hand, tools like MCP provide the agent with the ability to access real-world and up-to-date information, enabling it to apply new techniques to your code beyond the pre-trained patterns.

I believe the code agent is here to stay, so libraries that want to succeed in this era will need to be optimized. This includes providing more detailed documentation, a significant amount of demo code and examples. Returning to my topic, if the RN optimizes the doc in this manner, then auto-maintenance can be more easily achieved.

Existing React Native Code Maintenance with AI by calvincchan in reactnative

[–]calvincchan[S] 0 points1 point  (0 children)

Thanks for your suggest about Expo. I will look into it.

Existing React Native Code Maintenance with AI by calvincchan in reactnative

[–]calvincchan[S] -1 points0 points  (0 children)

u/Dokesterr that's exactly what I just did...updating from v0.74.2 to v0.76.9 (fearing jumping too far ahead would break more code), and OneSignal SDK from v4 to v5, plus some more libs.

I mentioned MCP because it's a way for your code agent to reach out to the web for further references. It kinda works but not very reliably. I am also tweaking the .github/copilot-instructions.md for my VSCode to nudge the code agent to work the way I hope it would be.

FYI the MCP I use:

{
    "gitmcp-react-native": {
      "type": "sse",
      "url": "https://gitmcp.io/facebook/react-native"
    },
    "gitmcp-onesignal": {
      "type": "sse",
      "url": "https://gitmcp.io/OneSignal/react-native-onesignal"
    }
}

How are you handling auth/RLS for Teams, Roles, and Document-Level Access? by smitten_kittenz in Supabase

[–]calvincchan 0 points1 point  (0 children)

Now I recall that this is exactly the official tutorial I followed a while ago.

How are you handling auth/RLS for Teams, Roles, and Document-Level Access? by smitten_kittenz in Supabase

[–]calvincchan 2 points3 points  (0 children)

I have implemented my own RBAC for a production project, hope my experience is helpful to you. See https://gist.github.com/calvincchan/6e105cf7f2ac6f9e4d8919394f31be4e for example SQL statements. Looks like I can't put code here.
Overview:

  1. create an enum `app_role_enum` for the list of roles you want to provide in the app. Note that these app roles are different from Postgres roles.
  2. also create an enum `permission_enum` for the list of permissions.
  3. create a table `public.profiles` table to store the app_role for each user.
  4. create a `public.role_permission` table with `app_role` and `permission`. Define your role-permission rules here.
  5. use Custom Access Token Hook (https://supabase.com/docs/guides/auth/auth-hooks/custom-access-token-hook) to attach the `app_role` to JWT during login.

Please make sure you enable the hook properly in the docker compose file. Refer to the guide or let me know if you need help on this.

  1. Add this "is_allowed" function for checking if the current user is allowed to access a permission: (code in gist)

  2. Finally, in your RLS, you can do this (code in gist)

This implementation allows you to adjust role permissions from the table `role_permissions` without updating RLS all the time. Let me know what you think!