Skip to content

fix(secrets): invalidate env queries so dropdown updates without refresh#4359

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/secrets-invalidation
Apr 30, 2026
Merged

fix(secrets): invalidate env queries so dropdown updates without refresh#4359
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/secrets-invalidation

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • useSavePersonalEnvironment only invalidated environmentKeys.personal(), but the env-var dropdown reads personal vars from the workspace query (workspaceEnvData.personal) whenever there's a workspaceId — the workspace endpoint returns workspace + personal merged
  • result: setting a personal secret in settings didn't refresh the dropdown until manual page refresh
  • fix: invalidate environmentKeys.all from the personal-save mutation so every mounted workspace env query also refetches

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 30, 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 30, 2026 7:07pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 30, 2026

PR Summary

Low Risk
Low risk: only adjusts React Query cache keys/invalidation to force refetching after a personal env save; main risk is extra refetching or a mismatched query key causing stale UI.

Overview
Fixes a cache invalidation gap where saving personal environment variables did not refresh any mounted workspace environment queries.

Refactors environmentKeys to add a shared workspaces() prefix and updates useSavePersonalEnvironment to invalidate both environmentKeys.personal() and the workspace query prefix so workspace env dropdowns update without a full page refresh.

Reviewed by Cursor Bugbot for commit 2810430. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

Adds an intermediate workspaces() key to environmentKeys and invalidates it (alongside personal()) in useSavePersonalEnvironment.onSettled, so workspace env queries — which include merged personal vars — are refreshed when personal secrets are saved. The implementation follows the project's query-key factory pattern and replaces the previous broad environmentKeys.all invalidation with two targeted invalidations.

Confidence Score: 5/5

Safe to merge — targeted, minimal change with no logic risk.

Single-file change that correctly applies the project's hierarchical query-key pattern and replaces overly broad invalidation with two targeted invalidations. No new logic paths, no security surface, no regressions identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/hooks/queries/environment.ts Adds intermediate workspaces() key to the key factory and invalidates it alongside personal() on personal-save mutation; no issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[useSavePersonalEnvironment.onSettled] --> B[invalidate environmentKeys.personal]
    A --> C[invalidate environmentKeys.workspaces]
    B --> D[refetch usePersonalEnvironment queries]
    C --> E["refetch useWorkspaceEnvironment(id) queries\n(all workspace IDs)"]
    E --> F[Dropdown reads merged personal+workspace vars\nfrom workspace query → now up-to-date]
Loading

Reviews (2): Last reviewed commit: "improvement(secrets): use targeted works..." | Re-trigger Greptile

Comment thread apps/sim/hooks/queries/environment.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

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 2810430. Configure here.

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