feat(discord): Supabase-backed trigger storage for pod resilience#368
Merged
JonasJesus42 merged 3 commits intomainfrom Apr 7, 2026
Merged
feat(discord): Supabase-backed trigger storage for pod resilience#368JonasJesus42 merged 3 commits intomainfrom
JonasJesus42 merged 3 commits intomainfrom
Conversation
StudioKV depended on expiring mesh tokens (~5 min), causing trigger credentials to be lost on pod restart. This replaces it with SupabaseTriggerStorage that uses static SUPABASE_URL/SUPABASE_ANON_KEY env vars (never expire), making triggers fully resilient across restarts. Also fixes onChange to merge with existing config (prevents silent drops), removes DISCORD_BOT_START tool (bots auto-start from bootstrap/onChange), and adds trigger credential pre-warming on startup. Requires new Supabase table: discord_trigger_credentials Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="discord-read/server/lib/supabase-client.ts">
<violation number="1" location="discord-read/server/lib/supabase-client.ts:241">
P2: `created_at` is being overwritten on every upsert, so it no longer represents the original creation time.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…oken Connections with duplicate bot tokens were getting instances with client=null because bootstrap skipped ensureBotRunning for them. Now duplicate connections share the Client reference from the primary connection that started it, so all connections report as running. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
created_at should only be set on first insert (via Supabase DEFAULT). Omit it from the upsert payload so it preserves the original creation time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LazyStudioKVwithSupabaseTriggerStorage: StudioKV depended on expiring mesh tokens (~5 min), causing trigger credentials to be lost on pod restart. The new storage uses staticSUPABASE_URL/SUPABASE_ANON_KEYenv vars that never expire.onChangeconfig merge: Previously silently dropped configs whenconnectionId/organizationId/meshUrlwere missing. Now merges with existing saved config from Supabase, preventing data loss.DISCORD_BOT_STARTtool: Bots auto-start from Supabase bootstrap andonChange— no manual start needed.Pre-deploy requirement
Create new Supabase table before deploying:
Post-deploy action
Users need to re-enable triggers once in Mesh UI so credentials get saved to the new Supabase table. After that, they persist indefinitely across pod restarts.
Test plan
discord_trigger_credentialstable in Supabasediscord_trigger_credentials→ send Discord message → verify trigger firesDISCORD_BOT_STARTtool no longer appears in MCP tool listonChangewith partial data → verify existing config fields are preserved🤖 Generated with Claude Code
Summary by cubic
Persist Discord trigger credentials in Supabase so triggers survive pod restarts and no longer rely on expiring Mesh tokens. Also shares one Discord client across connections with the same bot token and preserves
created_aton credential upserts.New Features
StudioKVwith Supabase-backed storage (discord_trigger_credentials) usingSUPABASE_URL/SUPABASE_ANON_KEY.onChangenow merges with saved config to prevent dropped fields whenconnectionId/organizationId/meshUrlare missing.DISCORD_BOT_START; bots auto-start via Supabase bootstrap andonChange.Migration
public.discord_trigger_credentialswith columns —connection_idPK (FK topublic.discord_connections(connection_id)ON DELETE CASCADE),callback_url,callback_token,active_trigger_types TEXT[],created_at,updated_at.Written for commit 4e76cf6. Summary will update on new commits.