Skip to content

fix: persist Copilot drafts per workflow - #6017

Closed
BillLeoutsakosvl346 wants to merge 2 commits into
stagingfrom
pi/oI1D29Gs
Closed

fix: persist Copilot drafts per workflow#6017
BillLeoutsakosvl346 wants to merge 2 commits into
stagingfrom
pi/oI1D29Gs

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

Persist unsent workflow Copilot drafts across navigation, including text, attachments, and contexts.

Why

Workflow panel drafts were not restored after navigating away, and must remain isolated per workflow and from the main workspace chat.

How

Build a stable draft scope key from the route workspace and workflow IDs and pass it to MothershipChat, reusing the existing draft restore and post-submission cleanup behavior.

@vercel

vercel Bot commented Jul 28, 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 28, 2026 8:48pm

Request Review

@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only draft scoping in the workflow panel; reuses existing draft persistence with no auth or data-path changes.

Overview
Workflow panel Copilot now keeps unsent composer state (text, attachments, contexts) when you leave and come back, with one draft bucket per workflow so it does not mix with the main workspace chat.

The panel builds a stable scope key {workspaceId}:copilot:{activeWorkflowId}, passes it to MothershipChat as draftScopeKey, and uses the same value as the component key so switching workflows remounts the input and loads the right stored draft via the existing UserInput / mothership-drafts behavior.

Reviewed by Cursor Bugbot for commit c718f0b. Bugbot is set up for automated code reviews on this repo. Configure here.

@BillLeoutsakosvl346 BillLeoutsakosvl346 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review

Approved. This is a simple, targeted reuse of the existing draftScopeKey mechanism. The workspace/Copilot/workflow key scopes drafts per workflow and avoids collisions with the main workspace chat key format, while preserving the existing restoration and submission cleanup behavior. I found no concrete bugs, unnecessary complexity, redundancy, or pattern violations in the diff.

@BillLeoutsakosvl346 BillLeoutsakosvl346 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review — PR #6017: persist Copilot drafts per workflow

This is a clean, minimal, one-file change that does exactly what it claims and nothing more.

What it does: derives workflowId from route params and builds a copilotDraftScopeKey (${workspaceId}:copilot:${workflowId}), then passes it to MothershipChat as draftScopeKey.

Assessment:

  • Follows existing patterns. This mirrors home.tsx (draftScopeKey = ${workspaceId}:${chatId ?? 'new'}) and reuses the already-wired draftScopeKey prop path through MothershipChatUserInput and the existing useMothershipDraftsStore restore/save/clear logic. No new machinery is introduced.
  • Correct isolation. The :copilot: segment keeps the workflow Copilot drafts namespaced separately from the main workspace chat drafts (${workspaceId}:${chatId}), and the trailing workflowId isolates per workflow, matching the stated goal. The key shapes can't collide (2 segments vs 3).
  • No over-engineering / no defensive cruft. Just the two lines needed to compute the key plus the prop pass-through. workflowId is guaranteed present in this [workflowId] route, so the as string cast is consistent with the existing workspaceId handling.

One thing worth being aware of (not a blocker, and consistent with the existing home.tsx behavior): the draft restore in UserInput is mount-only (hasRestoredDraftRef + empty deps), so restoration relies on the component remounting when workflowId changes on navigation. This is the same contract used by the main chat, so it's reasonable to inherit here.

LGTM — approve.

Comment on lines +903 to 904
draftScopeKey={copilotDraftScopeKey}
layout='copilot-view'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Draft not swapped on workflow change

When soft-navigating between workflows, draftScopeKey updates in place but Panel/MothershipChat/UserInput are not keyed by workflow, and UserInput only restores drafts on mount while always saving edits to draftScopeKeyRef.current. The previous workflow's text, attachments, and contexts stay in the editor and further edits overwrite the new workflow's stored draft, so drafts leak across workflows until a full remount.

Suggested change
draftScopeKey={copilotDraftScopeKey}
layout='copilot-view'
key={copilotDraftScopeKey}
draftScopeKey={copilotDraftScopeKey}
layout='copilot-view'

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Persist unsent workflow Copilot drafts per workspace/workflow by passing a stable draftScopeKey into MothershipChat.

  • Adds workflowId from route params and builds ${workspaceId}:copilot:${workflowId}.
  • Passes draftScopeKey into the existing copilot MothershipChat so text/attachments/contexts reuse mothership draft store restore and post-submit cleanup.

Confidence Score: 3/5

Not safe to merge until draft restore/swap on workflow navigation is fixed so drafts stay isolated when switching workflows without a full remount.

Passing a workflow-scoped draftScopeKey is correct for isolation in the store, but UserInput only restores on mount and keeps saving the live editor into the latest key, so soft workflow switches leave the wrong draft visible and can overwrite another workflow's draft.

Files Needing Attention: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx (and UserInput/MothershipChat draftScopeKey lifecycle if fixed there)

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Wires per-workflow draftScopeKey into MothershipChat, but without remounting/rehydrating UserInput on workflow change so drafts can bleed across workflows.

Reviews (1): Last reviewed commit: "fix: persist Copilot drafts per workflow" | Re-trigger Greptile

@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.

Cursor Bugbot has reviewed your changes using high effort and found 3 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 e554493. Configure here.

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
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