Skip to content

Commit be14d27

Browse files
BillLeoutsakosvl346Bill Leoutsakos
andauthored
fix(copilot): persist workflow drafts across navigation (#6807)
Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
1 parent 895d40e commit be14d27

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ export function MothershipChat({
827827
onCancelEdit={onCancelQueueEdit}
828828
/>
829829
<UserInput
830+
key={draftScopeKey}
830831
ref={userInputRef}
831832
onSubmit={onSubmit}
832833
isSending={isStreamActive}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const Panel = memo(function Panel() {
118118
const router = useRouter()
119119
const params = useParams()
120120
const workspaceId = params.workspaceId as string
121+
const routeWorkflowId = params.workflowId as string | undefined
121122

122123
const posthog = usePostHog()
123124
const posthogRef = useRef(posthog)
@@ -397,6 +398,10 @@ export const Panel = memo(function Panel() {
397398
},
398399
})
399400
)
401+
const copilotDraftWorkflowId = activeWorkflowId ?? routeWorkflowId
402+
const copilotDraftScopeKey = copilotDraftWorkflowId
403+
? `${workspaceId}:workflow-copilot:${copilotDraftWorkflowId}`
404+
: undefined
400405

401406
const handleCopilotNewChat = useCallback(() => {
402407
if (!activeWorkflowId || !workspaceId) return
@@ -943,6 +948,7 @@ export const Panel = memo(function Panel() {
943948
onCancelQueueEdit={copilotCancelQueueEdit}
944949
userId={session?.user?.id}
945950
chatId={copilotResolvedChatId}
951+
draftScopeKey={copilotDraftScopeKey}
946952
layout='copilot-view'
947953
/>
948954
</div>

0 commit comments

Comments
 (0)