Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jul 19, 2025

Description

Simplify Autofill Env Var logic.

  • Previously: Had a store mapping that overrode API Key using a useEffect based on provider. Detected whether it was cleared by the user and marked clears. Didn't work because of race conditions between useEffects and mapping was unreliable.

  • Simplified behavior: Don't clear API Key on switching between same providers -- so convenience is still there to pick model within same provider after API key entered. But clear when switching to different provider. Requires no complex state management.

Fixes # (issue)

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Screen.Recording.2025-07-19.at.4.46.36.PM.mov

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

@vercel
Copy link

vercel bot commented Jul 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2025 11:47pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 19, 2025 11:47pm

@icecrasher321 icecrasher321 changed the title fix(autofill-env-vars): simplify logic to not cause useEffect overwrites fix(autofill-env-vars): simplify/remove logic to not cause useEffect overwrites Jul 19, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR simplifies the environment variable autofill logic by removing a complex, problematic implementation in favor of a more straightforward approach.

The key changes are:

  1. Removes the autoFillEnvVars feature and related UI components, marking it as deprecated in the database schema
  2. Eliminates complex state management using useEffect hooks that were causing race conditions
  3. Implements a simpler provider-based API key persistence logic:
    • API keys persist when switching between models of the same provider
    • API keys clear only when switching to a different provider

The changes span across multiple areas including database schema, stores, API endpoints, and React components, removing the complex state tracking system while maintaining a good user experience.

Confidence score: 4/5

  1. This PR is safe to merge as it simplifies existing logic without introducing new complexity
  2. High confidence due to comprehensive cleanup across the codebase, but missing new tests reduces the score slightly
  3. Key files needing attention:
    • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/hooks/use-sub-block-value.ts - Core logic changes
    • apps/sim/db/schema.ts - Schema changes and deprecation
    • apps/sim/stores/workflows/subblock/types.ts - State management simplification

11 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

@delve-auditor
Copy link

delve-auditor bot commented Jul 19, 2025

No security or compliance issues detected. Reviewed everything up to b62317f.

Security Overview
  • 🔎 Scanned files: 12 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► route.ts
    Remove deprecated autoFillEnvVars feature
► tool-input.tsx
    Remove autofill functionality
► use-sub-block-value.ts
    Remove autofill and param storage logic
► general.tsx
    Remove autoFillEnvVars UI elements
► store.ts
    Remove toolParams storage
► types.ts
    Remove toolParams related types
► utils.ts
    Remove autofill helper functions
► schema.ts
    Mark autoFillEnvVars as deprecated

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@icecrasher321 icecrasher321 merged commit 7b73dfb into staging Jul 20, 2025
6 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/autofill-logic-simplified branch July 22, 2025 19:58
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…overwrites (simstudioai#726)

* fix(autofill-env-vars): simplify logic to not cause useEffect overwrites

* remove useless comments
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.

2 participants