Uh oh!
There was an error while loading. Please reload this page.
feat(envvars): use cache for envvar dropdown key names, prevent autofill & suggestions in the settings - #1769
Conversation
…ill & suggestions in the settings
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Implemented in-memory caching for workspace environment variables to reduce redundant API calls when users open the env var dropdown. The cache is stored in a Map keyed by workspaceId and is properly invalidated when variables are updated or deleted. Additionally, implemented browser autofill prevention for the environment variable settings form by switching from type="password" to type="text" with WebkitTextSecurity: 'disc' styling and adding honeypot inputs to prevent password managers from interfering.
Key changes:
- Cache preloads when workflow becomes ready, providing instant dropdown results
- Cache invalidation correctly triggers on
upsertWorkspaceEnvironment,removeWorkspaceEnvironmentKeys, and personal variable changes - Autofill prevention uses modern web techniques (honeypot inputs + text security styling)
- Added
maxHeightto dropdown for better UX with long variable lists
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The implementation is straightforward and well-structured. The cache invalidation logic is correctly placed in all mutation methods, the preload strategy won't cause race conditions, and the autofill prevention technique is a standard browser workaround. No logical errors or security issues were found.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/stores/settings/environment/store.ts | 5/5 | Added workspace env cache with Map, proper invalidation on mutations, and reset method |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx | 5/5 | Added preload logic for workspace env vars when workflow is ready, with cache clearing on workspace change |
| apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/environment/environment.tsx | 5/5 | Replaced password input type with text + WebkitTextSecurity styling, added honeypot inputs to prevent autofill |
| apps/sim/components/ui/env-var-dropdown.tsx | 4/5 | Simplified group creation logic and label display, removed conditional group pushing, added maxHeight styling |
Sequence Diagram
sequenceDiagram
participant User
participant Workflow
participant EnvStore
participant Cache
participant API
participant Dropdown
User->>Workflow: Opens workflow
Workflow->>EnvStore: loadWorkspaceEnvironment(workspaceId)
EnvStore->>Cache: Check cache for workspaceId
alt Cache Hit
Cache-->>EnvStore: Return cached data
EnvStore-->>Workflow: Return env data
else Cache Miss
EnvStore->>API: GET /workspace/:id/environment
API-->>EnvStore: Return workspace & personal env vars
EnvStore->>Cache: Store data with timestamp
EnvStore-->>Workflow: Return env data
end
User->>Dropdown: Types {{ to trigger dropdown
Dropdown->>EnvStore: loadWorkspaceEnvironment(workspaceId)
EnvStore->>Cache: Check cache
Cache-->>EnvStore: Return cached data (fast)
EnvStore-->>Dropdown: Display env vars
User->>EnvStore: Updates/Deletes env var
EnvStore->>API: PUT/DELETE request
API-->>EnvStore: Success
EnvStore->>Cache: clearWorkspaceEnvCache(workspaceId)
Cache-->>EnvStore: Cache invalidated
7 files reviewed, no comments
Uh oh!
There was an error while loading. Please reload this page.
…ill & suggestions in the settings (#1769) * feat(envvars): use cache for envvar dropdown key names, prevent autofill & suggestions in the settings * add the same prevention for autocomplete and suggestions to sso and webhook
Summary
save passwordandsuggested passwordsType of Change
Testing
Tested manually.
Checklist