Skip to content

refactor(stores): consolidate variables stores into stores/variables/#3930

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/consolidate-variables-stores
Apr 4, 2026
Merged

refactor(stores): consolidate variables stores into stores/variables/#3930
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/consolidate-variables-stores

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Apr 4, 2026

Summary

  • Move variable data store from stores/panel/variables/ to stores/variables/store.ts — the panel variables tab was removed, so the store no longer belongs under stores/panel/
  • Rename modal UI store export from useVariablesStore to useVariablesModalStore to eliminate the naming collision that forced aliased imports (useVariablesStore as usePanelVariablesStore)
  • Remove dead migrateStringToPlain function (defined but never called)
  • Merge variable data types and modal UI types into a single stores/variables/types.ts

Test plan

  • Verify variables floating modal opens/closes, drags, resizes correctly
  • Verify variable CRUD (add, edit, rename, delete) works in the floating modal
  • Verify variable references in blocks update when variables are renamed
  • Verify collaborative variable operations sync between clients
  • bunx tsc --noEmit passes with zero errors
  • bun run lint passes with zero errors

Move variable data store from stores/panel/variables/ to stores/variables/
since the panel variables tab no longer exists. Rename the modal UI store
to useVariablesModalStore to eliminate naming collision with the data store.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 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 4, 2026 1:36am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 4, 2026

PR Summary

Medium Risk
Moderate risk because it rewires variable state and modal UI state across many workflow/editor paths; regressions would mainly show up as variables panel open/close behavior or variable CRUD/reference updates.

Overview
Refactors variables state management by moving the variables data store out of stores/panel/variables into stores/variables/store, and updating all call sites (editor inputs, tag dropdown, execution/change detection, registry, API helpers) to use the new imports.

Splits concerns by introducing a dedicated UI-only modal store (useVariablesModalStore in stores/variables/modal) for open/position/size persistence, eliminating the prior useVariablesStore naming collision and removing the now-dead panel variables store exports.

Consolidates variable-related types into stores/variables/types and updates backend/utility typing (route.ts, duplication helper, VariableManager) to reference the new type location.

Reviewed by Cursor Bugbot for commit a29cbb1. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This PR is a clean structural refactoring that consolidates two previously separate variable store locations into a single stores/variables/ directory. It moves the variable data store from stores/panel/variables/ to stores/variables/store.ts, renames the modal UI store export from useVariablesStore to useVariablesModalStore (eliminating forced aliased imports), removes the dead migrateStringToPlain function, and merges types into a unified stores/variables/types.ts.

Key changes:

  • stores/variables/store.ts — variable data (CRUD, validation, name uniqueness, subblock reference updates)
  • stores/variables/modal.ts — floating modal UI state (position, dimensions, open/close) with persist middleware
  • stores/variables/types.ts — merged types for both data and modal stores
  • stores/variables/index.ts — barrel re-exporting all public symbols
  • 14 consumer files updated with corrected import paths
  • stores/panel/variables/ directory and its contents are now deleted

The refactoring is logically sound and the naming is now unambiguous. The PR passes tsc --noEmit and lint, confirming correctness at the type level. One minor TypeScript precision issue remains in a consumer file that was touched during the migration.

Confidence Score: 5/5

Safe to merge — pure store reorganization with no logic changes; tsc and lint pass cleanly.

All remaining findings are P2. The single comment flags a pre-existing Record<string, any> that the PR could have tightened while touching the file, but it causes no runtime issue. The naming collision is resolved, the barrel exports are complete, and the deleted stores/panel/variables/ directory is fully replaced.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts — minor any-type tightening opportunity

Important Files Changed

Filename Overview
apps/sim/stores/variables/store.ts Moved data store with CRUD operations, name-uniqueness logic, and subblock reference updates — clean and correct
apps/sim/stores/variables/modal.ts Renamed store export (useVariablesModalStore) with persist middleware — position constraining logic and default calculation are correct
apps/sim/stores/variables/types.ts Unified type file merging data and modal store interfaces — well-typed with TSDoc on all exports
apps/sim/stores/variables/index.ts Barrel export re-exporting all public symbols from the new store location — complete and correct
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts Import path updated; contains Record<string, any> that could use Record<string, Variable> per no-any rule
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/variables/variables.tsx Updated to import from new store paths (modal and store separately); floating modal component logic is clean
apps/sim/stores/workflows/registry/store.ts Import updated from old panel/variables path to new stores/variables/store — no logic changes

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before["Before (stores/panel/variables/)"]
        PV["stores/panel/variables/store.ts\n(useVariablesStore — data)"]
        PVT["stores/panel/variables/types.ts"]
        PVI["stores/panel/variables/index.ts"]
        PVM["stores/variables/modal.ts\n(useVariablesStore — modal ⚠️ name collision)"]
    end

    subgraph After["After (stores/variables/)"]
        VS["stores/variables/store.ts\n(useVariablesStore — data)"]
        VM["stores/variables/modal.ts\n(useVariablesModalStore — modal ✅)"]
        VT["stores/variables/types.ts\n(merged data + modal types)"]
        VI["stores/variables/index.ts\n(barrel export)"]
    end

    subgraph Consumers
        WR["stores/workflows/registry/store.ts"]
        CW["hooks/use-collaborative-workflow.ts"]
        VC["components/variables/variables.tsx"]
        CD["use-change-detection.ts"]
        WE["use-workflow-execution.ts"]
        API["api/workflows/id/variables/route.ts"]
        DUP["lib/workflows/persistence/duplicate.ts"]
        VM2["lib/workflows/variables/variable-manager.ts"]
    end

    Before -->|"refactor"| After
    VS --> Consumers
    VM --> VC
    VT --> VS & VM & WR & API & DUP & VM2
    VI --> Consumers
Loading

Reviews (2): Last reviewed commit: "fix: remove unused workflowId variable i..." | Re-trigger Greptile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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 a29cbb1. Configure here.

@waleedlatif1 waleedlatif1 merged commit 98fe4cd into staging Apr 4, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/consolidate-variables-stores branch April 4, 2026 01:43
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