From 44b862aa2f0aab38411bfaf25d75084abd0f16e6 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 10:17:06 +0000 Subject: [PATCH 1/2] test(agent): a coach-held send is not sent after consent is cleared or the account changes Without a release on these transitions the held send waits until the panel unmounts, and an account switch without reload can send the first account's draft under the second account's consent. --- .../extensions/agent/AgentPanelRoot.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index 8a75fb3ba88..1b7f258ac11 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -6026,6 +6026,44 @@ describe('AgentPanelRoot workflow binding', () => { expect(bodies).toHaveLength(0) }) + it('puts the draft back when consent is cleared while the panel stays open', async () => { + makeTab('wf-42') + const bodies = mockMessagesEndpoint('wf-42') + const settleSubmission = vi.spyOn( + useAgentComposerStore(), + 'settleSubmission' + ) + renderWithSelectedTarget() + await sendHeldByCoach('build me a workflow') + + Object.assign(useAgentConsentStore(), { accepted: false }) + + await waitFor(() => + expect(settleSubmission).toHaveBeenCalledWith(expect.any(Number), false) + ) + expect(bodies).toHaveLength(0) + }) + + it('puts the draft back when the consent identity changes during the hold', async () => { + makeTab('wf-42') + const bodies = mockMessagesEndpoint('wf-42') + const settleSubmission = vi.spyOn( + useAgentComposerStore(), + 'settleSubmission' + ) + renderWithSelectedTarget() + await sendHeldByCoach('build me a workflow') + + Object.assign(useAgentConsentStore(), { + identity: JSON.stringify(['account-b', 'workspace-hold', 0]) + }) + + await waitFor(() => + expect(settleSubmission).toHaveBeenCalledWith(expect.any(Number), false) + ) + expect(bodies).toHaveLength(0) + }) + it('puts the draft back instead of sending when the panel closes', async () => { makeTab('wf-42') const bodies = mockMessagesEndpoint('wf-42') From 039af61bed54955eba38a7075d8cfea42ac83df1 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 10:19:58 +0000 Subject: [PATCH 2/2] fix(agent): release the coach hold when consent is cleared or its identity changes Ports the release condition and the consent-identity recheck that main already has, so the held send restores the draft instead of waiting or going out under another account's consent. --- .../extensions/agent/AgentPanelRoot.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 19d8d7fc73f..64ae5611fd4 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -171,7 +171,9 @@ const { } = useBillingContext() const conversationStore = useAgentConversationStore() const history = useAgentChatHistoryStore() -const { accepted: consentAccepted } = storeToRefs(useAgentConsentStore()) +const { accepted: consentAccepted, identity: consentIdentity } = storeToRefs( + useAgentConsentStore() +) watch( subscription, (currentSubscription) => { @@ -605,10 +607,11 @@ function releaseCoachCompletionWaiters(proceed = true): void { coachCompletionWaiters.clear() } watch( - [consentAccepted, onboardingKey, coachDeferredBy], - ([accepted, key, reason]) => { + [consentAccepted, onboardingKey, coachDeferredBy, consentIdentity], + ([accepted, key, reason, identity], previous) => { if (accepted && key && !hasSeenCoach(key)) trackCoachDeferral(key, reason) - if (reason !== null) releaseCoachCompletionWaiters() + if (!accepted || reason !== null || identity !== previous[3]) + releaseCoachCompletionWaiters() }, { immediate: true } ) @@ -1620,10 +1623,12 @@ async function consentAllowsSubmission( ): Promise { let hasConsent = false let coachReleased = false + let acceptedIdentity: string | null = null consentHeldSubmissionId = submissionId try { await withConsent('first_message', () => { hasConsent = true + acceptedIdentity = consentIdentity.value }) if (hasConsent) coachReleased = await waitForCoachCompletion() } finally { @@ -1634,7 +1639,8 @@ async function consentAllowsSubmission( composerStore.submission?.id === submissionId && hasConsent && coachReleased && - consentAccepted.value + consentAccepted.value && + consentIdentity.value === acceptedIdentity ) }