fix(copilot): scope panel chat drafts per chat - #7159
Merged
Conversation
The workflow panel's copilot draft key was scoped by workspace + workflow
only. A draft is cleared on submit and never on chat switch, and the scope
key is what remounts the input (`key={draftScopeKey}` in mothership-chat),
so selecting a different copilot chat in the same workflow carried the
previous chat's typed text, contexts, and file attachments into it. Key the
draft on the selected chat as well, matching the home chat.
Two consequences of per-chat keys handled here:
- deleting a chat now prunes its draft, which would otherwise be unreachable
in persisted storage forever
- drafts persisted under the old workflow-only key are dropped by a store
migration rather than left as unreadable entries
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThe PR scopes workflow-panel Copilot drafts by workspace, workflow, and chat, preventing text and attachments from carrying between chats.
Confidence Score: 5/5The PR appears safe to merge; no actionable correctness, security, or repository-rule violations were identified. The new key consistently scopes panel drafts to the active workflow and its workflow-scoped chat selection, deletion clears the key captured for the initiating workflow, and the migration preserves all currently consumed key shapes.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx | Extends the panel draft key with the selected chat ID and removes that scoped draft after successful chat deletion. |
| apps/sim/stores/mothership-drafts/store.ts | Documents draft key formats and adds a version-1 persistence migration that prunes obsolete workflow-only keys. |
| apps/sim/stores/mothership-drafts/store.test.ts | Verifies migration behavior for legacy workflow drafts, home drafts, per-chat drafts, and missing state. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Selection[Selected workflow and chat] --> Key[Build workspace/workflow/chat key]
Key --> Draft[Persist or restore scoped draft]
Delete[Delete chat succeeds] --> Clear[Clear matching scoped draft]
Legacy[Persisted v0 state] --> Migrate[Remove workflow-only keys]
Migrate --> Drafts[Preserve home and per-chat keys]
Reviews (1): Last reviewed commit: "fix(copilot): scope panel chat drafts pe..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
key={draftScopeKey}inmothership-chat.tsx), so selecting a different chat in the same workflow carried the previous chat's typed text, contexts, and file attachments into it. The home chat already keys drafts per chat id — this brings the panel in line.Known trade-off: when a workflow has no chat selected the key is
…:new, so the first send flips the key once and remounts the input. Text typed in that window is flushed to thenewbucket rather than the new chat's. The deeper fix is forUserInputto react todraftScopeKeychanges (flush old, restore new) instead of relying on thekeyremount — that belongs in a follow-up covering both surfaces at once.Type of Change
Testing
Tested manually.
bun run type-check,bun run lint, andbun run check:audits(36 audits) pass. Added unit tests for the store migration, verified they fail when the key pattern is broken.Checklist