Skip to content

fix: scope copilot drafts by workflow - #6020

Open
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
pi/AHNfUroy
Open

fix: scope copilot drafts by workflow#6020
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
pi/AHNfUroy

Conversation

@BillLeoutsakosvl346

@BillLeoutsakosvl346 BillLeoutsakosvl346 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Pass a workflow-specific draft scope key to MothershipChat in the workspace copilot panel.

Why

Copilot drafts need to remain isolated between workflows and from Home chat while preserving persisted text, attachments, and contexts.

How

Read workflowId from the route, build a stable ${workspaceId}:copilot:${workflowId} key, and provide it through draftScopeKey.

@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 9:44pm

Request Review

@BillLeoutsakosvl346 BillLeoutsakosvl346 changed the title chore: investigate Slack-reported engineering task fix: scope copilot drafts by workflow Jul 28, 2026
@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small UI wiring change in the workflow panel; no auth, API, or data-model changes.

Overview
The workflow panel copilot chat now passes a draftScopeKey ({workspaceId}:copilot:{workflowId}) into MothershipChat, so unsent composer text (and related draft state in UserInput via useMothershipDraftsStore) is keyed per workflow instead of behaving as if no scope were set.

This aligns workflow copilot with the existing draft-scoping pattern used elsewhere and avoids drafts bleeding across workflows or being lost when switching workflows or tabs.

Reviewed by Cursor Bugbot for commit 2271ac2. 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.

Approve. This is a small, focused change that follows the existing draftScopeKey pattern and scopes copilot drafts by both workspace and workflow without unnecessary complexity. I found no concrete bugs or regressions 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: fix: scope copilot drafts by workflow

This is a clean, minimal change that does exactly what the description says. Verdict: approve.

  • draftScopeKey is an existing, optional prop on MothershipChat (mothership-chat.tsx:69) that is threaded down into user-input.tsx and used to key drafts in useMothershipDraftsStore, so wiring a value in here is the right mechanism.
  • The ${workspaceId}:copilot:${workflowId} key introduces a distinct copilot: namespace, which correctly isolates the workspace copilot drafts both between workflows and from Home chat (whose keys are ${workspaceId}:${chatId ?? 'new'}). No collision risk.
  • params.workflowId is guaranteed present on the [workflowId] route, so the key can't degrade to an undefined segment.
  • Follows the exact same pattern already established in home.tsx.

No bugs, over-engineering, or redundancy spotted. Nice small fix.

Comment on lines +119 to +120
const workflowId = params.workflowId as string
const copilotDraftScopeKey = `${workspaceId}:copilot:${workflowId}`

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.

P2 Draft key omits chatId

copilotDraftScopeKey is ${workspaceId}:copilot:${workflowId} while home scopes drafts as ${workspaceId}:${chatId ?? 'new'}. Panel copilot still switches chats via chatId without remounting MothershipChat, so unsubmitted text, attachments, and contexts are shared across every chat in that workflow, and submit clears that shared draft for all of them. Include the active/resolved copilot chat id (or 'new') in the key for per-chat isolation.

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Enables persisted copilot composer drafts in the workflow panel by deriving a workflow-scoped draftScopeKey and passing it into MothershipChat/UserInput.

  • Reads workflowId from route params and builds ${workspaceId}:copilot:${workflowId}.
  • Passes draftScopeKey so mothership-drafts localStorage restore/save/clear runs for panel copilot (previously omitted, so no draft persistence).
  • Key prefix copilot avoids colliding with home keys (workspaceId:chatId).

Confidence Score: 4/5

Safe to merge for enabling draft persistence; only non-blocking concern is drafts shared across copilot chats within one workflow.

The change correctly wires optional draft persistence that was previously skipped when draftScopeKey was omitted, and the key format avoids home collisions; the remaining gap is product parity with per-chat draft isolation on the home path.

Files Needing Attention: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Adds workflow-scoped draftScopeKey for panel copilot; works for per-workflow persistence but shares drafts across chats unlike home.

Reviews (1): Last reviewed commit: "chore: investigate Slack-reported engine..." | Re-trigger Greptile

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