Skip to content

fix(secrets): secrets/integrations component code cleanup#4003

Merged
icecrasher321 merged 2 commits intostagingfrom
fix/secrets-tabs
Apr 7, 2026
Merged

fix(secrets): secrets/integrations component code cleanup#4003
icecrasher321 merged 2 commits intostagingfrom
fix/secrets-tabs

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Secrets / Integrations Manager code cleanup to use react query native flags.

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 1:28am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Medium Risk
Moderate risk because it changes mutation/cache behavior for credential updates and alters save/disable guards; could cause stale UI or missed updates if the optimistic cache logic is wrong.

Overview
Refactors Secrets and Integrations settings detail views to stop using local isSavingDetails state and instead gate navigation, save actions, and button disabled/loading text off updateCredential.isPending.

Improves secrets list saving UX by aggregating environment mutation pending states into isListSaving, preventing duplicate saves and showing a consistent "Saving..." state.

Adds optimistic React Query cache updates to useUpdateWorkspaceCredential for credential list data (with rollback on error) and relies on invalidation rather than manual refetchCredentials after saving.

Reviewed by Cursor Bugbot for commit 2c83972. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR is a clean code quality improvement that removes manual loading-state tracking (isSavingDetails) from both the CredentialsManager and IntegrationsManager components, replacing it with TanStack Query's native isPending flag on the respective mutation objects.

Key changes:

  • Removed isSavingDetails useState variable in both components; updateCredential.isPending now serves the same purpose without manual set…(true/false) calls
  • Added isListSaving computed boolean in credentials-manager.tsx that aggregates the pending state of savePersonalMutation, upsertWorkspaceMutation, and removeWorkspaceMutation
  • handleSave now short-circuits while isListSaving is true, and the Save button shows "Saving…" during list mutations
  • handleSaveDetails and handleBackAttempt guards updated to use updateCredential.isPending in both files
  • Introduced a small variable extraction (currentCredentialId) for clarity in the credential-selection diff guard

The refactor is functionally equivalent to the original: TanStack Query automatically manages isPending on start/settle of a mutation, mirroring what setIsSavingDetails(true) + finally { setIsSavingDetails(false) } did manually. No behavioral regressions are introduced.

Confidence Score: 5/5

Safe to merge — no behavioral changes, no new state management risks, all mutations already tracked by TanStack Query.

All changes are functionally equivalent to the code they replace. No P0 or P1 issues exist; the only observations are minor style points that do not affect correctness or runtime behavior.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/credentials/credentials-manager.tsx Replaces isSavingDetails state with updateCredential.isPending and adds isListSaving derived boolean aggregating three mutation pending states; save button and back-attempt guards updated accordingly.
apps/sim/app/workspace/[workspaceId]/settings/components/integrations/integrations-manager.tsx Removes isSavingDetails state variable and replaces every usage with updateCredential.isPending; functionally equivalent, leverages TanStack Query native pending state.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks Save] --> B{isListSaving?
(savePersonal | upsertWorkspace | removeWorkspace).isPending}
    B -- true --> C[Return early / button disabled + 'Saving...']
    B -- false --> D[Execute handleSave]
    D --> E[Run mutations in parallel]
    E --> F{All settled?}
    F -- success --> G[Sync state / invalidate cache]
    F -- error --> H[Log error / rollback]

    I[User clicks Save Details] --> J{updateCredential.isPending?}
    J -- true --> K[Return early / button disabled + 'Saving...']
    J -- false --> L[Execute handleSaveDetails]
    L --> M[updateCredential.mutateAsync]
    M --> N{Settled?}
    N -- success --> O[Trim drafts / refetch]
    N -- error --> P[setDetailsError / logger.error]

    Q[User clicks Back] --> R{isDetailsDirty AND NOT updateCredential.isPending?}
    R -- true --> S[Show unsaved-changes dialog]
    R -- false --> T[Navigate back immediately]
Loading

Reviews (1): Last reviewed commit: "fix(secrets): secrets/integrations compo..." | Re-trigger Greptile

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2c83972. Configure here.

@icecrasher321 icecrasher321 merged commit 5eb494d into staging Apr 7, 2026
12 checks passed
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