Skip to content

v0.6.23: MCP fixes, remove local state in favor of server state, mothership workflow edits via sockets, ui improvements#3935

Merged
waleedlatif1 merged 10 commits intomainfrom
staging
Apr 4, 2026
Merged

v0.6.23: MCP fixes, remove local state in favor of server state, mothership workflow edits via sockets, ui improvements#3935
waleedlatif1 merged 10 commits intomainfrom
staging

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

waleedlatif1 and others added 9 commits April 3, 2026 17:44
* fix(loading): remove jarring workflow loading spinners

* fix(loading): remove home page skeleton loading state

* fix(loading): remove plain spinner loading states from task and file view
…#3930)

* refactor(stores): consolidate variables stores into stores/variables/

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>

* fix: remove unused workflowId variable in deleteVariable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* improvement(mothership): workflow edits via sockets

* make embedded view join room

* fix cursor positioning bug
* Fix oauth redirect on connector modal

* Fix lint

---------

Co-authored-by: Theodore Li <theo@sim.ai>
…3932)

* fix(mcp): resolve userId before JWT generation for agent block auth

* test(mcp): add regression test for agent block JWT userId resolution
* Fix "fix in copilot" button

* Auto send message to copilot for fix in copilot

---------

Co-authored-by: Theodore Li <theo@sim.ai>
…ebar and panel (#3934)

* fix(modals): center modals in visible content area accounting for sidebar and panel

* fix(modals): address pr feedback — comment clarity and document panel assumption
@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 3:06am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 4, 2026

PR Summary

Medium Risk
Medium risk because it reshapes workflow deployment/env/variable state management (Zustand → React Query/new stores) and introduces a new socket-driven reload path that can affect collaboration/state consistency across clients.

Overview
Shifts several pieces of client state from Zustand to server/React Query-backed sources. Deployment status/"needs redeploy" fields are removed from workflow state and registry, env vars now come from the environmentKeys.personal() query cache, and variable UI state is split into a new persisted useVariablesModalStore while variable data stays in useVariablesStore.

Improves real-time consistency and OAuth connector flows. Copilot workflow edits now notify the socket server (/api/workflow-updated) and clients listen for workflow-updated to reload the active workflow state; KB OAuth/connectors preserve and drive the “add connector” modal via a new addConnector URL param passed through OAuth callbacks.

UI polish/cleanup. Modals/search are centered relative to visible workspace content (accounting for sidebar/panel), sidebar width defaults avoid non-workspace hydration mismatch, and several route-level loading spinners/skeletons are removed.

Reviewed by Cursor Bugbot for commit 3267d8c. Configure here.

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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3267d8c. Configure here.

variables: {},
isLoading: false,
error: null,
isEditing: null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dead state fields never change from initial values

Low Severity

The new VariablesStore declares isLoading, error, and isEditing in both the type interface and the store initialization, but the old loadForWorkflow method that set isLoading and error was removed during the consolidation. No remaining actions in the store ever modify these fields, making them permanently stuck at their initial values (false, null, null). This is dead state carried over from the old store.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3267d8c. Configure here.

return result
}

return value
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Regex with global flag shared across recursive calls

Medium Severity

The updateReferences helper uses pattern.test(value) with a regex created with the gi flags, then calls value.replace(pattern, ...). While replace resets lastIndex, the test() call inside the recursive traversal of arrays and objects mutates lastIndex on the shared regex. If test() matches a string inside a nested structure and then replace is NOT reached (e.g., a non-string branch returns early), subsequent test() calls can start from a non-zero lastIndex and miss matches in sibling values.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3267d8c. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This is a wide-ranging v0.6.23 release that removes Zustand-managed server state in favour of React Query caches, fixes MCP JWT auth for agent blocks, closes the OAuth redirect loop on the KB connector modal, and wires copilot workflow edits through the socket layer so collaborators see changes immediately.

Key changes:

  • Deployment state → React Query (stores/workflows/registry/store.ts, hooks/queries/deployments.ts): deploymentStatuses is removed from Zustand entirely; all deploy/undeploy/activate mutations now use a single onSettled handler that invalidates the React Query cache, following the project's recommended pattern.
  • Environment store → React Query (stores/settings/environment/, hooks/queries/environment.ts, tools/utils.ts): useEnvironmentStore and its initialization scaffolding are deleted; client-side env-var resolution now reads from getQueryClient().getQueryData(environmentKeys.personal()).
  • Variables store consolidation (stores/panel/variables/stores/variables/): Modal UI state is separated into modal.ts while variable data lives in store.ts, eliminating the old persist-based combined store.
  • Mothership workflow edits via sockets (lib/copilot/tools/server/workflow/edit-workflow/index.ts, socket-provider.tsx, use-collaborative-workflow.ts): After persisting a copilot edit to the DB, a fire-and-forget POST notifies the socket server; the client handles workflow-updated events by reloading the workflow state from the API (skipping if an active diff is in progress).
  • MCP JWT fix (tools/index.ts): resolveToolScope is now called before generateInternalToken so the agent-block user ID is correctly embedded in the JWT.
  • OAuth connector redirect fix (oauth-modal.tsx, use-oauth-return.ts, add-connector-modal.tsx, base.tsx): The addConnector search param is threaded through the OAuth callback URL so the KB page reopens at the correct connector-configuration step after OAuth completes.
  • Modal centering (modal.tsx, globals.css, layout.tsx): The emcn ModalContent now accounts for sidebar and panel widths when computing its left offset; the CSS default for --sidebar-width is set to 0px and the blocking script in layout.tsx always writes the real value before first paint.

Confidence Score: 5/5

Safe to merge — all findings are P2 style/architectural suggestions with no correctness or data-integrity impact.

The MCP JWT fix, OAuth redirect fix, and deployment-state migration are well-tested (new test cases added). The Zustand → React Query migration follows project conventions and the old initialization scaffolding is cleanly removed. The only concerns are P2: a Next.js routing import inside the emcn UI primitive, a globals.css edit that technically violates the custom rule (but is justified by the blocking-script design), and the lack of a retry path when workflow-updated is skipped due to an active diff.

apps/sim/components/emcn/components/modal/modal.tsx (Next.js usePathname coupling), apps/sim/hooks/use-collaborative-workflow.ts (no retry after skipped workflow-updated).

Important Files Changed

Filename Overview
apps/sim/hooks/use-collaborative-workflow.ts Adds workflow-updated socket handler for copilot edits, extracts shared reloadWorkflowFromApi helper, and simplifies handleWorkflowReverted; skipped-update path has no retry when hasActiveDiff is true.
apps/sim/components/emcn/components/modal/modal.tsx Adds sidebar/panel-aware modal centering via usePathname; introduces a Next.js routing dependency in the shared emcn UI primitive.
apps/sim/app/_styles/globals.css Changes --sidebar-width default from 248px to 0px; safe because the blocking script in layout.tsx always sets the real value before first paint, but violates the 'avoid globals.css edits' rule.
apps/sim/hooks/queries/deployments.ts Removes Zustand deploymentStatuses sync from all three deploy/undeploy/activate mutations; replaces onSuccess/onError pair with a single onSettled that always invalidates cache — correct pattern per project guidelines.
apps/sim/tools/index.ts MCP fix: moves resolveToolScope before generateInternalToken so the resolved userId (from agent-block params) is used in the JWT, not the raw executionContext.userId.
apps/sim/stores/index.ts Strips out all initialization scaffolding in favour of React Query; resetAllStores now removes the environment query cache instead of calling useEnvironmentStore.reset().
apps/sim/stores/variables/store.ts Consolidated from stores/panel/variables/store.ts; modal state split into modal.ts, data store kept here with operation-queue persistence replacing direct fetch.
apps/sim/stores/workflows/registry/store.ts Removes deploymentStatuses map and its three actions; on loadWorkflowState now seeds the React Query cache via getQueryClient().setQueryData instead of mutating Zustand state.
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/index.ts After persisting workflow changes to DB, fires a fire-and-forget POST to the socket server's /api/workflow-updated endpoint so connected clients reload the new state.
apps/sim/app/workspace/providers/socket-provider.tsx Adds workflow-updated socket event and onWorkflowUpdated callback; fixes a null-ref guard on urlWorkflowIdRef.current before the stale-join-success check; removes deploymentStatuses from rehydration.
apps/sim/app/workspace/[workspaceId]/components/oauth-modal.tsx Threads connectorType through the OAuth flow so the callback URL carries the addConnector search param, allowing the KB page to reopen the correct step after OAuth redirect.
apps/sim/tools/utils.ts Replaces useEnvironmentStore.getState() with getQueryClient().getQueryData(environmentKeys.personal()) for client-side env-var resolution; removes the injectable getStore parameter (tests updated to match).

Sequence Diagram

sequenceDiagram
    participant Copilot as Copilot (server tool)
    participant DB as Database
    participant SocketSrv as Socket Server
    participant Client as Browser Client
    participant API as /api/workflows/[id]

    Copilot->>DB: Persist workflow edits
    Copilot-->>SocketSrv: POST /api/workflow-updated (fire & forget)
    SocketSrv-->>Client: emit('workflow-updated', { workflowId })

    alt hasActiveDiff == false
        Client->>API: GET /api/workflows/[id]
        API-->>Client: { data: { state } }
        Client->>Client: replaceWorkflowState(state)
        Client->>Client: useSubBlockStore.setState(subblockValues)
        Client->>Client: pruneInvalidUndoRedoEntries(graph)
    else hasActiveDiff == true
        Client->>Client: log warn & skip reload (no retry scheduled)
    end
Loading

Comments Outside Diff (1)

  1. apps/sim/components/emcn/components/modal/modal.tsx, line 109-122 (link)

    P2 Next.js routing dependency in a shared UI primitive

    ModalContent (inside the EMCN component library) now imports usePathname from next/navigation, tying a foundational UI primitive to Next.js-specific routing. This breaks the component's portability and means every modal instance re-renders on route changes purely for a layout adjustment.

    A cleaner approach would be a CSS-only calc() expression using just the two CSS variables, avoiding the runtime check entirely:

    // Without usePathname — pure CSS:
    style={{
      left: 'calc(50% + (var(--sidebar-width) - var(--panel-width)) / 2)',
      ...style,
    }}

    This formula naturally equals 50% when --panel-width is 0 (non-workflow pages) and centers in the content area when both vars are set, eliminating the isWorkflowPage branch entirely.

Reviews (1): Last reviewed commit: "fix(modals): center modals in visible co..." | Re-trigger Greptile

…ose animation (#3937)

* fix(modals): center modals in visible content area accounting for sidebar and panel

* fix(modals): address pr feedback — comment clarity and document panel assumption

* fix(modals): remove open/close animation from modal content
@waleedlatif1 waleedlatif1 merged commit 0b9019d into main Apr 4, 2026
26 checks passed
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.

3 participants