Skip to content

Commit c7a99d0

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(copilot): persist workflow drafts across navigation
1 parent edc25aa commit c7a99d0

2 files changed

Lines changed: 5 additions & 1 deletion

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
@@ -764,6 +764,7 @@ export function MothershipChat({
764764
onCancelEdit={onCancelQueueEdit}
765765
/>
766766
<UserInput
767+
key={draftScopeKey}
767768
ref={userInputRef}
768769
onSubmit={onSubmit}
769770
isSending={isStreamActive}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const Panel = memo(function Panel() {
117117
const router = useRouter()
118118
const params = useParams()
119119
const workspaceId = params.workspaceId as string
120+
const routeWorkflowId = params.workflowId as string
120121

121122
const posthog = usePostHog()
122123
const posthogRef = useRef(posthog)
@@ -396,6 +397,7 @@ export const Panel = memo(function Panel() {
396397
},
397398
})
398399
)
400+
const copilotDraftScopeKey = `${workspaceId}:workflow-copilot:${routeWorkflowId}`
399401

400402
const handleCopilotNewChat = useCallback(() => {
401403
if (!activeWorkflowId || !workspaceId) return
@@ -847,7 +849,7 @@ export const Panel = memo(function Panel() {
847849

848850
{/* Tab Content - Keep all tabs mounted but hidden to preserve state */}
849851
<div className='flex-1 overflow-hidden pt-3'>
850-
{isCopilotTabAvailable && (
852+
{isCopilotTabAvailable && activeWorkflowId === routeWorkflowId && (
851853
<div
852854
className={
853855
_hasHydrated && activeTab === 'copilot'
@@ -943,6 +945,7 @@ export const Panel = memo(function Panel() {
943945
onCancelQueueEdit={copilotCancelQueueEdit}
944946
userId={session?.user?.id}
945947
chatId={copilotResolvedChatId}
948+
draftScopeKey={copilotDraftScopeKey}
946949
layout='copilot-view'
947950
/>
948951
</div>

0 commit comments

Comments
 (0)