Skip to content

fix(copilot): persist workflow drafts across navigation - #6807

Open
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
fix/persist-workflow-copilot-drafts
Open

fix(copilot): persist workflow drafts across navigation#6807
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
fix/persist-workflow-copilot-drafts

Conversation

@BillLeoutsakosvl346

@BillLeoutsakosvl346 BillLeoutsakosvl346 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Persist unsent workflow Copilot text, completed attachments, and context chips across navigation and refresh.
  • Reuse the existing localStorage-backed Mothership draft store with one namespaced bucket per workspace and workflow.
  • Use the route workflow on initial hydration, then follow the active operational workflow so the draft, transcript, and send target change together.
  • Key only the composer when the workflow scope changes; transcript and scroll state remain untouched.
  • Keep the scope stable while a new Copilot chat receives its server ID so queued follow-up text cannot be lost.
  • Leave Copilot rendering, cross-surface handoffs, APIs, schemas, backend logic, and the draft store unchanged.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other

Testing

  • bunx biome check on both changed files
  • bun run check:audits — 29/29 audits passed
  • bun run lint:check — 24/24 tasks passed
  • bun run type-check — 24/24 tasks passed
  • bun run test — 17/17 tasks passed; app suite 27,406 passed, 46 skipped
  • bunx turbo run build --filter=@sim/app — passed
  • git diff --check — passed
  • After review changes: scoped Biome, @sim/app type-check, and diff check passed

Interactive localhost QA was not available in the agent browser session. Reviewer focus: type an unsent workflow Copilot draft, navigate away and return or refresh, confirm it restores; switch workflows and confirm isolation; send and confirm the draft clears.

No new automated test was added because this adopts an existing persistence path, while a mocked Panel test would only assert prop wiring rather than route-navigation behavior.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Existing tests are passing; no wiring-only test added
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement

Screenshots/Videos

Not attached because an interactive localhost browser session was unavailable.

@vercel

vercel Bot commented Aug 18, 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 Aug 18, 2026 3:25am

Request Review

@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only wiring to an existing draft persistence path; no backend, auth, or data model changes.

Overview
Workflow Copilot now persists unsent composer state (text, attachments, context chips) using the existing Mothership localStorage draft store, scoped per workspace and workflow via draftScopeKey (workspaceId:workflow-copilot:workflowId).

Panel derives the workflow id from the hydrated registry or the route param so the scope stays stable during navigation and while a new chat receives its server id. It passes draftScopeKey into MothershipChat.

MothershipChat keys only UserInput with draftScopeKey so drafts restore when switching workflows without remounting the transcript. No API or store changes.

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

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reuses the localStorage-backed Mothership draft store for workflow Copilot and remounts only the composer when its workflow scope changes.

  • Adds a workspace-and-workflow draft key to the Copilot panel.
  • Keys UserInput by draft scope so persisted text, completed attachments, and context chips restore when the scope changes.
  • The scope currently follows asynchronously hydrated registry state, leaving a wrong-workflow window during navigation.

Confidence Score: 4/5

The workflow draft scope should be tied to the current route before merging because navigation can save new Copilot input under the previous workflow and then make it disappear.

During an asynchronous workflow switch, the panel can render the destination workflow while activeWorkflowId still names the source workflow, causing the newly added persistence wiring to write drafts into the wrong scope until hydration completes.

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

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Keys UserInput by draft scope to trigger restoration without remounting the transcript; the remount exposes the panel's stale-scope transition.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Adds workflow-scoped Copilot persistence, but derives the key from registry state that can still identify the previous workflow during asynchronous navigation.

Sequence Diagram

sequenceDiagram
  participant U as User
  participant R as Workflow route
  participant P as Panel
  participant G as Workflow registry
  participant D as Draft store
  U->>R: Navigate A → B
  R->>P: Render workflow B
  G-->>P: "activeWorkflowId = A"
  P->>D: Use scope workspace:copilot:A
  U->>P: Type draft on B
  P->>D: Persist under A
  R->>G: Hydrate workflow B
  G-->>P: "activeWorkflowId = B"
  P->>P: Remount composer
  D-->>P: Restore B draft
Loading

Reviews (1): Last reviewed commit: "fix(copilot): persist workflow drafts ac..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/persist-workflow-copilot-drafts branch from fc3aa8f to f12acb9 Compare August 18, 2026 03:07
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/persist-workflow-copilot-drafts branch from f12acb9 to c7a99d0 Compare August 18, 2026 03:14

@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 1 potential issue.

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 c7a99d0. Configure here.

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/persist-workflow-copilot-drafts branch from c7a99d0 to 3024651 Compare August 18, 2026 03:25
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