Skip to content

improvement(editor): fix React effect/state anti-patterns across the /w surface#5325

Open
waleedlatif1 wants to merge 3 commits into
stagingfrom
worktree-w-react-doctor
Open

improvement(editor): fix React effect/state anti-patterns across the /w surface#5325
waleedlatif1 wants to merge 3 commits into
stagingfrom
worktree-w-react-doctor

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes React effect/state anti-patterns across the entire /w workflow-editor surface (raised the react-doctor health score 24 → 49; errors 70 → 24)
  • Replaces derived-state-in-effect, prop-sync effects, and event-logic-in-effect with render-phase adjustment, derived render values, and event-handler side effects
  • Stabilizes unstable references (memoization, module-scope hoists, stateref for values never rendered) and fixes several latent stale-closure dependency bugs (use-float-resize resize constraints, use-wand conversation history, missing blockExecutionMap/workspaceId deps)
  • Accessibility: adds labels/roles/type="button" where safe; JS micro-optimizations (single-pass loops, Set/Map lookups)
  • Zero suppressions added (removed 5 pre-existing eslint-disables by fixing root causes)

Type of Change

  • Improvement / refactor (no behavior change)

Testing

Tested manually. tsc clean, Biome clean. Every one of the 92 changed files was line-by-line audited by an independent adversarial reviewer for behavior equivalence — one mount-timing regression was caught and fixed before shipping.

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)

…/w surface

Removes derived-state-in-effect, prop-sync effects, and event-logic-in-effect
across the workflow editor in favor of render-phase adjustment, derived render
values, and event-handler side effects. Stabilizes unstable references
(memoization, module-scope hoists, state->ref for non-rendered values), fixes
several stale-closure dependency bugs, and adds accessibility labels/roles.
No behavior changes; typecheck and lint clean.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 1, 2026 7:08pm

Request Review

@cursor

cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Broad touch surface in workflow chat, deploy, and copilot/editor inputs where render-phase setState and ref migrations can subtly change timing or stale closures despite the intent to preserve behavior.

Overview
Large refactor across chat, copilot input, deploy modal, editor sub-blocks, and related /w components to align with React guidance: fewer “sync props/state in useEffect” patterns and more render-time adjustment (prev-ref comparisons), refs for values that never need to paint (e.g. chat prompt history, deploy chat image URL, custom tool id), and derived values computed during render or via useMemo.

Copilot & mentions: context list syncing, past-chat reset on workflow change, combobox input mirroring selected labels, and message/local-buffer adoption move off mount-only effects where that could flash stale UI.

Deploy & chat: deploy-modal resets tab/errors on open/workflow change during render; identifier validation splits sync rules from debounced API checks; MCP save uses a server Map for lookups.

Editor sub-blocks: repeated inline renderX() helpers become stable child components (LineNumbers, TagHeader, MetricHeader, table header/delete cells, etc.); several inputs fix default-prop array identity, filter/sort rules memoization, and useCallback dependency lists (e.g. workflow chat streaming handler).

Misc: useContextuse in a few providers; type="button" and aria-label on hidden/icon controls; small loop/flatMap/Map optimizations in cursors, tag dropdown, and tool-input.

Reviewed by Cursor Bugbot for commit 71d3809. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors React state and effect patterns across the workflow editor. The main changes are:

  • Replaced derived-state effects with render-time values and refs.
  • Stabilized callbacks, memoized values, and mutable references across editor surfaces.
  • Updated deploy modal imports to use absolute barrel paths.
  • Added small accessibility attributes and button types.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The latest import changes follow the expected absolute barrel pattern.
  • The reviewed callback and ref changes did not show a new reachable breakage.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx Updated deploy modal imports to use the established absolute barrel path pattern.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/chat/chat.tsx Kept chat deploy image URL handling on a ref and updated the validation hook import path.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts Stabilized workflow execution callbacks without changing the log persistence behavior.

Reviews (3): Last reviewed commit: "improvement(editor): convert new inline ..." | Re-trigger Greptile

Addresses review feedback: the no-barrel-import cleanup introduced relative
imports that violate the absolute-import rule and conflict with the repo's
barrel convention. Reverts to absolute barrel imports (deploy-modal, general,
chat hooks, connection-blocks, toolbar, search-groups).
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 14add6d. Configure here.

Replaces the multi-line // comment blocks introduced by this PR (render-phase
adjustment rationale, derived-in-render notes) with concise TSDoc, per the
repo's TSDoc-only comment convention. Comment-only; no code changes.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 71d3809. 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