Skip to content

feat: apply settings to every env#5165

Merged
chronark merged 4 commits intomainfrom
update-all-env-settings
Mar 3, 2026
Merged

feat: apply settings to every env#5165
chronark merged 4 commits intomainfrom
update-all-env-settings

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Mar 2, 2026

What does this PR do?

Refactors form setting cards to use a unified save state system instead of separate canSave and isSaving boolean props. Introduces a resolveSaveState function that evaluates multiple conditions to determine the appropriate save button state, and adds tooltip support to show disabled reasons.

The new system provides better user feedback by displaying specific reasons why the save button is disabled (e.g., "No changes to save", "Decrypting values…", "Select at least one region before setting instance count").

Also adds an onboarding-specific environment provider that syncs production settings to other environments during project setup.

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)

How should this be tested?

  • Navigate to project settings and verify all form cards display appropriate save button states
  • Test that disabled save buttons show helpful tooltips when hovering
  • Verify that save buttons are properly disabled/enabled based on form validation and changes
  • Test the onboarding flow to ensure settings sync correctly between environments
  • Check that environment variable forms show "Decrypting values…" state appropriately
  • Verify region selection shows proper validation message when no regions are selected

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Ran make fmt on /go directory
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

This was referenced Mar 2, 2026
@vercel
Copy link

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Mar 3, 2026 11:41am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

This change refactors form submission controls across multiple settings components by replacing separate canSave and isSaving boolean props with a unified saveState prop. The shared FormSettingCard component is updated with a new SaveState type and resolveSaveState helper function. Additionally, a new onboarding environment provider synchronizes settings across environments, and deployment utilities are refactored to support this new flow.

Changes

Cohort / File(s) Summary
Shared Form Infrastructure
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/shared/form-setting-card.tsx, web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/environment-provider.tsx
Introduced SaveState type and resolveSaveState helper function; replaced canSave/isSaving props with unified saveState prop on FormSettingCard. Exported EnvironmentContext to make it publicly accessible.
Runtime Settings Components
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/*.tsx
Updated cpu, command, memory, port-settings, regions, scaling, storage, instances, and healthcheck components to import resolveSaveState and compute saveState based on submission/validation/change states; replaced canSave/isSaving props with saveState on FormSettingCard.
Advanced Settings Components
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/advanced-settings/custom-domains/index.tsx, web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/advanced-settings/env-vars/index.tsx
Applied same refactoring pattern: imported resolveSaveState and replaced canSave/isSaving props with saveState on FormSettingCard.
Build Settings Components
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/build-settings/dockerfile-settings.tsx, web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/build-settings/root-directory-settings.tsx
Imported resolveSaveState and computed saveState with conditions for saving/invalid/unchanged states; replaced canSave/isSaving with unified saveState prop.
Sentinel Settings
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/sentinel-settings/keyspaces.tsx
Applied refactoring pattern: imported resolveSaveState and replaced canSave/isSaving props with saveState on FormSettingCard.
Onboarding Environment Integration
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/onboarding/steps/configure-deployment.tsx, web/apps/dashboard/app/(app)/[workspaceSlug]/projects/onboarding/steps/onboarding-environment-provider.tsx
Introduced new OnboardingEnvironmentSettingsProvider component that synchronizes production environment settings across non-production environments using buildSettingsMutations; updated ConfigureDeploymentStep to use the new provider.
Deployment Library
web/apps/dashboard/lib/collections/deploy/environment-settings.ts
Extracted mutation building logic into new buildSettingsMutations helper function; refactored dispatchSettingsMutations to delegate to the helper and integrate with toast notifications.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Provider as OnboardingEnvironmentSettingsProvider
    participant ProjectData as useProjectData
    participant Query as useLiveQuery
    participant Mutations as buildSettingsMutations
    participant Context as EnvironmentContext.Provider
    
    User->>Provider: Component mounts
    Provider->>ProjectData: Retrieve project environments
    ProjectData-->>Provider: Environment list
    Provider->>Query: Query production environment settings
    Query-->>Provider: Settings loaded
    Provider->>Context: Provide settings via context
    Context-->>User: Settings available to consumers
    
    Note over Provider,Context: On production settings update:
    Provider->>Mutations: Build mutations for non-prod envs
    Mutations-->>Provider: Array of mutation promises
    Provider->>Mutations: Execute all mutations in parallel
    Mutations-->>Provider: Changes synced
    Provider->>Context: Update context with new state
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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
Title check ✅ Passed The title clearly describes the main feature: applying settings across environments, which aligns with the PR's primary objective of enabling environment-wide setting synchronization.
Description check ✅ Passed The description covers all major changes: refactoring save state system, introducing resolveSaveState, adding tooltip support, and implementing environment settings synchronization. It includes type of change, testing instructions, and a mostly complete checklist.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-all-env-settings

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

@ogzhanolguncu ogzhanolguncu mentioned this pull request Mar 2, 2026
19 tasks
@ogzhanolguncu ogzhanolguncu marked this pull request as ready for review March 2, 2026 17:18
@ogzhanolguncu ogzhanolguncu force-pushed the feat/next-onboarding-step branch from 8b8a6bb to bad2566 Compare March 2, 2026 17:49
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from d46f025 to 09b4777 Compare March 2, 2026 17:50
@ogzhanolguncu ogzhanolguncu force-pushed the feat/next-onboarding-step branch from bad2566 to aec8a3c Compare March 2, 2026 17:55
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from 09b4777 to aa3d88f Compare March 2, 2026 17:55
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from aa3d88f to c654a92 Compare March 2, 2026 18:03
@ogzhanolguncu ogzhanolguncu force-pushed the feat/next-onboarding-step branch from aec8a3c to 6ba9cf1 Compare March 2, 2026 18:03
@graphite-app graphite-app bot changed the base branch from feat/next-onboarding-step to graphite-base/5165 March 3, 2026 07:44
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from c790e8d to 61a2959 Compare March 3, 2026 09:55
@ogzhanolguncu ogzhanolguncu changed the base branch from graphite-base/5165 to feat/next-onboarding-step March 3, 2026 09:55
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from a0fcfcb to fe565ce Compare March 3, 2026 11:09
@ogzhanolguncu ogzhanolguncu force-pushed the feat/next-onboarding-step branch from 5f2e4c4 to fa20f12 Compare March 3, 2026 11:09
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from fe565ce to 00949fc Compare March 3, 2026 11:19
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from 00949fc to fe5ceef Compare March 3, 2026 11:24
Base automatically changed from feat/next-onboarding-step to main March 3, 2026 11:37
@ogzhanolguncu ogzhanolguncu force-pushed the update-all-env-settings branch from fe5ceef to 58ed410 Compare March 3, 2026 11:38
@graphite-app
Copy link

graphite-app bot commented Mar 3, 2026

Merge activity

  • Mar 3, 11:39 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

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
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/onboarding/steps/onboarding-environment-provider.tsx:
- Around line 70-81: The code updates prevSettingsRef.current too early — move
the assignment of prevSettingsRef.current = current so it happens only after
Promise.all(mutations) resolves successfully; keep using prev =
prevSettingsRef.current to skip initial load, build mutations via
buildSettingsMutations(envIds, prev, current) as before, then await
Promise.all(mutations) (or handle its returned promise) and only on success set
prevSettingsRef.current = current; also replace the bare console.error with
structured error handling that logs the error and triggers retry/rollback logic
for failed env updates (e.g., re-queue failed envIds or surface an actionable
error).

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab63f35 and 58ed410.

📒 Files selected for processing (19)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/advanced-settings/custom-domains/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/advanced-settings/env-vars/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/build-settings/dockerfile-settings.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/build-settings/root-directory-settings.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/command.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/cpu.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/healthcheck/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/instances.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/memory.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/port-settings.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/regions.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/scaling.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/storage.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/sentinel-settings/keyspaces.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/shared/form-setting-card.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/environment-provider.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/onboarding/steps/configure-deployment.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/onboarding/steps/onboarding-environment-provider.tsx
  • web/apps/dashboard/lib/collections/deploy/environment-settings.ts

@chronark chronark enabled auto-merge March 3, 2026 14:09
@chronark chronark added this pull request to the merge queue Mar 3, 2026
Merged via the queue into main with commit 74916d8 Mar 3, 2026
16 checks passed
@chronark chronark deleted the update-all-env-settings branch March 3, 2026 14:24
@coderabbitai coderabbitai bot mentioned this pull request Mar 4, 2026
13 tasks
@coderabbitai coderabbitai bot mentioned this pull request Mar 17, 2026
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.

3 participants