Skip to content

fix(ui): prevent concurrent environment mutations - #7751

Open
andrewhuhh wants to merge 2 commits into
mainfrom
andrew/platfor-679-migrate-project-environments-settings-to-v3
Open

fix(ui): prevent concurrent environment mutations#7751
andrewhuhh wants to merge 2 commits into
mainfrom
andrew/platfor-679-migrate-project-environments-settings-to-v3

Conversation

@andrewhuhh

Copy link
Copy Markdown
Contributor

Context

PLATFOR-679 completes the remaining parity work for the project Settings Environments surface.

Before this change, reorder, restore, soft-delete, and hard-delete actions could be submitted repeatedly or concurrently without consistent pending feedback. Edit validation also allowed an empty environment name. The Environments surface also retained legacy color utilities, and its permission wrapper depended on the v2 Tooltip component.

This change:

  • Adds pending feedback and disables conflicting or duplicate environment actions.
  • Preserves existing permissions, confirmations, ordering, mutation/API contracts, notifications, and error behavior.
  • Rejects empty environment names in the edit form. Whitespace-only names remain governed by the existing non-trimming validation contract.
  • Replaces Environments-owned legacy colors with semantic tokens from frontend/src/index.css.
  • Replaces the permission wrapper's v2 Tooltip composition with v3 Tooltip primitives.
  • Does not change the shared Settings shell, Overview environment state, Tags, Policies, backend, or API contracts.

Linear: PLATFOR-679

Screenshots

Not captured in this environment. Outstanding draft-PR evidence:

  1. Open a Secrets Management project and navigate to Settings → Environments.
  2. Capture the populated environment list.
  3. Capture reorder, restore, soft-delete, and hard-delete actions while their mutations are pending, showing the initiating action disabled with loading feedback.
  4. Capture the edit form rejecting an empty environment name.

Steps to verify the change

  1. From the project Settings route, open Environments.
  2. Reorder an environment and confirm the initiating arrow shows pending feedback while all environment actions are disabled; confirm the success notification and existing ordering behavior remain unchanged.
  3. Open a pending-deletion environment and restore it; confirm the Restore action shows pending feedback and repeated/conflicting actions are disabled.
  4. Schedule deletion and confirm the dialog action shows pending feedback, the dialog cannot be dismissed during submission, and the existing success notification remains unchanged.
  5. Open permanent deletion, type the exact slug, and confirm the destructive action shows pending feedback while input and conflicting actions are disabled.
  6. Open Edit environment, clear the name, and confirm validation rejects submission.
  7. Run cd frontend && npm run lint.
  8. Run cd frontend && npm run type:check.

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: fix(ui): prevent concurrent environment mutations
  • Tested locally — serialized frontend lint/type-check gate passed.
  • Updated docs (if needed) — no documentation changes are required.
  • Updated CLAUDE.md files (if needed) — no architectural guidance changes are required.
  • Read the contributing guide

@linear

linear Bot commented Aug 21, 2026

Copy link
Copy Markdown

PLATFOR-679

@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-infisical-7751-fix-ui-prevent-concurrent-environment-mutations

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@andrewhuhh
andrewhuhh marked this pull request as ready for review August 21, 2026 06:18
@andrewhuhh andrewhuhh self-assigned this Aug 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a876bcaeb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
}}
isDisabled={!isAllowed}
isDisabled={!isAllowed || deleteWsEnvironment.isPending}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable Create during reorder and restore mutations

When a reorder or restore request is slow, this button remains enabled because it observes only deleteWsEnvironment.isPending, while those other pending states are local to EnvironmentTable. A user can therefore start creating an environment before the first mutation finishes, so the environment mutation serialization added by this change remains incomplete; lift the table mutation state or otherwise share a single pending guard with this button.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds pending-state feedback and guards around environment reorder, restore, soft-delete, and hard-delete actions, tightens edit-name validation, migrates permission tooltips to v3 primitives, and replaces legacy environment colors with semantic tokens.

  • Coordinates most environment mutation controls through pending state.
  • Adds loading and disabled states to destructive confirmations and row actions.
  • Rejects empty environment names.
  • Migrates permission tooltips and environment styling to v3 conventions.

Confidence Score: 4/5

The soft-delete dialog behavior should be fixed before merging because confirmation still dismisses the dialog before its pending feedback can appear.

AlertDialogAction requests closure in the same activation that starts deletion, so the render-captured pending flag remains false and the new close guard does not preserve the dialog during submission.

Files Needing Attention: frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx

Important Files Changed

Filename Overview
frontend/src/components/permissions/ProjectPermissionCan.tsx Migrates permission tooltips from the v2 wrapper to the equivalent v3 Tooltip composition without an established contract regression.
frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx Adds shared delete pending-state guards and feedback, but the soft-delete AlertDialogAction still closes before the pending guard can observe the mutation.
frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentTable.tsx Serializes table reorder and restore actions, displays initiating-action feedback, and migrates legacy color utilities to semantic tokens.
frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx Adds a minimum-length constraint that rejects an empty environment name while preserving the documented whitespace behavior.

Reviews (1): Last reviewed commit: "Prevent concurrent environment mutations..." | Re-trigger Greptile

Comment on lines +167 to +168
if (!isOpen && deleteWsEnvironment.isPending) return;
handlePopUpToggle("deleteEnv", isOpen);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Pending deletion dialog closes early

When a user confirms scheduled deletion, AlertDialogAction requests closure in the same activation that starts the mutation, so this guard still sees the previous isPending value and allows the dialog to close. The newly added pending feedback is therefore hidden while the deletion request is running, and the dialog does not remain locked as intended.

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